Content deleted Content added
No edit summary |
BrainStack (talk | contribs) Link suggestions feature: 3 links added. |
||
(12 intermediate revisions by 10 users not shown) | |||
Line 4:
| name = Erlang
| logo = Erlang logo.svg
| logo size =
| paradigms = [[Multi-paradigm programming language|Multi-paradigm]]: [[Concurrent programming|concurrent]], [[Functional programming|functional
| family =
| designer = {{unbulleted list|[[Joe Armstrong (programmer)|Joe Armstrong]]|Robert Virding|Mike Williams}}
Line 20:
| file ext = .erl, .hrl
| license = [[Apache License 2.0]]
| website = {{
| wikibooks = Erlang Programming
}}
'''Erlang''' ({{IPAc-en|ˈ|ɜr|l|æ|ŋ}} {{respell|UR|lang}}) is a [[General-purpose programming language|general-purpose]], [[concurrent computing|concurrent]], [[Functional programming|functional]] [[High-level programming language|high-level]] [[programming language]], and a [[Garbage collection (computer science)|garbage-collected]] [[runtime system]]. The term Erlang is used interchangeably with Erlang/OTP, or [[Open Telecom Platform]] (OTP), which consists of the Erlang [[runtime system]], several ready-to-use components (OTP) mainly written in Erlang, and a set of [[Systems architecture|design principles]] for Erlang programs.<ref>{{cite web |url=http://erlang.org/doc/system_architecture_intro/sys_arch_intro.html#id58791 |title=Erlang – Introduction |website=erlang.org |access-date=6 February 2017 |archive-date=8 September 2019 |archive-url=https://web.archive.org/web/20190908105859/http://erlang.org/doc/system_architecture_intro/sys_arch_intro.html#id58791 |url-status=dead }}</ref>
The Erlang [[runtime system]] is designed for systems with these traits:
Line 34:
*[[Hot swapping#Software|Hot swapping]], where code can be changed without stopping a system.<ref>{{cite web |last1=Armstrong |first1=Joe |last2=Däcker |first2=Bjarne |last3=Lindgren |first3=Thomas |last4=Millroth |first4=Håkan |title=Open-source Erlang – White Paper |url=http://ftp.sunet.se/pub/lang/erlang/white_paper.html|archive-url=https://web.archive.org/web/20111025022940/http://ftp.sunet.se/pub/lang/erlang/white_paper.html |archive-date=25 October 2011 |access-date=31 July 2011}}</ref>
The Erlang [[programming language]] has
A normal Erlang application is built out of hundreds of small Erlang processes.
Line 41:
==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]] and a [[Abbreviation#Syllabic abbreviation|syllabic abbreviation]] of "Ericsson Language".<ref name="hopl"/><ref>{{cite web |url=http://www.erlang.org/pipermail/erlang-questions/1999-February/000098.html |title=Erlang, the mathematician? |date=February 1999 }}</ref><ref>{{cite web |url=https://foldoc.org/Erlang |title=Free Online Dictionary of Computing: Erlang }}</ref> Erlang was designed with the aim of improving the development of telephony applications.<ref>{{cite web|url=http://erlang.org/course/history.html|title=History of Erlang|website=Erlang.org}}</ref> The initial version of Erlang was implemented in [[Prolog]] and was influenced by the programming language [[PLEX (programming language)|PLEX]] 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 (Erlang virtual machine)|BEAM]] [[virtual machine]] (VM), which compiles Erlang to C using a mix of natively compiled code and [[threaded code]] to strike a balance between performance and disk space.<ref>{{cite book |last=Armstrong |first=Joe |chapter=The development of Erlang |title=Proceedings of the second ACM SIGPLAN international conference on Functional programming |journal=ACM SIGPLAN Notices |date=August 1997 |volume=32 |issue=8 |pages=196–203 |doi=10.1145/258948.258967 |isbn=0897919181 |s2cid=6821037 }}</ref> According to co-inventor Joe Armstrong, the language went from
[[File:Robert Virding and Joe Armstrong, 2013.jpg|thumb|Robert Virding and Joe Armstrong, 2013]]
In February 1998, Ericsson Radio Systems banned the in-house use of Erlang for new products, citing a preference for non-proprietary languages.<ref>{{cite thesis|url=https://cogsys.uni-bamberg.de/team/schmid/uoshp/lehreuos/fp01-www/fp-referate/erlang/bjarnelic.pdf#page=45|title=Concurrent Functional Programming for Telecommunications: A Case Study of Technology Introduction|first=Bjarne|last=Däcker|date=October 2000|publisher=Royal Institute of Technology|page=37}}</ref> The ban caused Armstrong and others to make plans to leave Ericsson.<ref name="questions"/> In March 1998 Ericsson announced the AXD301 switch,<ref name="hopl"/> containing over a million lines of Erlang and reported to achieve a [[high availability]] of [[nines (engineering)|nine "9"s]].<ref>
{{cite web |url=http://www.rabbitmq.com/resources/armstrong.pdf |title=Concurrency Oriented Programming in Erlang |date=9 November 2002}}
</ref> In December 1998, the implementation of Erlang was open-sourced and most of the Erlang team resigned to form a new company, Bluetail AB.<ref name="hopl"/> Ericsson eventually relaxed the ban and re-hired Armstrong in 2004.<ref name="questions">{{cite web |url=http://erlang.org/pipermail/erlang-questions/2006-July/021368.html |title=question about Erlang's future |date=6 July 2010}}</ref>
In 2006, native [[symmetric multiprocessing]] support was added to the runtime system and VM.<ref name="hopl"/>
===Processes===
Erlang applications are built of very lightweight Erlang processes in the Erlang runtime system
Joe Armstrong, co-inventor of Erlang, summarized the principles of processes in his [[Doctor of Philosophy|PhD]] [[thesis]]:<ref>{{Cite thesis |last=Armstrong |first=Joe |title=Making reliable distributed systems in the presence of software errors |date=20 November 2003 |degree=DTech |publisher=The Royal Institute of Technology |place=Stockholm, Sweden}}</ref>
Line 77:
It is also the language of choice for [[Ejabberd]] – an [[XMPP]] messaging server.
[[
Since being released as open source, Erlang has been spreading beyond telecoms, establishing itself in other vertical markets such as FinTech, gaming, healthcare, automotive,
==Functional programming examples==
Line 138:
%% 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
%%
fib_int(0, _, B) -> B;
Line 241:
;Strings: Strings are written as doubly quoted lists of characters. This is syntactic sugar for a list of the integer [[Unicode]] code points for the characters in the string. Thus, for example, the string "cat" is shorthand for <code>[99,97,116]</code>.<ref>{{cite web |url=http://erlang.org/doc/apps/stdlib/unicode_usage.html#string-and-character-literals |title=String and Character Literals |access-date=2 May 2015}}</ref>
;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.
=="Let it crash" coding style==
Line 251 ⟶ 249:
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 <code>erlang:monitor/2</code> on that process. If the monitored process then crashes, the supervisor will receive a message containing a tuple whose first member is the atom <code>'DOWN'</code>. The supervisor is responsible firstly for listening for such messages and
==Concurrency and distribution orientation==
Line 299 ⟶ 297:
==Implementation==
The official [[reference implementation]] of Erlang uses [[BEAM (Erlang virtual machine)|BEAM]].<ref>{{cite web |url=http://erlang.org/doc/reference_manual/code_loading.html#id90080 |title=Erlang – Compilation and Code Loading |website=erlang.org |access-date=2017-12-21}}</ref> BEAM is included in the official distribution of Erlang, called Erlang/OTP. BEAM executes [[bytecode]] which is converted to [[threaded code]] at load time. It also includes a native code compiler on most platforms, developed by the High Performance Erlang Project (HiPE) at [[Uppsala University]]. Since October 2001 the HiPE system is fully integrated in Ericsson's Open Source Erlang/OTP system.<ref>{{cite web |title=High Performance Erlang |url=http://www.it.uu.se/research/group/hipe/ |access-date=26 March 2011}}</ref> It also supports interpreting, directly from source code via [[abstract syntax tree]], via script as of R11B-5 release of Erlang.
==Hot code loading and modules==
Line 379 ⟶ 377:
* [[Mix (build tool)]]
* [[Phoenix (web framework)]]
* [[Gleam (programming language)]] – a general-purpose, concurrent, functional high-level programming language that compiles to Erlang
==References==
|