Elixir (programming language)
Appearance
Text
Small
Standard
Large
Width
Standard
Wide
Color (beta)
Automatic
Light
Dark
From Wikipedia, the free encyclopedia
This article relies excessively on references (S'ouvre dans une nouvelle fenêtre) to primary sources (S'ouvre dans une nouvelle fenêtre). Please improve this article by adding secondary or tertiary sources (S'ouvre dans une nouvelle fenêtre).
Find sources: "Elixir" programming language (S'ouvre dans une nouvelle fenêtre) – news (S'ouvre dans une nouvelle fenêtre) · newspapers (S'ouvre dans une nouvelle fenêtre) · books (S'ouvre dans une nouvelle fenêtre) · scholar (S'ouvre dans une nouvelle fenêtre) · JSTOR (S'ouvre dans une nouvelle fenêtre) (June 2023) (Learn how and when to remove this message (S'ouvre dans une nouvelle fenêtre))
Elixir
(S'ouvre dans une nouvelle fenêtre)Elixir
Paradigms (S'ouvre dans une nouvelle fenêtre)multi-paradigm (S'ouvre dans une nouvelle fenêtre): functional (S'ouvre dans une nouvelle fenêtre), concurrent (S'ouvre dans une nouvelle fenêtre), distributed (S'ouvre dans une nouvelle fenêtre), process-oriented (S'ouvre dans une nouvelle fenêtre)Designed by (S'ouvre dans une nouvelle fenêtre)José ValimFirst appeared2012; 13 years agoStable release (S'ouvre dans une nouvelle fenêtre)
1.18.4[1] (S'ouvre dans une nouvelle fenêtre)
/ 21 May 2025; 4 days ago
Typing disciplinedynamic (S'ouvre dans une nouvelle fenêtre), strong (S'ouvre dans une nouvelle fenêtre)Platform (S'ouvre dans une nouvelle fenêtre)Erlang (S'ouvre dans une nouvelle fenêtre)License (S'ouvre dans une nouvelle fenêtre)Apache License 2.0 (S'ouvre dans une nouvelle fenêtre)[2] (S'ouvre dans une nouvelle fenêtre)Filename extensions (S'ouvre dans une nouvelle fenêtre).ex, .exsWebsiteelixir-lang.org (S'ouvre dans une nouvelle fenêtre)Influenced byClojure (S'ouvre dans une nouvelle fenêtre), Erlang (S'ouvre dans une nouvelle fenêtre), Ruby (S'ouvre dans une nouvelle fenêtre)InfluencedGleam (S'ouvre dans une nouvelle fenêtre), LFE (S'ouvre dans une nouvelle fenêtre)
Elixir is a functional (S'ouvre dans une nouvelle fenêtre), concurrent (S'ouvre dans une nouvelle fenêtre), high-level (S'ouvre dans une nouvelle fenêtre) general-purpose (S'ouvre dans une nouvelle fenêtre) programming language (S'ouvre dans une nouvelle fenêtre) that runs on the BEAM (S'ouvre dans une nouvelle fenêtre) virtual machine (S'ouvre dans une nouvelle fenêtre), which is also used to implement the Erlang (S'ouvre dans une nouvelle fenêtre) programming language.[3] (S'ouvre dans une nouvelle fenêtre) Elixir builds on top of Erlang and shares the same abstractions for building distributed (S'ouvre dans une nouvelle fenêtre), fault-tolerant (S'ouvre dans une nouvelle fenêtre) applications. Elixir also provides tooling and an extensible (S'ouvre dans une nouvelle fenêtre) design. The latter is supported by compile-time metaprogramming (S'ouvre dans une nouvelle fenêtre) with macros (S'ouvre dans une nouvelle fenêtre) and polymorphism (S'ouvre dans une nouvelle fenêtre) via protocols.[4] (S'ouvre dans une nouvelle fenêtre)
The community organizes yearly events in the United States,[5] (S'ouvre dans une nouvelle fenêtre) Europe,[6] (S'ouvre dans une nouvelle fenêtre) and Japan,[7] (S'ouvre dans une nouvelle fenêtre) as well as minor local events and conferences.[8] (S'ouvre dans une nouvelle fenêtre)[9] (S'ouvre dans une nouvelle fenêtre)
History
José Valim created the Elixir programming language as a research and development (S'ouvre dans une nouvelle fenêtre) project at Plataformatec. His goals were to enable higher extensibility and productivity in the Erlang VM while maintaining compatibility with Erlang's ecosystem.[10] (S'ouvre dans une nouvelle fenêtre)[11] (S'ouvre dans une nouvelle fenêtre)
Elixir is aimed at large-scale sites and apps. It uses features of Ruby (S'ouvre dans une nouvelle fenêtre), Erlang, and Clojure (S'ouvre dans une nouvelle fenêtre) to develop a high-concurrency and low-latency language. It was designed to handle large data volumes. Elixir is also used in telecommunications, e-commerce, and finance.[12] (S'ouvre dans une nouvelle fenêtre)
In 2021, the Numerical Elixir effort was announced with the goal of bringing machine learning, neural networks, GPU compilation, data processing, and computational notebooks to the Elixir ecosystem.[13] (S'ouvre dans une nouvelle fenêtre)
Versioning
Each of the minor versions supports a specific range of Erlang/OTP (S'ouvre dans une nouvelle fenêtre) versions.[14] (S'ouvre dans une nouvelle fenêtre) The current stable release version is 1.18.4[1] (S'ouvre dans une nouvelle fenêtre) .
Features
Compiles (S'ouvre dans une nouvelle fenêtre) to bytecode (S'ouvre dans une nouvelle fenêtre) for the BEAM virtual machine (S'ouvre dans une nouvelle fenêtre) of Erlang (S'ouvre dans une nouvelle fenêtre).[15] (S'ouvre dans une nouvelle fenêtre) Full interoperability with Erlang code, without runtime (S'ouvre dans une nouvelle fenêtre) impact.
Scalability and fault-tolerance, thanks to Erlang's lightweight concurrency mechanisms[15] (S'ouvre dans une nouvelle fenêtre)
Built-in tooling (S'ouvre dans une nouvelle fenêtre) for managing dependencies, code compilation, running tests, formatting code, remote debugging and more.
An interactive REPL (S'ouvre dans une nouvelle fenêtre) inside running programs, including Phoenix (S'ouvre dans une nouvelle fenêtre) web servers, with code reloading and access to internal state
Everything is an expression (S'ouvre dans une nouvelle fenêtre)[15] (S'ouvre dans une nouvelle fenêtre)
Pattern matching (S'ouvre dans une nouvelle fenêtre)[15] (S'ouvre dans une nouvelle fenêtre) to promote assertive code[16] (S'ouvre dans une nouvelle fenêtre)
Type hints for static analysis tools
Immutable data, with an emphasis, like other functional (S'ouvre dans une nouvelle fenêtre) languages, on recursion (S'ouvre dans une nouvelle fenêtre) and higher-order functions (S'ouvre dans une nouvelle fenêtre) instead of side-effect (S'ouvre dans une nouvelle fenêtre)-based looping (S'ouvre dans une nouvelle fenêtre)
Shared nothing concurrent programming (S'ouvre dans une nouvelle fenêtre) via message passing (actor model (S'ouvre dans une nouvelle fenêtre))[17] (S'ouvre dans une nouvelle fenêtre)
Lazy (S'ouvre dans une nouvelle fenêtre) and async collections (S'ouvre dans une nouvelle fenêtre) with streams
Railway oriented programming via the
withconstruct[18] (S'ouvre dans une nouvelle fenêtre)Hygienic metaprogramming (S'ouvre dans une nouvelle fenêtre) by direct access to the abstract syntax tree (S'ouvre dans une nouvelle fenêtre) (AST).[15] (S'ouvre dans une nouvelle fenêtre) Libraries often implement small domain-specific languages (S'ouvre dans une nouvelle fenêtre), such as for databases or testing.
Code execution at compile time. The Elixir compiler also runs on the BEAM, so modules that are being compiled can immediately run code which has already been compiled.
Polymorphism (S'ouvre dans une nouvelle fenêtre) via a mechanism called protocols. Dynamic dispatch (S'ouvre dans une nouvelle fenêtre), as in Clojure (S'ouvre dans une nouvelle fenêtre), however, without multiple dispatch (S'ouvre dans une nouvelle fenêtre) because Elixir protocols dispatch on a single type.
Support for documentation via Python-like docstrings in the Markdown (S'ouvre dans une nouvelle fenêtre) formatting language[15] (S'ouvre dans une nouvelle fenêtre)
Unicode (S'ouvre dans une nouvelle fenêtre) support and UTF-8 (S'ouvre dans une nouvelle fenêtre) strings
Examples
The following examples can be run in an iex shell (S'ouvre dans une nouvelle fenêtre) or saved in a file and run from the command line (S'ouvre dans une nouvelle fenêtre) by typing elixir <filename>.
Classic Hello world (S'ouvre dans une nouvelle fenêtre) example:
iex> IO.puts("Hello World!")
Hello World!
Pipe operator:
iex> "Elixir" |> String.graphemes() |> Enum.frequencies()
%{"E" => 1, "i" => 2, "l" => 1, "r" => 1, "x" => 1}
iex> %{values: 1..5} |> Map.get(:values) |> Enum.map(& &1 * 2)
[2, 4, 6, 8, 10]
iex> %{values: 1..5} |> Map.get(:values) |> Enum.map(& &1 * 2) |> Enum.sum()
30
Pattern matching (S'ouvre dans une nouvelle fenêtre) (a.k.a. destructuring):
iex> %{left: x} = %{left: 5, right: 8}
iex> x
5
iex> {:ok, [_ | rest]} = {:ok, [1, 2, 3]}
iex> rest
[2, 3]
Pattern matching with multiple clauses:
iex> case File.read("path/to/file") do
iex> {:ok, contents} -> IO.puts("found file: #{contents}")
iex> {:error, reason} -> IO.puts("missing file: #{reason}")
iex> end
List comprehension (S'ouvre dans une nouvelle fenêtre):
iex> for n <- 1..5, rem(n, 2) == 1, do: n*n
[1, 9, 25]
Asynchronously reading files with streams:
1..5
|> Task.async_stream(&File.read!("#{&1}.txt"))
|> Stream.filter(fn {:ok, contents} -> String.trim(contents) != "" end)
|> Enum.join("\n")
Multiple function bodies with guards (S'ouvre dans une nouvelle fenêtre):
def fib(n) when n in [0, 1], do: n
def fib(n), do: fib(n-2) + fib(n-1)
Relational databases with the Ecto library:
schema "weather" do
field :city # Defaults to type :string
field :temp_lo, :integer
field :temp_hi, :integer
field :prcp, :float, default: 0.0
end
Weather |> where(city: "Kraków") |> order_by(:temp_lo) |> limit(10) |> Repo.all
Sequentially spawning a thousand processes:
for num <- 1..1000, do: spawn fn -> IO.puts("#{num * 2}") end
Asynchronously (S'ouvre dans une nouvelle fenêtre) performing a task:
task = Task.async fn -> perform_complex_action() end
other_time_consuming_action()
Task.await task
[citation needed (S'ouvre dans une nouvelle fenêtre)]
See also
References
"Release 1.18.4" (S'ouvre dans une nouvelle fenêtre). 21 May 2025. Retrieved 25 May 2025.
"elixir/LICENSE at master · elixir-lang/elixir · GitHub" (S'ouvre dans une nouvelle fenêtre). GitHub.
"Most Popular Programming Languages of 2018 - Elite Infoworld Blog" (S'ouvre dans une nouvelle fenêtre). 2018-03-30. Archived from the original (S'ouvre dans une nouvelle fenêtre) on 2018-05-09. Retrieved 2018-05-08.
"Elixir" (S'ouvre dans une nouvelle fenêtre). José Valim. Retrieved 2013-02-17.
"ElixirConf" (S'ouvre dans une nouvelle fenêtre). Retrieved 2018-07-11.
"ElixirConf" (S'ouvre dans une nouvelle fenêtre). Retrieved 2018-07-11.
"Erlang & Elixir Fest" (S'ouvre dans une nouvelle fenêtre). Retrieved 2019-02-18.
"Elixir LDN" (S'ouvre dans une nouvelle fenêtre). Retrieved 2018-07-12.
"EMPEX - Empire State Elixir Conference" (S'ouvre dans une nouvelle fenêtre). Retrieved 2018-07-12.
Elixir - A modern approach to programming for the Erlang VM (S'ouvre dans une nouvelle fenêtre). Retrieved 2013-02-17.
José Valim - ElixirConf EU 2017 Keynote (S'ouvre dans une nouvelle fenêtre). Archived (S'ouvre dans une nouvelle fenêtre) from the original on 2021-11-17. Retrieved 2017-07-14.
"Behinde the code: The One Who Created Elixir" (S'ouvre dans une nouvelle fenêtre). Retrieved 2019-11-25.
"Numerical Elixir (Nx)" (S'ouvre dans une nouvelle fenêtre). GitHub (S'ouvre dans une nouvelle fenêtre). Retrieved 2024-05-06.
Elixir is a dynamic, functional language designed for building scalable and maintainable applications: elixir-lang/elixir (S'ouvre dans une nouvelle fenêtre), Elixir, 2019-04-21, retrieved 2019-04-21
"Elixir" (S'ouvre dans une nouvelle fenêtre). Retrieved 2014-09-07.
"Writing assertive code with Elixir" (S'ouvre dans une nouvelle fenêtre). 24 September 2014. Retrieved 2018-07-05.
Loder, Wolfgang (12 May 2015). Erlang and Elixir for Imperative Programmers (S'ouvre dans une nouvelle fenêtre). "Chapter 16: Code Structuring Concepts", section title "Actor Model": Leanpub. Retrieved 7 July 2015.
Wlaschin, Scott (May 2013). "Railway Oriented Programming" (S'ouvre dans une nouvelle fenêtre). F# for Fun and Profit. Archived (S'ouvre dans une nouvelle fenêtre) from the original on 30 January 2021. Retrieved 28 February 2021.
Further reading
Simon St. Laurent; J. Eisenberg (December 22, 2016). Introducing Elixir: Getting Started in Functional Programming 2nd Edition. O'Reilly Media (S'ouvre dans une nouvelle fenêtre). ISBN (S'ouvre dans une nouvelle fenêtre) 978-1491956779 (S'ouvre dans une nouvelle fenêtre).
Sasa Juric (January 12, 2019). Elixir in Action 2nd Edition. Manning Publications (S'ouvre dans une nouvelle fenêtre). ISBN (S'ouvre dans une nouvelle fenêtre) 978-1617295027 (S'ouvre dans une nouvelle fenêtre).
Programming languages (S'ouvre dans une nouvelle fenêtre)
Authority control databases (S'ouvre dans une nouvelle fenêtre): National
Categories (S'ouvre dans une nouvelle fenêtre):
Concurrent programming languages (S'ouvre dans une nouvelle fenêtre)
Pattern matching programming languages (S'ouvre dans une nouvelle fenêtre)
Programming languages created in 2012 (S'ouvre dans une nouvelle fenêtre)
Software using the Apache license (S'ouvre dans une nouvelle fenêtre)\
Elm (programming language)
Tools
Appearance
Text
Small
Standard
Large
Width
Standard
Wide
Color (beta)
Automatic
Light
Dark
From Wikipedia, the free encyclopedia
This article relies excessively on references (S'ouvre dans une nouvelle fenêtre) to primary sources (S'ouvre dans une nouvelle fenêtre). Please improve this article by adding secondary or tertiary sources (S'ouvre dans une nouvelle fenêtre).
Find sources: "Elm" programming language (S'ouvre dans une nouvelle fenêtre) – news (S'ouvre dans une nouvelle fenêtre) · newspapers (S'ouvre dans une nouvelle fenêtre) · books (S'ouvre dans une nouvelle fenêtre) · scholar (S'ouvre dans une nouvelle fenêtre) · JSTOR (S'ouvre dans une nouvelle fenêtre) (May 2019) (Learn how and when to remove this message (S'ouvre dans une nouvelle fenêtre))
Elm
The Elm tangram
Paradigm (S'ouvre dans une nouvelle fenêtre)functional (S'ouvre dans une nouvelle fenêtre)FamilyHaskell (S'ouvre dans une nouvelle fenêtre)Designed by (S'ouvre dans une nouvelle fenêtre)Evan CzaplickiFirst appearedMarch 30, 2012; 13 years ago[1] (S'ouvre dans une nouvelle fenêtre)Stable release (S'ouvre dans une nouvelle fenêtre)
0.19.1 / October 21, 2019; 5 years ago[2] (S'ouvre dans une nouvelle fenêtre)
Typing discipline (S'ouvre dans une nouvelle fenêtre)static (S'ouvre dans une nouvelle fenêtre), strong (S'ouvre dans une nouvelle fenêtre), inferred (S'ouvre dans une nouvelle fenêtre)Platform (S'ouvre dans une nouvelle fenêtre)x86-64 (S'ouvre dans une nouvelle fenêtre)OS (S'ouvre dans une nouvelle fenêtre)macOS (S'ouvre dans une nouvelle fenêtre), Windows (S'ouvre dans une nouvelle fenêtre)License (S'ouvre dans une nouvelle fenêtre)Permissive (S'ouvre dans une nouvelle fenêtre) (Revised BSD (S'ouvre dans une nouvelle fenêtre))[3] (S'ouvre dans une nouvelle fenêtre)Filename extensions (S'ouvre dans une nouvelle fenêtre).elmWebsiteelm-lang.org (S'ouvre dans une nouvelle fenêtre)
Influenced byHaskell (S'ouvre dans une nouvelle fenêtre), Standard ML (S'ouvre dans une nouvelle fenêtre), OCaml (S'ouvre dans une nouvelle fenêtre), F# (S'ouvre dans une nouvelle fenêtre)InfluencedRedux (S'ouvre dans une nouvelle fenêtre),[4] (S'ouvre dans une nouvelle fenêtre) Rust (S'ouvre dans une nouvelle fenêtre),[5] (S'ouvre dans une nouvelle fenêtre) Vue (S'ouvre dans une nouvelle fenêtre),[6] (S'ouvre dans une nouvelle fenêtre) Roc,[7] (S'ouvre dans une nouvelle fenêtre) Derw,[8] (S'ouvre dans une nouvelle fenêtre) Gren[9] (S'ouvre dans une nouvelle fenêtre)
Elm is a domain-specific (S'ouvre dans une nouvelle fenêtre) programming language (S'ouvre dans une nouvelle fenêtre) for declaratively (S'ouvre dans une nouvelle fenêtre) creating web browser (S'ouvre dans une nouvelle fenêtre)-based graphical user interfaces (S'ouvre dans une nouvelle fenêtre). Elm is purely functional (S'ouvre dans une nouvelle fenêtre), and is developed with emphasis on usability (S'ouvre dans une nouvelle fenêtre), performance, and robustness (S'ouvre dans une nouvelle fenêtre). It advertises "no runtime (S'ouvre dans une nouvelle fenêtre) exceptions (S'ouvre dans une nouvelle fenêtre) in practice",[10] (S'ouvre dans une nouvelle fenêtre) made possible by the Elm compiler's static type checking (S'ouvre dans une nouvelle fenêtre).
History
Elm was initially designed by Evan Czaplicki as his thesis in 2012.[11] (S'ouvre dans une nouvelle fenêtre) The first release of Elm came with many examples and an online editor that made it easy to try out in a web browser (S'ouvre dans une nouvelle fenêtre).[12] (S'ouvre dans une nouvelle fenêtre) Czaplicki joined Prezi (S'ouvre dans une nouvelle fenêtre) in 2013 to work on Elm,[13] (S'ouvre dans une nouvelle fenêtre) and in 2016 moved to NoRedInk (S'ouvre dans une nouvelle fenêtre) as an Open Source Engineer, also starting the Elm Software Foundation.[14] (S'ouvre dans une nouvelle fenêtre)
The initial implementation of the Elm compiler targets HyperText Markup Language (HTML (S'ouvre dans une nouvelle fenêtre)), Cascading Style Sheets (S'ouvre dans une nouvelle fenêtre) (CSS), and JavaScript (S'ouvre dans une nouvelle fenêtre).[15] (S'ouvre dans une nouvelle fenêtre) The set of core tools has continued to expand, now including a read–eval–print loop (S'ouvre dans une nouvelle fenêtre) (REPL),[16] (S'ouvre dans une nouvelle fenêtre) package manager (S'ouvre dans une nouvelle fenêtre),[17] (S'ouvre dans une nouvelle fenêtre) time-travelling debugger,[18] (S'ouvre dans une nouvelle fenêtre) and installers for macOS (S'ouvre dans une nouvelle fenêtre) and Windows (S'ouvre dans une nouvelle fenêtre).[19] (S'ouvre dans une nouvelle fenêtre) Elm also has an ecosystem of community created libraries (S'ouvre dans une nouvelle fenêtre),[20] (S'ouvre dans une nouvelle fenêtre) and Ellie, an advanced online editor that allows saved work and including community libraries.[21] (S'ouvre dans une nouvelle fenêtre)
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 (S'ouvre dans une nouvelle fenêtre).[22] (S'ouvre dans une nouvelle fenêtre) As a functional language, it supports anonymous functions (S'ouvre dans une nouvelle fenêtre), functions as arguments, and functions can return functions, the latter often by partial application of curried (S'ouvre dans une nouvelle fenêtre) functions. Functions are called by value. Its semantics include immutable values, stateless functions (S'ouvre dans une nouvelle fenêtre), 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
All values in Elm are immutable (S'ouvre dans une nouvelle fenêtre), meaning that a value cannot be modified after it is created. Elm uses persistent data structures (S'ouvre dans une nouvelle fenêtre) to implement its arrays, sets, and dictionaries in the standard library.[23] (S'ouvre dans une nouvelle fenêtre)
Static types
Elm is statically typed. Type annotations are optional (due to type inference) but strongly encouraged. Annotations exist on the line above the definition (unlike C-family languages where types and names are interspersed). Elm uses a single colon to mean "has type".
Types include primitives like integers and strings, and basic data structures such as lists, tuples, and records. Functions have types written with arrows, for example round : Float -> Int. Custom types (S'ouvre dans une nouvelle fenêtre) allow the programmer to create custom types to represent data in a way that matches the problem domain.[24] (S'ouvre dans une nouvelle fenêtre)
Types can refer to other types, for example a List Int. Types are always capitalized; lowercase names are type variables. For example, a List a is a list of values of unknown type. It is the type of the empty list and of the argument to List.length, which is agnostic to the list's elements. There are a few special types that programmers create to interact with the Elm runtime. For example, Html Msg represents a (virtual) DOM tree whose event handlers all produce messages of type Msg.
Rather than allow any value to be implicitly nullable (such as JavaScript's undefined or a null pointer (S'ouvre dans une nouvelle fenêtre)), Elm's standard library defines a Maybe a type. Code that produces or handles an optional value does so explicitly using this type, and all other code is guaranteed a value of the claimed type is actually present.
Elm provides a limited number of built-in type classes (S'ouvre dans une nouvelle fenêtre): number which includes Int and Float to facilitate the use of numeric operators such as (+) or (*), comparable which includes numbers, characters, strings, lists of comparable things, and tuples of comparable things to facilitate the use of comparison operators, and appendable which includes strings and lists to facilitate concatenation with (++). Elm does not provide a mechanism to include custom types into these type classes or create new type classes (see Limits (S'ouvre dans une nouvelle fenêtre)).
Module system
Elm has a module system (S'ouvre dans une nouvelle fenêtre) that allows users to break their code into smaller parts called modules. Modules can hide implementation details such as helper functions, and group related code together. Modules serve as a namespace for imported code, such as Bitwise.and. Third party libraries (or packages) consist of one or more modules, and are available from the Elm Public Library (S'ouvre dans une nouvelle fenêtre). All libraries are versioned according to semver (S'ouvre dans une nouvelle fenêtre), which is enforced by the compiler and other tools. That is, removing a function or changing its type can only be done in a major release.
Interoperability with HTML, CSS, and JavaScript
Elm uses an abstraction called ports to communicate with JavaScript (S'ouvre dans une nouvelle fenêtre).[25] (S'ouvre dans une nouvelle fenêtre) 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.[26] (S'ouvre dans une nouvelle fenêtre) It uses a virtual DOM (S'ouvre dans une nouvelle fenêtre) approach to make updates efficient.[27] (S'ouvre dans une nouvelle fenêtre)
Backend
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.[28] (S'ouvre dans une nouvelle fenêtre)[29] (S'ouvre dans une nouvelle fenêtre)[30] (S'ouvre dans une nouvelle fenêtre) Czaplicki has also teased Elm Studio, a potential alternative to Lamdera, but it isn't available to the public yet.[31] (S'ouvre dans une nouvelle fenêtre) 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 (S'ouvre dans une nouvelle fenêtre) table generation.[32] (S'ouvre dans une nouvelle fenêtre)[33] (S'ouvre dans une nouvelle fenêtre)
For full-stack frameworks, as opposed to BaaS (S'ouvre dans une nouvelle fenêtre) products, elm-pages is perhaps the most popular fully open-source option.[34] (S'ouvre dans une nouvelle fenêtre) It does not extend the Elm language, but just runs the compiled JS on Node.js (S'ouvre dans une nouvelle fenêtre). It also supports scripting. There is also Pine, an Elm to .NET compiler, which allows safe interop with C#, F#, and other CLR (S'ouvre dans une nouvelle fenêtre) languages.[35] (S'ouvre dans une nouvelle fenêtre)
There were also some attempts in Elm versions prior to 0.19.0 to use the BEAM (Erlang virtual machine) (S'ouvre dans une nouvelle fenêtre) 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,[36] (S'ouvre dans une nouvelle fenêtre) while another one compiled it to Elixir.[37] (S'ouvre dans une nouvelle fenêtre)
Finally, the Gren programming language started out a fork of Elm primarily focused on backend support, although its goals have since shifted.
The Elm Architecture (TEA pattern)
The Elm Architecture is a software design pattern (S'ouvre dans une nouvelle fenêtre) and as a TLA (S'ouvre dans une nouvelle fenêtre) called TEA pattern for building interactive web applications. Elm applications are naturally constructed in that way, but other projects may find the concept useful.
An Elm program is always split into three parts:
Model - the state of the application
View - a function that turns the model into HTML
Update - a function that updates the model based on messages
Those are the core of the Elm Architecture.
For example, imagine an application that displays a number and a button that increments the number when pressed.[38] (S'ouvre dans une nouvelle fenêtre) In this case, all we need to store is one number, so our model can be as simple as type alias Model = Int. The view function would be defined with the Html library and display the number and button. For the number to be updated, we need to be able to send a message to the update function, which is done through a custom type such as type Msg = Increase. The Increase value is attached to the button defined in the view function such that when the button is clicked by a user, Increase is passed on to the update function, which can update the model by increasing the number.
In the Elm Architecture, sending messages to update is the only way to change the state. In more sophisticated applications, messages may come from various sources: user interaction, initialization of the model, internal calls from update, subscriptions to external events (window resize, system clock, JavaScript interop...) and URL changes and requests.
Limits
Elm does not support higher-kinded polymorphism (S'ouvre dans une nouvelle fenêtre),[39] (S'ouvre dans une nouvelle fenêtre) which related languages Haskell (S'ouvre dans une nouvelle fenêtre), Scala (S'ouvre dans une nouvelle fenêtre) and PureScript (S'ouvre dans une nouvelle fenêtre) offer, nor does Elm support the creation of type classes (S'ouvre dans une nouvelle fenêtre).
This means that, for example, Elm does not have a generic map function which works across multiple data structures such as List and Set. In Elm, such functions are typically invoked qualified by their module name, for example calling List.map and Set.map. In Haskell or PureScript, there would be only one function map. This is a known feature request that is on Czaplicki's rough roadmap since at least 2015.[40] (S'ouvre dans une nouvelle fenêtre) On the other hand, implementations of TEA pattern in advanced languages like Scala (S'ouvre dans une nouvelle fenêtre) does not suffer from such limitations and can benefit from Scala (S'ouvre dans une nouvelle fenêtre)'s type classes, type-level (S'ouvre dans une nouvelle fenêtre) and kind-level (S'ouvre dans une nouvelle fenêtre) programming constructs.[41] (S'ouvre dans une nouvelle fenêtre)
Another outcome is a large amount of boilerplate code (S'ouvre dans une nouvelle fenêtre) 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[42] (S'ouvre dans une nouvelle fenêtre) with almost identical fragments being repeated in update, view, subscriptions, route parsing and building functions.
Example code
-- This is a single line comment.
{-
This is a multi-line comment.
It is {- nestable. -}
-}
-- Here we define a value named `greeting`. The type is inferred as a `String`.
greeting =
"Hello World!"
-- It is best to add type annotations to top-level declarations.
hello : String
hello =
"Hi there."
-- Functions are declared the same way, with arguments following the function name.
add x y =
x + y
-- Again, it is best to add type annotations.
hypotenuse : Float -> Float -> Float
hypotenuse a b =
sqrt (a^2 + b^2)
-- We can create lambda functions with the `\[arg] -> [expression]` syntax.
hello : String -> String
hello = \s -> "Hi, " ++ s
-- Function declarations may have the anonymous parameter names denoted by `_`,
-- which are matched but not used in the body.
const : a -> b -> a
const k _ = k
-- Functions are also curried; here we've curried the multiplication
-- infix operator with a `2`
multiplyBy2 : number -> number
multiplyBy2 =
(*) 2
-- If-expressions are used to branch on `Bool` values
absoluteValue : number -> number
absoluteValue number =
if number < 0 then negate number else number
-- Records are used to hold values with named fields
book : { title : String, author : String, pages : Int }
book =
{ title = "Steppenwolf"
, author = "Hesse"
, pages = 237
}
-- Record access is done with `.`
title : String
title =
book.title
-- Record access `.` can also be used as a function
author : String
author =
.author book
-- We can create tagged unions with the `type` keyword.
-- The following value represents a binary tree.
type Tree a
= Empty
| Node a (Tree a) (Tree a)
-- It is possible to inspect these types with case-expressions.
depth : Tree a -> Int
depth tree =
case tree of
Empty -> 0
Node _ left right ->
1 + max (depth left) (depth right)
See also
PureScript (S'ouvre dans une nouvelle fenêtre) – A strongly-typed, purely-functional programming language that compiles to JavaScript
Reason (S'ouvre dans une nouvelle fenêtre) – A syntax extension and toolchain for OCaml that can also transpile to JavaScript
References
Czaplicki, Evan (30 March 2012). "My Thesis is Finally Complete! "Elm: Concurrent FRP for functional GUIs"" (S'ouvre dans une nouvelle fenêtre). Reddit (S'ouvre dans une nouvelle fenêtre).
"Releases: elm/Compiler" (S'ouvre dans une nouvelle fenêtre). GitHub (S'ouvre dans une nouvelle fenêtre).
"elm/compiler" (S'ouvre dans une nouvelle fenêtre). GitHub. 16 October 2021.
"Prior Art - Redux" (S'ouvre dans une nouvelle fenêtre). redux.js.org. 28 April 2024.
"Uniqueness Types" (S'ouvre dans une nouvelle fenêtre). Rust Blog. Retrieved 2016-10-08. Those of you familiar with the Elm style may recognize that the updated --explain messages draw heavy inspiration from the Elm approach.
"Comparison with Other Frameworks — Vue.js" (S'ouvre dans une nouvelle fenêtre).
"roc/roc-for-elm-programmers.md at main · roc-lang/roc" (S'ouvre dans une nouvelle fenêtre). GitHub (S'ouvre dans une nouvelle fenêtre). Retrieved 2024-02-17. Roc is a direct descendant of the Elm programming language. The two languages are similar, but not the same!
"Why Derw: an Elm-like language that compiles to TypeScript?" (S'ouvre dans une nouvelle fenêtre). 20 December 2021.
"Gren 0.1.0 is released" (S'ouvre dans une nouvelle fenêtre).
"Elm: Concurrent FRP for Functional GUIs" (S'ouvre dans une nouvelle fenêtre) (PDF).
"Try Elm" (S'ouvre dans une nouvelle fenêtre). elm-lang.org. Retrieved 2025-04-26.
"elm and prezi" (S'ouvre dans une nouvelle fenêtre). elm-lang.org.
"new adventures for elm" (S'ouvre dans une nouvelle fenêtre). elm-lang.org.
"elm/compiler" (S'ouvre dans une nouvelle fenêtre). GitHub. 16 October 2021.
"repl" (S'ouvre dans une nouvelle fenêtre). elm-lang.org.
"package manager" (S'ouvre dans une nouvelle fenêtre). elm-lang.org.
"Home" (S'ouvre dans une nouvelle fenêtre). elm-lang.org.
"Install" (S'ouvre dans une nouvelle fenêtre). guide.elm-lang.org.
"Elm packages" (S'ouvre dans une nouvelle fenêtre). Elm-lang.org.
"Ellie" (S'ouvre dans une nouvelle fenêtre). Ellie-app.com.
"syntax" (S'ouvre dans une nouvelle fenêtre). elm-lang.org. Retrieved 2025-04-26.
"elm/core" (S'ouvre dans une nouvelle fenêtre). package.elm-lang.org.
"Model The Problem" (S'ouvre dans une nouvelle fenêtre). Elm. Retrieved 4 May 2016.
"JavaScript interop" (S'ouvre dans une nouvelle fenêtre). elm-lang.org.
"elm/html" (S'ouvre dans une nouvelle fenêtre). package.elm-lang.org.
"Blazing Fast HTML" (S'ouvre dans une nouvelle fenêtre). elm-lang.org.
Elm Europe (2019-11-28). Mario Rogic - Elm as a Service (S'ouvre dans une nouvelle fenêtre). Retrieved 2025-03-27 – via YouTube.
Elm Online Meetup (2021-07-23). Building a Meetup clone on Lamdera - Martin Stewart (S'ouvre dans une nouvelle fenêtre). Retrieved 2025-03-27 – via YouTube.
"Episode 38: Lamdera" (S'ouvre dans une nouvelle fenêtre). Elm Radio Podcast. Retrieved 2025-03-27.
"Elm Studio" (S'ouvre dans une nouvelle fenêtre). www.elm.studio. Retrieved 2025-03-27.
"Status Update - 3 Nov 2021" (S'ouvre dans une nouvelle fenêtre). Elm. 2021-11-03. Retrieved 2025-03-27.
Cesarini, Francesco (22 May 2023). "@evancz tempting the demo gods…" (S'ouvre dans une nouvelle fenêtre). Twitter (S'ouvre dans une nouvelle fenêtre). Retrieved 26 March 2025.
"elm-pages - pull in typed elm data to your pages" (S'ouvre dans une nouvelle fenêtre). elm-pages. Retrieved 2025-03-27.
"Pine — Run Elm Everywhere" (S'ouvre dans une nouvelle fenêtre). pine-vm.org. Retrieved 2025-03-27.
"Kofigumbs/Elm-beam" (S'ouvre dans une nouvelle fenêtre). GitHub (S'ouvre dans une nouvelle fenêtre). 24 September 2021.
"What is it?" (S'ouvre dans une nouvelle fenêtre). GitHub (S'ouvre dans une nouvelle fenêtre). 24 September 2021.
"Buttons · An Introduction to Elm" (S'ouvre dans une nouvelle fenêtre). guide.elm-lang.org. Retrieved 2020-10-15.
"Higher-Kinded types Not Expressible? #396" (S'ouvre dans une nouvelle fenêtre). github.com/elm-lang/elm-compiler. Retrieved 6 March 2015.
"Higher-Kinded types Not Expressible #396" (S'ouvre dans une nouvelle fenêtre). github.com/elm-lang/elm-compiler. Retrieved 19 November 2019.
"The Elm Architecture" (S'ouvre dans une nouvelle fenêtre). tyrian.indigoengine.io. Retrieved 2024-09-07.
"Main.elm" (S'ouvre dans une nouvelle fenêtre). github.com/rtfeldman/elm-spa-example. Retrieved 30 June 2020.
External links
Haskell (S'ouvre dans une nouvelle fenêtre) programming
Programming languages (S'ouvre dans une nouvelle fenêtre)
Categories (S'ouvre dans une nouvelle fenêtre):
Domain-specific programming languages (S'ouvre dans une nouvelle fenêtre)
Haskell programming language family (S'ouvre dans une nouvelle fenêtre)
Pattern matching programming languages (S'ouvre dans une nouvelle fenêtre)
Programming languages created in 2012 (S'ouvre dans une nouvelle fenêtre)
Source-to-source compilers (S'ouvre dans une nouvelle fenêtre)
Statically typed programming languages (S'ouvre dans une nouvelle fenêtre)
Free and open-source software (S'ouvre dans une nouvelle fenêtre)
Software using the MIT license (S'ouvre dans une nouvelle fenêtre)
Gleam (programming language)
Tools
Text
Small
Standard
Large
Width
Standard
Wide
Color (beta)
Automatic
Light
Dark
From Wikipedia, the free encyclopedia
The topic of this article may not meet Wikipedia's general notability guideline (S'ouvre dans une nouvelle fenêtre). Please help to demonstrate the notability of the topic by citing reliable secondary sources (S'ouvre dans une nouvelle fenêtre) that are independent (S'ouvre dans une nouvelle fenêtre) of the topic and provide significant coverage of it beyond a mere trivial mention. If notability cannot be shown, the article is likely to be merged (S'ouvre dans une nouvelle fenêtre), redirected (S'ouvre dans une nouvelle fenêtre), or deleted (S'ouvre dans une nouvelle fenêtre).
Find sources: "Gleam" programming language (S'ouvre dans une nouvelle fenêtre) – news (S'ouvre dans une nouvelle fenêtre) · newspapers (S'ouvre dans une nouvelle fenêtre) · books (S'ouvre dans une nouvelle fenêtre) · scholar (S'ouvre dans une nouvelle fenêtre) · JSTOR (S'ouvre dans une nouvelle fenêtre) (March 2024) (Learn how and when to remove this message (S'ouvre dans une nouvelle fenêtre))
Gleam
Lucy, the starfish mascot for Gleam[1] (S'ouvre dans une nouvelle fenêtre)
Paradigm (S'ouvre dans une nouvelle fenêtre)Multi-paradigm (S'ouvre dans une nouvelle fenêtre): functional (S'ouvre dans une nouvelle fenêtre), concurrent (S'ouvre dans une nouvelle fenêtre)[2] (S'ouvre dans une nouvelle fenêtre)Designed by (S'ouvre dans une nouvelle fenêtre)Louis PilfoldDeveloper (S'ouvre dans une nouvelle fenêtre)Louis PilfoldFirst appearedJune 13, 2016; 8 years agoStable release (S'ouvre dans une nouvelle fenêtre)
1.10.0[3] (S'ouvre dans une nouvelle fenêtre)
/ 14 April 2025
Typing discipline (S'ouvre dans une nouvelle fenêtre)Type-safe (S'ouvre dans une nouvelle fenêtre), static (S'ouvre dans une nouvelle fenêtre), inferred (S'ouvre dans une nouvelle fenêtre)[2] (S'ouvre dans une nouvelle fenêtre)Memory management (S'ouvre dans une nouvelle fenêtre)Garbage collected (S'ouvre dans une nouvelle fenêtre)Implementation languageRust (S'ouvre dans une nouvelle fenêtre)OS (S'ouvre dans une nouvelle fenêtre)FreeBSD (S'ouvre dans une nouvelle fenêtre), Linux (S'ouvre dans une nouvelle fenêtre), macOS (S'ouvre dans une nouvelle fenêtre), OpenBSD (S'ouvre dans une nouvelle fenêtre), Windows (S'ouvre dans une nouvelle fenêtre)[4] (S'ouvre dans une nouvelle fenêtre)License (S'ouvre dans une nouvelle fenêtre)Apache License 2.0 (S'ouvre dans une nouvelle fenêtre)[5] (S'ouvre dans une nouvelle fenêtre)Filename extensions (S'ouvre dans une nouvelle fenêtre).gleamWebsitegleam.run (S'ouvre dans une nouvelle fenêtre)Influenced by
Alpaca
[6] (S'ouvre dans une nouvelle fenêtre)
Gleam is a general-purpose (S'ouvre dans une nouvelle fenêtre), concurrent (S'ouvre dans une nouvelle fenêtre), functional (S'ouvre dans une nouvelle fenêtre) high-level (S'ouvre dans une nouvelle fenêtre) programming language (S'ouvre dans une nouvelle fenêtre) that compiles to Erlang (S'ouvre dans une nouvelle fenêtre) or JavaScript (S'ouvre dans une nouvelle fenêtre) source code.[2] (S'ouvre dans une nouvelle fenêtre)[7] (S'ouvre dans une nouvelle fenêtre)[8] (S'ouvre dans une nouvelle fenêtre)
Gleam is a statically-typed language,[9] (S'ouvre dans une nouvelle fenêtre) which is different from the most popular languages that run on Erlang’s virtual machine BEAM (S'ouvre dans une nouvelle fenêtre), Erlang (S'ouvre dans une nouvelle fenêtre) and Elixir (S'ouvre dans une nouvelle fenêtre). Gleam has its own type-safe implementation of OTP, Erlang's actor framework.[10] (S'ouvre dans une nouvelle fenêtre) Packages are provided using the Hex package manager, and an index for finding packages written for Gleam is available.[11] (S'ouvre dans une nouvelle fenêtre)
History
The first numbered version of Gleam was released on April 15, 2019.[12] (S'ouvre dans une nouvelle fenêtre) Compiling to JavaScript was introduced with version v0.16.[13] (S'ouvre dans une nouvelle fenêtre)
In 2023 the Erlang Ecosystem Foundation funded the creation of a course for learning Gleam on the learning platform Exercism (S'ouvre dans une nouvelle fenêtre).[14] (S'ouvre dans une nouvelle fenêtre)
Version v1.0.0 was released on March 4, 2024.[15] (S'ouvre dans une nouvelle fenêtre)
Features
Gleam includes the following features, many common to other functional programming languages:[8] (S'ouvre dans une nouvelle fenêtre)
Result type (S'ouvre dans une nouvelle fenêtre) for error handling
No implicit type conversions (S'ouvre dans une nouvelle fenêtre)
Example
A "Hello, World!" (S'ouvre dans une nouvelle fenêtre) example:
import gleam/io
pub fn main() {
io.println("hello, world!")
}Gleam supports tail call (S'ouvre dans une nouvelle fenêtre) optimization:[16] (S'ouvre dans une nouvelle fenêtre)
pub fn factorial(x: Int) -> Int {
// The public function calls the private tail recursive function
factorial_loop(x, 1)
}
fn factorial_loop(x: Int, accumulator: Int) -> Int {
case x {
1 -> accumulator
// The last thing this function does is call itself
_ -> factorial_loop(x - 1, accumulator * x)
}
}Implementation
Gleam's toolchain is implemented in the Rust programming language (S'ouvre dans une nouvelle fenêtre).[17] (S'ouvre dans une nouvelle fenêtre) The toolchain is a single native binary executable which contains the compiler, build tool, package manager, source code formatter, and language server (S'ouvre dans une nouvelle fenêtre). A WebAssembly (S'ouvre dans une nouvelle fenêtre) binary containing the Gleam compiler is also available, enabling Gleam code to be compiled within a web browser.
References
"gleam-lang/gleam Issues – New logo and mascot #2551" (S'ouvre dans une nouvelle fenêtre). GitHub (S'ouvre dans une nouvelle fenêtre).
"Release 1.10.0" (S'ouvre dans une nouvelle fenêtre). April 14, 2025. Retrieved April 15, 2025.
"Installing Gleam" (S'ouvre dans une nouvelle fenêtre). 2024.
"Gleam License File" (S'ouvre dans une nouvelle fenêtre). GitHub (S'ouvre dans une nouvelle fenêtre). December 5, 2021.
Pilfold, Louis (February 7, 2024). "Gleam: Past, Present, Future!" (S'ouvre dans une nouvelle fenêtre). Fosdem 2024 – via YouTube.
Krill, Paul (March 5, 2024). "Gleam language available in first stable release" (S'ouvre dans une nouvelle fenêtre). InfoWorld. Retrieved March 26, 2024.
Eastman, David (June 22, 2024). "Introduction to Gleam, a New Functional Programming Language" (S'ouvre dans une nouvelle fenêtre). The New Stack. Retrieved July 29, 2024.
De Simone, Sergio (March 16, 2024). "Erlang-Runtime Statically-Typed Functional Language Gleam Reaches 1.0" (S'ouvre dans une nouvelle fenêtre). InfoQ. Retrieved March 26, 2024.
Getting to know Actors in Gleam – Raúl Chouza (S'ouvre dans une nouvelle fenêtre). Code BEAM America. March 27, 2024. Retrieved May 6, 2024 – via YouTube.
"Introducing the Gleam package index – Gleam" (S'ouvre dans une nouvelle fenêtre). gleam.run (S'ouvre dans une nouvelle fenêtre). Retrieved May 7, 2024.
"Hello, Gleam! – Gleam" (S'ouvre dans une nouvelle fenêtre). gleam.run (S'ouvre dans une nouvelle fenêtre). Retrieved May 6, 2024.
"v0.16 – Gleam compiles to JavaScript! – Gleam" (S'ouvre dans une nouvelle fenêtre). gleam.run (S'ouvre dans une nouvelle fenêtre). Retrieved May 7, 2024.
Alistair, Woodman (December 2023). "Erlang Ecosystem Foundation Annual General Meeting 2023 Chair's Report" (S'ouvre dans une nouvelle fenêtre).
"Gleam version 1 – Gleam" (S'ouvre dans une nouvelle fenêtre). gleam.run (S'ouvre dans une nouvelle fenêtre). Retrieved May 7, 2024.
"Tail Calls" (S'ouvre dans une nouvelle fenêtre). The Gleam Language Tour. Retrieved March 26, 2024.
"gleam-lang/gleam" (S'ouvre dans une nouvelle fenêtre). Gleam. May 6, 2024. Retrieved May 6, 2024.
External links
This programming-language (S'ouvre dans une nouvelle fenêtre)-related article is a stub (S'ouvre dans une nouvelle fenêtre). You can help Wikipedia by expanding it (S'ouvre dans une nouvelle fenêtre).
Categories (S'ouvre dans une nouvelle fenêtre):
Erlang (programming language) (S'ouvre dans une nouvelle fenêtre)
Concurrent programming languages (S'ouvre dans une nouvelle fenêtre)
Free and open source compilers (S'ouvre dans une nouvelle fenêtre)
High-level programming languages (S'ouvre dans une nouvelle fenêtre)
Multi-paradigm programming languages (S'ouvre dans une nouvelle fenêtre)
Pattern matching programming languages (S'ouvre dans une nouvelle fenêtre)
Programming languages created in 2016 (S'ouvre dans une nouvelle fenêtre)
Software using the Apache license (S'ouvre dans une nouvelle fenêtre)
Statically typed programming languages (S'ouvre dans une nouvelle fenêtre)
Programming language topic stubs (S'ouvre dans une nouvelle fenêtre)
Erlang (programming language)
Tools
Text
Small
Standard
Large
Width
Standard
Wide
Color (beta)
Automatic
Light
Dark
From Wikipedia, the free encyclopedia
Erlang
Paradigms (S'ouvre dans une nouvelle fenêtre)Multi-paradigm (S'ouvre dans une nouvelle fenêtre): concurrent (S'ouvre dans une nouvelle fenêtre), functional (S'ouvre dans une nouvelle fenêtre)Designed by (S'ouvre dans une nouvelle fenêtre)
Robert Virding
Mike Williams
Developer (S'ouvre dans une nouvelle fenêtre)Ericsson (S'ouvre dans une nouvelle fenêtre)First appeared1986; 39 years agoStable release (S'ouvre dans une nouvelle fenêtre)
27.3.4[1] (S'ouvre dans une nouvelle fenêtre)
/ 8 May 2025; 9 days ago
Typing disciplineDynamic (S'ouvre dans une nouvelle fenêtre), strong (S'ouvre dans une nouvelle fenêtre)License (S'ouvre dans une nouvelle fenêtre)Apache License 2.0 (S'ouvre dans une nouvelle fenêtre)Filename extensions (S'ouvre dans une nouvelle fenêtre).erl, .hrlWebsitewww.erlang.org (S'ouvre dans une nouvelle fenêtre)Major implementations (S'ouvre dans une nouvelle fenêtre)ErlangInfluenced byLisp (S'ouvre dans une nouvelle fenêtre), PLEX (S'ouvre dans une nouvelle fenêtre),[2] (S'ouvre dans une nouvelle fenêtre) Prolog (S'ouvre dans une nouvelle fenêtre), Smalltalk (S'ouvre dans une nouvelle fenêtre)InfluencedAkka (S'ouvre dans une nouvelle fenêtre), Clojure (S'ouvre dans une nouvelle fenêtre),[3] (S'ouvre dans une nouvelle fenêtre) Dart (S'ouvre dans une nouvelle fenêtre), Elixir (S'ouvre dans une nouvelle fenêtre), F# (S'ouvre dans une nouvelle fenêtre), Opa (S'ouvre dans une nouvelle fenêtre), Oz (S'ouvre dans une nouvelle fenêtre), Reia (S'ouvre dans une nouvelle fenêtre), Rust (S'ouvre dans une nouvelle fenêtre),[4] (S'ouvre dans une nouvelle fenêtre) Scala (S'ouvre dans une nouvelle fenêtre), Go (S'ouvre dans une nouvelle fenêtre)
Erlang (/ˈɜːrlæŋ/ (S'ouvre dans une nouvelle fenêtre) UR-lang (S'ouvre dans une nouvelle fenêtre)) is a general-purpose (S'ouvre dans une nouvelle fenêtre), concurrent (S'ouvre dans une nouvelle fenêtre), functional (S'ouvre dans une nouvelle fenêtre) high-level (S'ouvre dans une nouvelle fenêtre) programming language (S'ouvre dans une nouvelle fenêtre), and a garbage-collected (S'ouvre dans une nouvelle fenêtre) runtime system (S'ouvre dans une nouvelle fenêtre). The term Erlang is used interchangeably with Erlang/OTP, or Open Telecom Platform (S'ouvre dans une nouvelle fenêtre) (OTP), which consists of the Erlang runtime system (S'ouvre dans une nouvelle fenêtre), several ready-to-use components (OTP) mainly written in Erlang, and a set of design principles (S'ouvre dans une nouvelle fenêtre) for Erlang programs.[5] (S'ouvre dans une nouvelle fenêtre)
The Erlang runtime system (S'ouvre dans une nouvelle fenêtre) is designed for systems with these traits:
Highly available (S'ouvre dans une nouvelle fenêtre), non-stop (S'ouvre dans une nouvelle fenêtre) applications
Hot swapping (S'ouvre dans une nouvelle fenêtre), where code can be changed without stopping a system.[6] (S'ouvre dans une nouvelle fenêtre)
The Erlang programming language (S'ouvre dans une nouvelle fenêtre) has immutable (S'ouvre dans une nouvelle fenêtre) data, pattern matching (S'ouvre dans une nouvelle fenêtre), and functional programming (S'ouvre dans une nouvelle fenêtre).[7] (S'ouvre dans une nouvelle fenêtre) The sequential subset of the Erlang language supports eager evaluation (S'ouvre dans une nouvelle fenêtre), single assignment (S'ouvre dans une nouvelle fenêtre), and dynamic typing (S'ouvre dans une nouvelle fenêtre).
A normal Erlang application is built out of hundreds of small Erlang processes.
It was originally proprietary software (S'ouvre dans une nouvelle fenêtre) within Ericsson (S'ouvre dans une nouvelle fenêtre), developed by Joe Armstrong (S'ouvre dans une nouvelle fenêtre), Robert Virding, and Mike Williams in 1986,[8] (S'ouvre dans une nouvelle fenêtre) but was released as free and open-source software (S'ouvre dans une nouvelle fenêtre) in 1998.[9] (S'ouvre dans une nouvelle fenêtre)[10] (S'ouvre dans une nouvelle fenêtre) Erlang/OTP is supported and maintained by the Open Telecom Platform (OTP) product unit at Ericsson (S'ouvre dans une nouvelle fenêtre).
History
The name Erlang, attributed to Bjarne Däcker, has been presumed by those working on the telephony switches (for whom the language was designed) to be a reference to Danish mathematician and engineer Agner Krarup Erlang (S'ouvre dans une nouvelle fenêtre) and a syllabic abbreviation (S'ouvre dans une nouvelle fenêtre) of "Ericsson Language".[8] (S'ouvre dans une nouvelle fenêtre)[11] (S'ouvre dans une nouvelle fenêtre)[12] (S'ouvre dans une nouvelle fenêtre) Erlang was designed with the aim of improving the development of telephony applications.[13] (S'ouvre dans une nouvelle fenêtre) The initial version of Erlang was implemented in Prolog (S'ouvre dans une nouvelle fenêtre) and was influenced by the programming language PLEX (S'ouvre dans une nouvelle fenêtre) used in earlier Ericsson exchanges. By 1988 Erlang had proven that it was suitable for prototyping telephone exchanges, but the Prolog interpreter was far too slow. One group within Ericsson estimated that it would need to be 40 times faster to be suitable for production use. In 1992, work began on the BEAM (S'ouvre dans une nouvelle fenêtre) virtual machine (VM), which compiles Erlang to C using a mix of natively compiled code and threaded code (S'ouvre dans une nouvelle fenêtre) to strike a balance between performance and disk space.[14] (S'ouvre dans une nouvelle fenêtre) According to co-inventor Joe Armstrong, the language went from laboratory product to real applications following the collapse of the next-generation AXE telephone exchange (S'ouvre dans une nouvelle fenêtre) named AXE-N (S'ouvre dans une nouvelle fenêtre) in 1995. As a result, Erlang was chosen for the next Asynchronous Transfer Mode (S'ouvre dans une nouvelle fenêtre) (ATM) exchange AXD.[8] (S'ouvre dans une nouvelle fenêtre)
(S'ouvre dans une nouvelle fenêtre)In February 1998, Ericsson Radio Systems banned the in-house use of Erlang for new products, citing a preference for non-proprietary languages.[15] (S'ouvre dans une nouvelle fenêtre) The ban caused Armstrong and others to make plans to leave Ericsson.[16] (S'ouvre dans une nouvelle fenêtre) In March 1998 Ericsson announced the AXD301 switch,[8] (S'ouvre dans une nouvelle fenêtre) containing over a million lines of Erlang and reported to achieve a high availability (S'ouvre dans une nouvelle fenêtre) of nine "9"s (S'ouvre dans une nouvelle fenêtre).[17] (S'ouvre dans une nouvelle fenêtre) In December 1998, the implementation of Erlang was open-sourced and most of the Erlang team resigned to form a new company, Bluetail AB.[8] (S'ouvre dans une nouvelle fenêtre) Ericsson eventually relaxed the ban and re-hired Armstrong in 2004.[16] (S'ouvre dans une nouvelle fenêtre)
In 2006, native symmetric multiprocessing (S'ouvre dans une nouvelle fenêtre) support was added to the runtime system and VM.[8] (S'ouvre dans une nouvelle fenêtre)
Processes
Erlang applications are built of very lightweight Erlang processes in the Erlang runtime system. Erlang processes can be seen as "living" objects (object-oriented programming (S'ouvre dans une nouvelle fenêtre)), with data encapsulation and message passing (S'ouvre dans une nouvelle fenêtre), but capable of changing behavior during runtime. The Erlang runtime system provides strict process isolation (S'ouvre dans une nouvelle fenêtre) between Erlang processes (this includes data and garbage collection, separated individually by each Erlang process) and transparent communication between processes (see Location transparency (S'ouvre dans une nouvelle fenêtre)) on different Erlang nodes (on different hosts).
Joe Armstrong, co-inventor of Erlang, summarized the principles of processes in his PhD (S'ouvre dans une nouvelle fenêtre) thesis (S'ouvre dans une nouvelle fenêtre):[18] (S'ouvre dans une nouvelle fenêtre)
Everything is a process.
Processes are strongly isolated.
Process creation and destruction is a lightweight operation.
Message passing is the only way for processes to interact.
Processes have unique names.
If you know the name of a process you can send it a message.
Processes share no resources.
Error handling is non-local.
Processes do what they are supposed to do or fail.
Joe Armstrong remarked in an interview with Rackspace in 2013: "If Java (S'ouvre dans une nouvelle fenêtre) is 'write once, run anywhere (S'ouvre dans une nouvelle fenêtre)', then Erlang is 'write once, run forever'."[19] (S'ouvre dans une nouvelle fenêtre)
Usage
In 2014, Ericsson (S'ouvre dans une nouvelle fenêtre) reported Erlang was being used in its support nodes, and in GPRS (S'ouvre dans une nouvelle fenêtre), 3G (S'ouvre dans une nouvelle fenêtre) and LTE (S'ouvre dans une nouvelle fenêtre) mobile networks worldwide and also by Nortel (S'ouvre dans une nouvelle fenêtre) and Deutsche Telekom (S'ouvre dans une nouvelle fenêtre).[20] (S'ouvre dans une nouvelle fenêtre)
Erlang is used in RabbitMQ (S'ouvre dans une nouvelle fenêtre). As Tim Bray (S'ouvre dans une nouvelle fenêtre), director of Web Technologies at Sun Microsystems (S'ouvre dans une nouvelle fenêtre), expressed in his keynote at O'Reilly Open Source Convention (S'ouvre dans une nouvelle fenêtre) (OSCON) in July 2008:
If somebody came to me and wanted to pay me a lot of money to build a large scale message handling system that really had to be up all the time, could never afford to go down for years at a time, I would unhesitatingly choose Erlang to build it in.
Erlang is the programming language used to code WhatsApp (S'ouvre dans une nouvelle fenêtre).[21] (S'ouvre dans une nouvelle fenêtre)
It is also the language of choice for Ejabberd (S'ouvre dans une nouvelle fenêtre) – an XMPP (S'ouvre dans une nouvelle fenêtre) messaging server.
Elixir (S'ouvre dans une nouvelle fenêtre) is a programming language that compiles into BEAM byte code (via Erlang Abstract Format).[22] (S'ouvre dans une nouvelle fenêtre)
Since being released as open source, Erlang has been spreading beyond telecoms, establishing itself in other vertical markets such as FinTech, gaming, healthcare, automotive, Internet of Things and blockchain. Apart from WhatsApp, there are other companies listed as Erlang's success stories, including Vocalink (S'ouvre dans une nouvelle fenêtre) (a MasterCard company), Goldman Sachs (S'ouvre dans une nouvelle fenêtre), Nintendo (S'ouvre dans une nouvelle fenêtre), AdRoll, Grindr (S'ouvre dans une nouvelle fenêtre), BT Mobile (S'ouvre dans une nouvelle fenêtre), Samsung (S'ouvre dans une nouvelle fenêtre), OpenX (S'ouvre dans une nouvelle fenêtre), and SITA (S'ouvre dans une nouvelle fenêtre).[23] (S'ouvre dans une nouvelle fenêtre)[24] (S'ouvre dans une nouvelle fenêtre)
Functional programming examples
Factorial
A factorial (S'ouvre dans une nouvelle fenêtre) algorithm implemented in Erlang:
-module(fact). % This is the file 'fact.erl', the module and the filename must match
-export([fac/1]). % This exports the function 'fac' of arity 1 (1 parameter, no type, no name)
fac(0) -> 1; % If 0, then return 1, otherwise (note the semicolon ; meaning 'else')
fac(N) when N > 0, is_integer(N) -> N * fac(N-1).
% Recursively determine, then return the result
% (note the period . meaning 'endif' or 'function end')
%% This function will crash if anything other than a nonnegative integer is given.
%% It illustrates the "Let it crash" philosophy of Erlang.
Fibonacci sequence
A tail recursive algorithm that produces the Fibonacci sequence (S'ouvre dans une nouvelle fenêtre):
%% The module declaration must match the file name "series.erl"
-module(series).
%% The export statement contains a list of all those functions that form
%% the module's public API. In this case, this module exposes a single
%% function called fib that takes 1 argument (I.E. has an arity of 1)
%% The general syntax for -export is a list containing the name and
%% arity of each public function
-export([fib/1]).
%% ---------------------------------------------------------------------
%% Public API
%% ---------------------------------------------------------------------
%% Handle cases in which fib/1 receives specific values
%% The order in which these function signatures are declared is a vital
%% part of this module's functionality
%% If fib/1 receives a negative number, then return the atom err_neg_val
%% Normally, such defensive coding is discouraged due to Erlang's 'Let
%% it Crash' philosophy, but here the result would be an infinite loop.
fib(N) when N < 0 -> err_neg_val;
%% If fib/1 is passed precisely the integer 0, then return 0
fib(0) -> 0;
%% For all other values, call the private function fib_int/3 to perform
%% the calculation
fib(N) -> fib_int(N-1, 0, 1).
%% ---------------------------------------------------------------------
%% Private API
%% ---------------------------------------------------------------------
%% If fib_int/3 receives 0 as its first argument, then we're done, so
%% return the value in argument B. The second argument is denoted _ to
%% disregard its value.
fib_int(0, _, B) -> B;
%% For all other argument combinations, recursively call fib_int/3
%% where each call does the following:
%% - decrement counter N
%% - pass the third argument as the new second argument
%% - pass the sum of the second and third arguments as the new
%% third argument
fib_int(N, A, B) -> fib_int(N-1, B, A+B).
Omitting the comments gives a much shorter program.
-module(series).
-export([fib/1]).
fib(N) when N < 0 -> err_neg_val;
fib(0) -> 0;
fib(N) -> fib_int(N-1, 0, 1).
fib_int(0, _, B) -> B;
fib_int(N, A, B) -> fib_int(N-1, B, A+B).
Quicksort
Quicksort (S'ouvre dans une nouvelle fenêtre) in Erlang, using list comprehension (S'ouvre dans une nouvelle fenêtre):[25] (S'ouvre dans une nouvelle fenêtre)
%% qsort:qsort(List)
%% Sort a list of items
-module(qsort). % This is the file 'qsort.erl'
-export([qsort/1]). % A function 'qsort' with 1 parameter is exported (no type, no name)
qsort([]) -> []; % If the list [] is empty, return an empty list (nothing to sort)
qsort([Pivot|Rest]) ->
% Compose recursively a list with 'Front' for all elements that should be before 'Pivot'
% then 'Pivot' then 'Back' for all elements that should be after 'Pivot'
qsort([Front || Front <- Rest, Front < Pivot]) ++
[Pivot] ++
qsort([Back || Back <- Rest, Back >= Pivot]).
The above example recursively invokes the function qsort until nothing remains to be sorted. The expression [Front || Front <- Rest, Front < Pivot] is a list comprehension (S'ouvre dans une nouvelle fenêtre), meaning "Construct a list of elements Front such that Front is a member of Rest, and Front is less than Pivot." ++ is the list concatenation operator.
A comparison function can be used for more complicated structures for the sake of readability.
The following code would sort lists according to length:
% This is file 'listsort.erl' (the compiler is made this way)
-module(listsort).
% Export 'by_length' with 1 parameter (don't care about the type and name)
-export([by_length/1]).
by_length(Lists) -> % Use 'qsort/2' and provides an anonymous function as a parameter
qsort(Lists, fun(A,B) -> length(A) < length(B) end).
qsort([], _)-> []; % If list is empty, return an empty list (ignore the second parameter)
qsort([Pivot|Rest], Smaller) ->
% Partition list with 'Smaller' elements in front of 'Pivot' and not-'Smaller' elements
% after 'Pivot' and sort the sublists.
qsort([X || X <- Rest, Smaller(X,Pivot)], Smaller)
++ [Pivot] ++
qsort([Y || Y <- Rest, not(Smaller(Y, Pivot))], Smaller).
A Pivot is taken from the first parameter given to qsort() and the rest of Lists is named Rest. Note that the expression
[X || X <- Rest, Smaller(X,Pivot)]
is no different in form from
[Front || Front <- Rest, Front < Pivot]
(in the previous example) except for the use of a comparison function in the last part, saying "Construct a list of elements X such that X is a member of Rest, and Smaller is true", with Smaller being defined earlier as
fun(A,B) -> length(A) < length(B) end
The anonymous function (S'ouvre dans une nouvelle fenêtre) is named Smaller in the parameter list of the second definition of qsort so that it can be referenced by that name within that function. It is not named in the first definition of qsort, which deals with the base case of an empty list and thus has no need of this function, let alone a name for it.
Data types
Erlang has eight primitive data types (S'ouvre dans une nouvelle fenêtre):
Integers
Integers are written as sequences of decimal digits, for example, 12, 12375 and -23427 are integers. Integer arithmetic is exact and only limited by available memory on the machine. (This is called arbitrary-precision arithmetic (S'ouvre dans une nouvelle fenêtre).)
Atoms
Atoms are used within a program to denote distinguished values. They are written as strings of consecutive alphanumeric characters, the first character being lowercase. Atoms can contain any character if they are enclosed within single quotes and an escape convention exists which allows any character to be used within an atom. Atoms are never garbage collected and should be used with caution, especially if using dynamic atom generation.
Floats
Floating point numbers use the IEEE 754 64-bit representation (S'ouvre dans une nouvelle fenêtre).
References
References are globally unique symbols whose only property is that they can be compared for equality. They are created by evaluating the Erlang primitive make_ref().
Binaries
A binary is a sequence of bytes. Binaries provide a space-efficient way of storing binary data. Erlang primitives exist for composing and decomposing binaries and for efficient input/output of binaries.
Pids
Pid is short for process identifier – a Pid is created by the Erlang primitive spawn(...) Pids are references to Erlang processes.
Ports
Ports are used to communicate with the external world. Ports are created with the built-in function open_port. Messages can be sent to and received from ports, but these messages must obey the so-called "port protocol."
Funs
Funs are function closures (S'ouvre dans une nouvelle fenêtre). Funs are created by expressions of the form: fun(...) -> ... end.
And three compound data types:
Tuples
Tuples are containers for a fixed number of Erlang data types. The syntax {D1,D2,...,Dn} denotes a tuple whose arguments are D1, D2, ... Dn. The arguments can be primitive data types or compound data types. Any element of a tuple can be accessed in constant time.
Lists
Lists are containers for a variable number of Erlang data types. The syntax [Dh|Dt] denotes a list whose first element is Dh, and whose remaining elements are the list Dt. The syntax [] denotes an empty list. The syntax [D1,D2,..,Dn] is short for [D1|[D2|..|[Dn|[]]]]. The first element of a list can be accessed in constant time. The first element of a list is called the head of the list. The remainder of a list when its head has been removed is called the tail of the list.
Maps
Maps contain a variable number of key-value associations. The syntax is#{Key1=>Value1,...,KeyN=>ValueN}.
Two forms of syntactic sugar (S'ouvre dans une nouvelle fenêtre) are provided:
Strings
Strings are written as doubly quoted lists of characters. This is syntactic sugar for a list of the integer Unicode (S'ouvre dans une nouvelle fenêtre) code points for the characters in the string. Thus, for example, the string "cat" is shorthand for [99,97,116].[26] (S'ouvre dans une nouvelle fenêtre)
Records
Records provide a convenient way for associating a tag with each of the elements in a tuple. This allows one to refer to an element of a tuple by name and not by position. A pre-compiler takes the record definition and replaces it with the appropriate tuple reference.
Erlang has no method to define classes, although there are external libraries (S'ouvre dans une nouvelle fenêtre) available.[27] (S'ouvre dans une nouvelle fenêtre)
"Let it crash" coding style
Erlang is designed with a mechanism that makes it easy for external processes to monitor for crashes (or hardware failures), rather than an in-process mechanism like exception handling (S'ouvre dans une nouvelle fenêtre) used in many other programming languages. Crashes are reported like other messages, which is the only way processes can communicate with each other,[28] (S'ouvre dans une nouvelle fenêtre) and subprocesses can be spawned cheaply (see below (S'ouvre dans une nouvelle fenêtre)). The "let it crash" philosophy prefers that a process be completely restarted rather than trying to recover from a serious failure.[29] (S'ouvre dans une nouvelle fenêtre) Though it still requires handling of errors, this philosophy results in less code devoted to defensive programming (S'ouvre dans une nouvelle fenêtre) where error-handling code is highly contextual and specific.[28] (S'ouvre dans une nouvelle fenêtre)
Supervisor trees
A typical Erlang application is written in the form of a supervisor tree. This architecture is based on a hierarchy of processes in which the top level process is known as a "supervisor". The supervisor then spawns multiple child processes that act either as workers or more, lower level supervisors. Such hierarchies can exist to arbitrary depths and have proven to provide a highly scalable and fault-tolerant environment within which application functionality can be implemented.
Within a supervisor tree, all supervisor processes are responsible for managing the lifecycle of their child processes, and this includes handling situations in which those child processes crash. Any process can become a supervisor by first spawning a child process, then calling erlang:monitor/2 on that process. If the monitored process then crashes, the supervisor will receive a message containing a tuple whose first member is the atom 'DOWN'. The supervisor is responsible firstly for listening for such messages and for taking the appropriate action to correct the error condition.
Concurrency and distribution orientation
Erlang's main strength is support for concurrency (S'ouvre dans une nouvelle fenêtre). It has a small but powerful set of primitives to create processes and communicate among them. Erlang is conceptually similar to the language occam (S'ouvre dans une nouvelle fenêtre), though it recasts the ideas of communicating sequential processes (S'ouvre dans une nouvelle fenêtre) (CSP) in a functional framework and uses asynchronous message passing.[30] (S'ouvre dans une nouvelle fenêtre) Processes are the primary means to structure an Erlang application. They are neither operating system (S'ouvre dans une nouvelle fenêtre) processes (S'ouvre dans une nouvelle fenêtre) nor threads (S'ouvre dans une nouvelle fenêtre), but lightweight processes (S'ouvre dans une nouvelle fenêtre) that are scheduled by BEAM. Like operating system processes (but unlike operating system threads), they share no state with each other. The estimated minimal overhead for each is 300 words (S'ouvre dans une nouvelle fenêtre).[31] (S'ouvre dans une nouvelle fenêtre) Thus, many processes can be created without degrading performance. In 2005, a benchmark with 20 million processes was successfully performed with 64-bit Erlang on a machine with 16 GB random-access memory (S'ouvre dans une nouvelle fenêtre) (RAM; total 800 bytes/process).[32] (S'ouvre dans une nouvelle fenêtre) Erlang has supported symmetric multiprocessing (S'ouvre dans une nouvelle fenêtre) since release R11B of May 2006.
While threads (S'ouvre dans une nouvelle fenêtre) need external library support in most languages, Erlang provides language-level features to create and manage processes with the goal of simplifying concurrent programming. Though all concurrency is explicit in Erlang, processes communicate using message passing (S'ouvre dans une nouvelle fenêtre) instead of shared variables, which removes the need for explicit locks (S'ouvre dans une nouvelle fenêtre) (a locking scheme is still used internally by the VM).[33] (S'ouvre dans une nouvelle fenêtre)
Inter-process communication (S'ouvre dans une nouvelle fenêtre) works via a shared-nothing (S'ouvre dans une nouvelle fenêtre) asynchronous (S'ouvre dans une nouvelle fenêtre) message passing (S'ouvre dans une nouvelle fenêtre) system: every process has a "mailbox", a queue (S'ouvre dans une nouvelle fenêtre) of messages that have been sent by other processes and not yet consumed. A process uses the receive primitive to retrieve messages that match desired patterns. A message-handling routine tests messages in turn against each pattern, until one of them matches. When the message is consumed and removed from the mailbox the process resumes execution. A message may comprise any Erlang structure, including primitives (integers, floats, characters, atoms), tuples, lists, and functions.
The code example below shows the built-in support for distributed processes:
% Create a process and invoke the function web:start_server(Port, MaxConnections)
ServerProcess = spawn(web, start_server, [Port, MaxConnections]),
% Create a remote process and invoke the function
% web:start_server(Port, MaxConnections) on machine RemoteNode
RemoteProcess = spawn(RemoteNode, web, start_server, [Port, MaxConnections]),
% Send a message to ServerProcess (asynchronously). The message consists of a tuple
% with the atom "pause" and the number "10".
ServerProcess ! {pause, 10},
% Receive messages sent to this process
receive
a_message -> do_something;
{data, DataContent} -> handle(DataContent);
{hello, Text} -> io:format("Got hello message: ~s", [Text]);
{goodbye, Text} -> io:format("Got goodbye message: ~s", [Text])
end.
As the example shows, processes may be created on remote nodes, and communication with them is transparent in the sense that communication with remote processes works exactly as communication with local processes.
Concurrency supports the primary method of error-handling in Erlang. When a process crashes, it neatly exits and sends a message to the controlling process which can then take action, such as starting a new process that takes over the old process's task.[34] (S'ouvre dans une nouvelle fenêtre)[35] (S'ouvre dans une nouvelle fenêtre)
Implementation
The official reference implementation of Erlang uses BEAM (S'ouvre dans une nouvelle fenêtre).[36] (S'ouvre dans une nouvelle fenêtre) BEAM is included in the official distribution of Erlang, called Erlang/OTP. BEAM executes bytecode (S'ouvre dans une nouvelle fenêtre) which is converted to threaded code (S'ouvre dans une nouvelle fenêtre) at load time. It also includes a native code compiler on most platforms, developed by the High Performance Erlang Project (HiPE) at Uppsala University (S'ouvre dans une nouvelle fenêtre). Since October 2001 the HiPE system is fully integrated in Ericsson's Open Source Erlang/OTP system.[37] (S'ouvre dans une nouvelle fenêtre) It also supports interpreting, directly from source code via abstract syntax tree (S'ouvre dans une nouvelle fenêtre), via script as of R11B-5 release of Erlang.
Hot code loading and modules
Erlang supports language-level Dynamic Software Updating (S'ouvre dans une nouvelle fenêtre). To implement this, code is loaded and managed as "module" units; the module is a compilation unit (S'ouvre dans une nouvelle fenêtre). The system can keep two versions of a module in memory at the same time, and processes can concurrently run code from each. The versions are referred to as the "new" and the "old" version. A process will not move into the new version until it makes an external call to its module.
An example of the mechanism of hot code loading:
%% A process whose only job is to keep a counter.
%% First version
-module(counter).
-export([start/0, codeswitch/1]).
start() -> loop(0).
loop(Sum) ->
receive
{increment, Count} ->
loop(Sum+Count);
{counter, Pid} ->
Pid ! {counter, Sum},
loop(Sum);
code_switch ->
?MODULE:codeswitch(Sum)
% Force the use of 'codeswitch/1' from the latest MODULE version
end.
codeswitch(Sum) -> loop(Sum).
For the second version, we add the possibility to reset the count to zero.
%% Second version
-module(counter).
-export([start/0, codeswitch/1]).
start() -> loop(0).
loop(Sum) ->
receive
{increment, Count} ->
loop(Sum+Count);
reset ->
loop(0);
{counter, Pid} ->
Pid ! {counter, Sum},
loop(Sum);
code_switch ->
?MODULE:codeswitch(Sum)
end.
codeswitch(Sum) -> loop(Sum).
Only when receiving a message consisting of the atom code_switch will the loop execute an external call to codeswitch/1 (?MODULE is a preprocessor macro for the current module). If there is a new version of the counter module in memory, then its codeswitch/1 function will be called. The practice of having a specific entry-point into a new version allows the programmer to transform state to what is needed in the newer version. In the example, the state is kept as an integer.
In practice, systems are built up using design principles from the Open Telecom Platform, which leads to more code upgradable designs. Successful hot code loading is exacting. Code must be written with care to make use of Erlang's facilities.
Distribution
In 1998, Ericsson released Erlang as free and open-source software (S'ouvre dans une nouvelle fenêtre) to ensure its independence from a single vendor and to increase awareness of the language. Erlang, together with libraries and the real-time distributed database Mnesia (S'ouvre dans une nouvelle fenêtre), forms the OTP collection of libraries. Ericsson and a few other companies support Erlang commercially.
Since the open source release, Erlang has been used by several firms worldwide, including Nortel (S'ouvre dans une nouvelle fenêtre) and Deutsche Telekom (S'ouvre dans une nouvelle fenêtre).[38] (S'ouvre dans une nouvelle fenêtre) Although Erlang was designed to fill a niche and has remained an obscure language for most of its existence, its popularity is growing due to demand for concurrent services.[39] (S'ouvre dans une nouvelle fenêtre)[40] (S'ouvre dans une nouvelle fenêtre) Erlang has found some use in fielding massively multiplayer online role-playing game (S'ouvre dans une nouvelle fenêtre) (MMORPG) servers.[41] (S'ouvre dans une nouvelle fenêtre)
See also
Elixir (S'ouvre dans une nouvelle fenêtre) – a functional, concurrent, general-purpose programming language that runs on BEAM
Luerl (S'ouvre dans une nouvelle fenêtre) - Lua on the BEAM, designed and implemented by one of the creators of Erlang.
Lisp Flavored Erlang (S'ouvre dans une nouvelle fenêtre) (LFE) – a Lisp-based programming language that runs on BEAM
Gleam (programming language) (S'ouvre dans une nouvelle fenêtre)
References
"Release 27.3.4" (S'ouvre dans une nouvelle fenêtre). 8 May 2025. Retrieved 17 May 2025.
Conferences, N. D. C. (4 June 2014). "Joe Armstrong - Functional Programming the Long Road to Enlightenment: a Historical and Personal Narrative" (S'ouvre dans une nouvelle fenêtre). Vimeo.
"Clojure: Lisp meets Java, with a side of Erlang - O'Reilly Radar" (S'ouvre dans une nouvelle fenêtre). radar.oreilly.com (S'ouvre dans une nouvelle fenêtre).
"Influences - The Rust Reference" (S'ouvre dans une nouvelle fenêtre). The Rust Reference. Retrieved 18 April 2023.
"Erlang – Introduction" (S'ouvre dans une nouvelle fenêtre). erlang.org (S'ouvre dans une nouvelle fenêtre). Archived from the original (S'ouvre dans une nouvelle fenêtre) on 8 September 2019. Retrieved 6 February 2017.
Armstrong, Joe; Däcker, Bjarne; Lindgren, Thomas; Millroth, Håkan. "Open-source Erlang – White Paper" (S'ouvre dans une nouvelle fenêtre). Archived from the original (S'ouvre dans une nouvelle fenêtre) on 25 October 2011. Retrieved 31 July 2011.
Hitchhiker’s Tour of the BEAM – Robert Virding http://www.erlang-factory.com/upload/presentations/708/HitchhikersTouroftheBEAM.pdf (S'ouvre dans une nouvelle fenêtre)
Armstrong, Joe (2007). History of Erlang. HOPL III: Proceedings of the third ACM SIGPLAN conference on History of programming languages. ISBN (S'ouvre dans une nouvelle fenêtre) 978-1-59593-766-7 (S'ouvre dans une nouvelle fenêtre).
"How tech giants spread open source programming love - (S'ouvre dans une nouvelle fenêtre)CIO.com (S'ouvre dans une nouvelle fenêtre)" (S'ouvre dans une nouvelle fenêtre). 8 January 2016. Archived from the original (S'ouvre dans une nouvelle fenêtre) on 22 February 2019. Retrieved 5 September 2016.
"Erlang/OTP Released as Open Source, 1998-12-08" (S'ouvre dans une nouvelle fenêtre). Archived from the original (S'ouvre dans une nouvelle fenêtre) on 9 October 1999.
"Erlang, the mathematician?" (S'ouvre dans une nouvelle fenêtre). February 1999.
"Free Online Dictionary of Computing: Erlang" (S'ouvre dans une nouvelle fenêtre).
"History of Erlang" (S'ouvre dans une nouvelle fenêtre). Erlang.org (S'ouvre dans une nouvelle fenêtre).
Armstrong, Joe (August 1997). "The development of Erlang". Proceedings of the second ACM SIGPLAN international conference on Functional programming. Vol. 32. pp. 196–203. doi (S'ouvre dans une nouvelle fenêtre):10.1145/258948.258967 (S'ouvre dans une nouvelle fenêtre). ISBN (S'ouvre dans une nouvelle fenêtre) 0897919181 (S'ouvre dans une nouvelle fenêtre). S2CID (S'ouvre dans une nouvelle fenêtre) 6821037 (S'ouvre dans une nouvelle fenêtre).
{{cite book}}:|journal=ignored (help (S'ouvre dans une nouvelle fenêtre))Däcker, Bjarne (October 2000). Concurrent Functional Programming for Telecommunications: A Case Study of Technology Introduction (S'ouvre dans une nouvelle fenêtre) (PDF) (Thesis). Royal Institute of Technology. p. 37.
"question about Erlang's future" (S'ouvre dans une nouvelle fenêtre). 6 July 2010.
"Concurrency Oriented Programming in Erlang" (S'ouvre dans une nouvelle fenêtre) (PDF). 9 November 2002.
Armstrong, Joe (20 November 2003). Making reliable distributed systems in the presence of software errors (DTech thesis). Stockholm, Sweden: The Royal Institute of Technology.
McGreggor, Duncan (26 March 2013). Rackspace takes a look at the Erlang programming language for distributed computing (S'ouvre dans une nouvelle fenêtre) (Video). Rackspace Studios, SFO. Archived (S'ouvre dans une nouvelle fenêtre) from the original on 11 December 2021. Retrieved 24 April 2019.
"Ericsson" (S'ouvre dans une nouvelle fenêtre). Ericsson.com (S'ouvre dans une nouvelle fenêtre). 4 December 2014. Retrieved 7 April 2018.
"Inside Erlang, The Rare Programming Language Behind WhatsApp's Success" (S'ouvre dans une nouvelle fenêtre). fastcompany.com (S'ouvre dans une nouvelle fenêtre). 21 February 2014. Retrieved 12 November 2019.
"Erlang/Elixir Syntax: A Crash Course" (S'ouvre dans une nouvelle fenêtre). elixir-lang.github.com (S'ouvre dans une nouvelle fenêtre). Retrieved 10 October 2022.
"Which companies are using Erlang, and why? #MyTopdogStatus" (S'ouvre dans une nouvelle fenêtre). erlang-solutions.com (S'ouvre dans une nouvelle fenêtre). 11 September 2019. Retrieved 15 March 2020.
"Which new companies are using Erlang and Elixir? #MyTopdogStatus" (S'ouvre dans une nouvelle fenêtre). erlang-solutions.com (S'ouvre dans une nouvelle fenêtre). 2 March 2020. Retrieved 24 June 2020.
"Erlang – List Comprehensions" (S'ouvre dans une nouvelle fenêtre). erlang.org (S'ouvre dans une nouvelle fenêtre).
"String and Character Literals" (S'ouvre dans une nouvelle fenêtre). Retrieved 2 May 2015.
"ect – Erlang Class Transformation – add object-oriented programming to Erlang – Google Project Hosting" (S'ouvre dans une nouvelle fenêtre). Retrieved 2 May 2015.
Verraes, Mathias (9 December 2014). "Let It Crash" (S'ouvre dans une nouvelle fenêtre). Mathias Verraes' Blog. Retrieved 10 February 2021.
"Reactive Design Patterns —" (S'ouvre dans une nouvelle fenêtre). www.reactivedesignpatterns.com (S'ouvre dans une nouvelle fenêtre). Retrieved 10 February 2021.
Armstrong, Joe (S'ouvre dans une nouvelle fenêtre) (September 2010). "Erlang" (S'ouvre dans une nouvelle fenêtre). Communications of the ACM (S'ouvre dans une nouvelle fenêtre). 53 (9): 68–75. doi (S'ouvre dans une nouvelle fenêtre):10.1145/1810891.1810910 (S'ouvre dans une nouvelle fenêtre). Erlang is conceptually similar to the occam programming language, though it recasts the ideas of CSP in a functional framework and uses asynchronous message passing.
"Erlang Efficiency Guide – Processes" (S'ouvre dans une nouvelle fenêtre). Archived from the original (S'ouvre dans une nouvelle fenêtre) on 27 February 2015.
Wiger, Ulf (14 November 2005). "Stress-testing erlang" (S'ouvre dans une nouvelle fenêtre). comp.lang.functional.misc. Retrieved 25 August 2006.
"Lock-free message queue" (S'ouvre dans une nouvelle fenêtre). Archived from the original (S'ouvre dans une nouvelle fenêtre) on 24 December 2013. Retrieved 23 December 2013.
Armstrong, Joe. "Erlang robustness" (S'ouvre dans une nouvelle fenêtre). Archived from the original (S'ouvre dans une nouvelle fenêtre) on 23 April 2015. Retrieved 15 July 2010.
"Erlang Supervision principles" (S'ouvre dans une nouvelle fenêtre). Archived from the original (S'ouvre dans une nouvelle fenêtre) on 6 February 2015. Retrieved 15 July 2010.
"Erlang – Compilation and Code Loading" (S'ouvre dans une nouvelle fenêtre). erlang.org (S'ouvre dans une nouvelle fenêtre). Retrieved 21 December 2017.
"High Performance Erlang" (S'ouvre dans une nouvelle fenêtre). Retrieved 26 March 2011.
"Who uses Erlang for product development?" (S'ouvre dans une nouvelle fenêtre). Frequently asked questions about Erlang. Retrieved 16 July 2007. The largest user of Erlang is (surprise!) Ericsson. Ericsson use it to write software used in telecommunications systems. Many dozens of projects have used it, a particularly large one is the extremely scalable AXD301 ATM switch. Other commercial users listed as part of the FAQ include: Nortel, Deutsche Flugsicherung (the German national air traffic control (S'ouvre dans une nouvelle fenêtre) organisation), and T-Mobile.
"Programming Erlang" (S'ouvre dans une nouvelle fenêtre). Retrieved 13 December 2008. Virtually all language use shared state concurrency. This is very difficult and leads to terrible problems when you handle failure and scale up the system...Some pretty fast-moving startups in the financial world have latched onto Erlang; for example, the Swedish www.kreditor.se (S'ouvre dans une nouvelle fenêtre).
"Erlang, the next Java" (S'ouvre dans une nouvelle fenêtre). Archived from the original (S'ouvre dans une nouvelle fenêtre) on 11 October 2007. Retrieved 8 October 2008. I do not believe that other languages can catch up with Erlang anytime soon. It will be easy for them to add language features to be like Erlang. It will take a long time for them to build such a high-quality VM and the mature libraries for concurrency and reliability. So, Erlang is poised for success. If you want to build a multicore application in the next few years, you should look at Erlang.
Clarke, Gavin (5 February 2011). "Battlestar Galactica vets needed for online roleplay" (S'ouvre dans une nouvelle fenêtre). Music and Media. The Reg (S'ouvre dans une nouvelle fenêtre). Retrieved 8 February 2011.
Further reading
Armstrong, Joe (2003). Making reliable distributed systems in the presence of software errors (S'ouvre dans une nouvelle fenêtre) (PDF) (PhD). The Royal Institute of Technology, Stockholm, Sweden. Archived from the original (S'ouvre dans une nouvelle fenêtre) (PDF) on 23 March 2015. Retrieved 13 February 2016.
Armstrong, Joe (2007). "A history of Erlang". Proceedings of the third ACM SIGPLAN conference on History of programming languages – HOPL III. pp. 6–1. doi (S'ouvre dans une nouvelle fenêtre):10.1145/1238844.1238850 (S'ouvre dans une nouvelle fenêtre). ISBN (S'ouvre dans une nouvelle fenêtre) 978-1-59593-766-7 (S'ouvre dans une nouvelle fenêtre). S2CID (S'ouvre dans une nouvelle fenêtre) 555765 (S'ouvre dans une nouvelle fenêtre).
Early history of Erlang (S'ouvre dans une nouvelle fenêtre) Archived (S'ouvre dans une nouvelle fenêtre) 29 August 2019 at the Wayback Machine (S'ouvre dans une nouvelle fenêtre) by Bjarne Däcker
Mattsson, H.; Nilsson, H.; Wikstrom, C. (1999). "Mnesia – A distributed robust DBMS for telecommunications applications". First International Workshop on Practical Aspects of Declarative Languages (PADL '99): 152–163.
Armstrong, Joe; Virding, Robert; Williams, Mike; Wikstrom, Claes (16 January 1996). Concurrent Programming in Erlang (S'ouvre dans une nouvelle fenêtre) (2nd ed.). Prentice Hall (S'ouvre dans une nouvelle fenêtre). p. 358. ISBN (S'ouvre dans une nouvelle fenêtre) 978-0-13-508301-7 (S'ouvre dans une nouvelle fenêtre). Archived from the original (S'ouvre dans une nouvelle fenêtre) on 6 March 2012.
Armstrong, Joe (11 July 2007). Programming Erlang: Software for a Concurrent World (S'ouvre dans une nouvelle fenêtre) (1st ed.). Pragmatic Bookshelf (S'ouvre dans une nouvelle fenêtre). p. 536 (S'ouvre dans une nouvelle fenêtre). ISBN (S'ouvre dans une nouvelle fenêtre) 978-1-934356-00-5 (S'ouvre dans une nouvelle fenêtre).
Thompson, Simon J.; Cesarini, Francesco (19 June 2009). Erlang Programming: A Concurrent Approach to Software Development (S'ouvre dans une nouvelle fenêtre) (1st ed.). Sebastopol, California: O'Reilly Media (S'ouvre dans une nouvelle fenêtre), Inc. p. 496. ISBN (S'ouvre dans une nouvelle fenêtre) 978-0-596-51818-9 (S'ouvre dans une nouvelle fenêtre).
Logan, Martin; Merritt, Eric; Carlsson, Richard (28 May 2010). Erlang and OTP in Action (1st ed.). Greenwich, CT: Manning Publications (S'ouvre dans une nouvelle fenêtre). p. 500. ISBN (S'ouvre dans une nouvelle fenêtre) 978-1-933988-78-8 (S'ouvre dans une nouvelle fenêtre).
Martin, Brown (10 May 2011). "Introduction to programming in Erlang, Part 1: The basics" (S'ouvre dans une nouvelle fenêtre). developerWorks. IBM. Retrieved 10 May 2011.
Martin, Brown (17 May 2011). "Introduction to programming in Erlang, Part 2: Use advanced features and functionality" (S'ouvre dans une nouvelle fenêtre). developerWorks. IBM. Retrieved 17 May 2011.
Wiger, Ulf (30 March 2001). "Four-fold Increase in Productivity and Quality: Industrial-Strength Functional Programming in Telecom-Class Products" (S'ouvre dans une nouvelle fenêtre) (PDF). FEmSYS 2001 Deployment on distributed architectures. Ericsson Telecom AB. Archived from the original (S'ouvre dans une nouvelle fenêtre) (PDF) on 19 August 2019. Retrieved 16 September 2014.
External links
Wikimedia Commons has media related to Erlang (programming language) (S'ouvre dans une nouvelle fenêtre).
Wikibooks has a book on the topic of: Erlang Programming (S'ouvre dans une nouvelle fenêtre)