Elm (programming language): Difference between revisions

Content deleted Content added
Dukese805 (talk | contribs)
m fix broken link
MiniBill (talk | contribs)
Elm is also available on Linux and Arm
Tags: Mobile edit Mobile web edit
 
(6 intermediate revisions by 6 users not shown)
Line 12:
| latest release date = {{Start date and age|2019|10|21}}<ref>{{Cite web |url=https://github.com/elm/compiler/releases |title=Releases: elm/Compiler |website=[[GitHub]]}}</ref>
| typing = [[Static typing|static]], [[Strong and weak typing|strong]], [[Type inference|inferred]]
| platform = [[x86-64]], [[AArch64|ARM]]
| operating system = [[macOS]], [[Microsoft Windows|Windows]], [[Linux]]
| license = [[Permissive license|Permissive]] ([[BSD license|Revised BSD]])<ref name=license>{{cite web |url=https://github.com/elm/compiler/blob/master/LICENSE |title=elm/compiler |website=GitHub|date=16 October 2021}}</ref>
| file ext = .elm
| website = {{Official URL}}
| influenced by = [[Haskell]], [[Standard ML]], [[OCaml]], [[F Sharp (programming language)|F#]]
| influenced = [[Redux (JavaScript library)|Redux]],<ref>{{cite web |url=https://redux.js.org/introduction/prior-art |title=Prior Art - Redux |website=redux.js.org|date=28 April 2024 }}</ref> [[Rust (programming language)|Rust]],<ref>{{Cite web |title=UniquenessShapes Typesof errors to come|url=https://blog.rust-lang.org/2016/08/10/Shape-of-errors-to-come.html |access-date=2016-10-08 |website= Rust Blog |quote=Those of you familiar with the Elm style may recognize that the updated --explain messages draw heavy inspiration from the Elm approach.}}</ref> [[Vue.js#Official libraries|Vue]],<ref>{{cite web |url=https://vuejs.org/v2/guide/comparison.html#Scale |title=Comparison with Other Frameworks — Vue.js}}</ref> Roc,<ref>{{Cite web |title=roc/roc-for-elm-programmers.md at main · roc-lang/roc |url=https://github.com/roc-lang/roc/blob/b8040bf6a224cc82a0d146a960c3f8dfca20d58b/roc-for-elm-programmers.md |access-date=2024-02-17 |website=[[GitHub]] |language=en |quote=Roc is a direct descendant of the Elm programming language. The two languages are similar, but not the same!}}</ref> Derw,<ref>{{cite web |title=Why Derw: an Elm-like language that compiles to TypeScript? |date= 20 December 2021|url= https://derw.substack.com/p/why-derw-an-elm-like-language-that}}</ref> Gren<ref>{{cite web |title=Gren 0.1.0 is released |url= https://gren-lang.org/news/220530_first_release/}}</ref>
}}
 
Line 24:
 
== History ==
Elm was initially designed by Evan Czaplicki as his thesis in 2012.<ref>{{cite web |url=https://elm-lang.org/assets/papers/concurrent-frp.pdf |title=Elm: Concurrent FRP for Functional GUIs}}</ref> The first release of Elm came with many examples and an online editor that made it easy to try out in a [[web browser]].<ref>{{cite web |url=https://elm-lang.org/try |title=Try Elm |website=elm-lang.org |access-date=20192025-0704-24|archive-url=https://web.archive.org/web/20170521144831/http://elm-lang.org/try|archive-date=2017-05-2126 |url-status=dead}}</ref> Czaplicki joined [[Prezi]] in 2013 to work on Elm,<ref>{{cite web |url=https://elm-lang.org/news/elm-and-prezi |title=elm and prezi |website=elm-lang.org}}</ref> and in 2016 moved to [[NoRedInk]] as an Open Source Engineer, also starting the Elm Software Foundation.<ref>{{cite web |url=https://elm-lang.org/news/new-adventures-for-elm |title=new adventures for elm |website=elm-lang.org}}</ref>
 
The initial implementation of the Elm compiler targets HyperText Markup Language ([[HTML]]), [[Cascading Style Sheets]] (CSS), and [[JavaScript]].<ref>{{cite web |url=https://github.com/elm/compiler |title=elm/compiler |website=GitHub|date=16 October 2021}}</ref> The set of core tools has continued to expand, now including a [[read–eval–print loop]] (REPL),<ref>{{cite web |url=https://elm-lang.org/news/repl |title=repl |website=elm-lang.org}}</ref> [[Package management system|package manager]],<ref>{{cite web |url=https://elm-lang.org/news/package-manager |title=package manager |website=elm-lang.org}}</ref> time-travelling debugger,<ref>{{cite web |url=https://elm-lang.org/news/time-travel-made-easy |title=Home |website=elm-lang.org}}</ref> and installers for [[macOS]] and [[Microsoft Windows|Windows]].<ref>{{cite web |url=https://guide.elm-lang.org/install.html |title=Install |website=guide.elm-lang.org}}</ref> Elm also has an ecosystem of community created [[Library (computing)|libraries]],<ref>{{Cite web |url=https://package.elm-lang.org/ |title=Elm packages |website=Elm-lang.org}}</ref> and Ellie, an advanced online editor that allows saved work and including community libraries.<ref>{{Cite web |url=https://ellie-app.com/ |title=Ellie |website=Ellie-app.com}}</ref>
 
== Features ==
Elm has a small set of language constructs, including traditional if-expressions, let-expressions for storing local values, and case-expressions for [[pattern matching]].<ref name="syntax">{{cite web |url=httphttps://elm-lang.org/learndocs/Syntax.elmsyntax |title=syntax |website=elm-lang.org |access-date=20132025-0504-31|archive-url=https://web.archive.org/web/20160313052210/http://elm-lang.org/learn/syntax.elm|archive-date=2016-03-1326 |url-status=dead}}</ref> As a functional language, it supports [[anonymous function]]s, functions as arguments, and functions can return functions, the latter often by partial application of [[currying|curried]] functions. Functions are called by value. Its semantics include immutable values, [[pure function|stateless functions]], and static typing with type inference. Elm programs render HTML through a virtual DOM, and may interoperate with other code by using "JavaScript as a service".
 
=== Immutability ===
Line 57:
Elm does not officially support server-side development. Czaplicki does consider it a primary goal at this point, but public progress on this front has been slow. Nevertheless, there are several independent projects which attempt to explore Elm on the backend.
 
The primary production-ready full-stack Elm platform is Lamdera, an open-core "unfork" of Elm.<ref>{{Cite AV media |url=https://www.youtube.com/watch?v=nSrucNcwlA8 |title=Mario Rogic - Elm as a Service |date=2019-11-28 |last=Elm Europe |access-date=2025-03-27 |via=YouTube}}</ref><ref>{{Cite AV media |url=https://www.youtube.com/watch?v=3Nn5meBieh4 |title=Building a Meetup clone on Lamdera - Martin Stewart |date=2021-07-23 |last=Elm Online Meetup |access-date=2025-03-27 |via=YouTube}}</ref><ref>{{Cite web |title=Episode 38: Lamdera |url=https://elm-radio.com/episode/lamdera/ |access-date=2025-03-27 |website=Elm Radio Podcast |language=en}}</ref> Czaplicki has also teased Elm Studio, a potential alternative to Lamdera, but it isn't available to the public yet.<ref>{{Cite web |title=Elm Studio |url=https://www.elm.studio/ |access-date=2025-03-27 |website=www.elm.studio}}</ref> Current speculation is that Elm Studio will use a future version of Elm that targets C, uses Emscripten to compile to WASM, and supports type-safe [[Postgres]] table generation.<ref>{{Cite web |date=2021-11-03 |title=Status Update - 3 Nov 2021 |url=https://discourse.elm-lang.org/t/status-update-3-nov-2021/7870/3 |access-date=2025-03-27 |website=Elm |language=en}}</ref> <ref>{{Cite web |last=Cesarini |first=Francesco |date=22 May 2023 |title=@evancz tempting the demo gods… |url=https://xcancel.com/FrancescoC/status/1660591792780111872 |access-date=26 March 2025 |website=[[Twitter]]}}</ref>
 
For full-stack frameworks, as opposed to [[Backend as a service|BaaS]] products, elm-pages is perhaps the most popular fully open-source option.<ref>{{Cite web |title=elm-pages - pull in typed elm data to your pages |url=https://elm-pages.com/ |access-date=2025-03-27 |website=elm-pages |language=en}}</ref> It does not extend the Elm language, but just runs the compiled JS on [[Node.js]]. It also supports scripting. There is also Pine, an Elm to .NET compiler, which allows safe interop with C#, F#, and other [[Common Language Runtime|CLR]] languages.<ref>{{Cite web |title=Pine — Run Elm Everywhere |url=https://pine-vm.org/ |access-date=2025-03-27 |website=pine-vm.org}}</ref>
 
There were also some attempts in Elm versions prior to 0.19.0 to use the [[BEAM (Erlang virtual machine)]] to run Elm, but they are stuck due to the removal of native code in 0.19.0 and changes to the package manager. One of the projects executed Elm directly on the environment,<ref>{{Cite web |url=https://github.com/hkgumbs/elm-beam |title=Kofigumbs/Elm-beam |website=[[GitHub]] |date=24 September 2021}}</ref>, while another one compiled it to Elixir.<ref>{{Cite web |url=https://github.com/wende/elchemy |title=What is it? |website=[[GitHub]] |date=24 September 2021}}</ref>
 
Finally, the Gren programming language started out a fork of Elm primarily focused on backend support, although its goals have since shifted.
Line 82:
Elm does not support [[Type class#Higher-kinded polymorphism|higher-kinded polymorphism]],<ref>{{cite web |title=Higher-Kinded types Not Expressible? #396 |url=https://github.com/elm-lang/elm-compiler/issues/396 |website=github.com/elm-lang/elm-compiler |access-date=6 March 2015}}</ref> which related languages [[Haskell]], [[Scala (programming language)|Scala]] and [[PureScript]] offer, nor does Elm support the creation of [[type class]]es.
 
This means that, for example, Elm does not have a generic <code>map</code> function which works across multiple data structures such as <code>List</code> and <code>Set</code>. In Elm, such functions are typically invoked qualified by their module name, for example calling <code>List.map</code> and <code>Set.map</code>. In Haskell or PureScript, there would be only one function <code>map</code>. This is a known feature request that is on Czaplicki's rough roadmap since at least 2015.<ref>{{cite web |title=Higher-Kinded types Not Expressible #396 |url=https://github.com/elm/compiler/issues/396#issuecomment-128190898 |website=github.com/elm-lang/elm-compiler |access-date=19 November 2019}}</ref> On the other hand, implementations of TEA pattern in advanced languages like [[Scala (programming language)|Scala]] does not suffer from such limitations and can benefit from [[Scala (programming language)|Scala]]'s type classes, [[Type-level programming|type-level]] and [[Kind (type theory)|kind-level]] programming constructs.<ref>{{Cite web |title=The Elm Architecture |url=https://tyrian.indigoengine.io/03-documentation/architecture/the-elm-architecture/.html |access-date=2024-09-07 |website=tyrian.indigoengine.io}}</ref>
 
Another outcome is a large amount of [[boilerplate code]] in medium to large size projects as illustrated by the author of "Elm in Action," a former Elm core team member, in his single page application example<ref>{{cite web |title=Main.elm |url=https://github.com/rtfeldman/elm-spa-example/blob/23dee34dd7a8c26229a03bc8e9f0e034f6222f13/src/Main.elm |website=github.com/rtfeldman/elm-spa-example |access-date=30 June 2020}}</ref> with almost identical fragments being repeated in update, view, subscriptions, route parsing and building functions.