Elm Language — Conclusion:

COSC4315 TT
4 min readApr 22, 2019

--

Benchmarking speed, memory footprint, safety, ease of use, reasons to use the language

part 1, part 2, part 3, and part 4 of series on Elm

Benchmarking:

Changes to upgrade performance for some input on one platform can deteriorate performance for a different input or platform. Using different platforms, browsers and types to test with, is a significant step to ensuring that the performance improvement really is a universal improvement.

The performance of a a > b heavily depends on the type. Some changes will work better for smaller datasets, others on larger datasets. Or changes might result in Javascript that might initially perform better, but can’t be handled efficiently by an optimising JIT. Developing for performance isn’t explicit. However, in terms of speed, Elm is second to none that can be statistically proven.

Creator of Elm, Evan Czaplicki created a benchmark that compares the renderer performance of Elm, Ember, React, and Angular. The benchmark is a TodoMVCapp where items are added and removed rapidly using for loops.

Here are the results:

As we can see, Elm is the fastest among the four languages. Elm is at least 30% faster than others.

Memory Footprint:

Elm compiles to JavaScript. JavaScript is a lightweight programming language. It is designed to have a small memory footprint. This is the amount of main memory that it uses. Low memory utilization is an essential feature for languages that are geared towards building websites and web applications. Part of the reason why, is because these applications have to be able to run on mobile devices. Elm is outstanding for this purpose.

Safety:

Elm is a functional language. One of its features is that it has no runtime errors. These are errors that occur during the execution of a program. Furthermore, all data in Elm is immutable. This means that a value can not be changed after it is created. This prevents side effects from occurring. Side effects modify state. State is the data stored at a given time that a function can access. Because of this, all functions in Elm are pure. They will always return the same output given the same input. These characteristics allow Elm to be easy to debug. Pure functions remove the dependencies that functions may have on code that was executed before them. This occurs in languages that do not implement pure functions. In Elm, a function’s output depends solely on its arguments and other immutable data in its scope. An error in Elm will most likely be the product of incorrectly applied logic inside a function. Naturally, this translates to easy testing as well. Verifying the proper output of each function is easier. This translates to unit testing in Elm. Qualities of this sort make Elm a safe language to use.

The function doubleNumbers does not change the list. This is an example of immutability.

Ease of Use:

Being a declarative language, ease of use is an inherent quality of Elm. The focus is on describing what the programmer wants to accomplish, rather than how it is to be done. The implementation of actual algorithms explicitly is oftentimes bypassed in declarative languages. This is left up to the given language’s implementation. For the programmer, this means that he can focus his energy on specifying what solution is needed for a given problem, rather than focusing on how to implement said possible solutions. This translates to a straightforward, easier way of programming that quite appealing.

Reasons to Use Elm:

Throughout this five part series on Elm, we have related many of the winning qualities of this wonderful language. Elm builds upon more than four decades of work on typed functional reactive languages. Many of the features that make this language attractive, are free, easy, and built-in in Elm. Other languages require a stack of libraries to accomplish the same objectives. Elm includes a package manager. Elm has immutable values.

Elm implements control abstraction thoroughly. This means that it hides complicated code behind a simpler set of operations.

Sorting and reversing a list is handled for the programmer

Its compiler error detection is top-notch, giving descriptive error messages and useful suggestions and hints.

helpful hints

Testing and debugging are a breeze. All in all, Elm is a superb tool for creating websites and web apps. It emphasizes simplicity, ease of use, and superior tooling. Good luck and bon voyage!

References:

https://elm-lang.org/docs

https://elm-lang.org/blog/blazing-fast-html-round-two

https://github.com/evancz/react-angular-ember-elm-performance-comparisonh

https://en.wikipedia.org/wiki/Declarative_programming

--

--