First appeared 2012 | Designed by Evan Czaplicki | |
![]() | ||
Stable release 0.18 / November 14, 2016; 3 months ago (2016-11-14) License Permissive (Revised BSD) |
Elm is a domain-specific programming language for declaratively creating web browser-based graphical user interfaces. Elm is purely functional, and is developed with emphasis on usability, performance, and robustness. It advertises "no runtime exceptions in practice," made possible by the Elm compiler's static type checking.
Contents
History
Elm was initially designed by Evan Czaplicki as his thesis in 2012. The first release of Elm came with many examples and an online editor that made it easy to try out in a web browser. Evan Czaplicki joined Prezi in 2013 to work on Elm, and in 2016 moved to NoRedInk as an Open Source Engineer, also starting the Elm Software Foundation.
The initial implementation of the Elm compiler targets HTML, CSS, and JavaScript. The set of core tools has continued to expand, now including a REPL, package manager, time-traveling debugger, and installers for Mac and Windows. Elm also has an ecosystem of community created libraries.
Features
Elm has a small but expressive set of language constructs, including if-expressions, let-expressions, case-expressions, anonymous functions, and list interpolation. From there the key features include immutability, static types, and interoperability with HTML, CSS, and JavaScript.
Immutability
All values in Elm are immutable, meaning that a value cannot be modified after it is created. Elm uses persistent data structures to implement its Array
, Dict
, and Set
libraries.
Static types
Elm is statically typed. Every definition in Elm can be given a type annotation that describes the exact shape of the value. Types include:
Elm also supports full type inference, so the compiler can verify that a program is type-safe without any type annotations.
Module system
Elm has a module system that allows users to break their code into smaller parts called modules. Users can import and export values, making it possible to hide implementation details that other programmers do not need to think about. Modules form the basis of Elm's community library website, the Elm Public Library.
Interoperability with HTML, CSS, and JavaScript
Elm uses an abstraction called ports to communicate with JavaScript. It allows values to flow in and out of Elm programs, making it possible to communicate between Elm and JavaScript.
Elm has a library called elm-html that a programmer can use to write HTML and CSS within Elm. It uses a virtual DOM approach to make updates efficient.
Limitations
Unlike Haskell or PureScript, Elm has no support for higher-kinded types, and thus cannot provide generic abstractions for many common operations. For example, there is no generic map
, apply
, fold
, or filter
function. Instead, such names are used prefixed by their module, such as List.map
and Dict.map
.