Erlang programming language

Erlang is a general-purpose concurrent programming language and runtime system. The sequential sub-set of Erlang is a functional language, with strict evaluation, single assignment and dynamic typing. It was designed at Ericsson to support distributed, fault-tolerant, soft-real-time, non-stop applications.

It is named after A. K. Erlang. It is sometimes mistakenly thought that its name is as abbreviation of ERicsson LANGuage, owing to its heavy use inside Ericsson.


Contents

Functional language

Code looks like this:

-module(fact).
-export([fac/1]).

fac(0) -> 1;
fac(N) where N > 0 -> N * fac(N-1).

Below is an implementation of a Quicksort algorithm.

%% quicksort(List)
%% Sort a list of items
-module(quicksort).
-export([qsort/1]).

qsort([]) -> [];
qsort([Pivot|Rest]) ->
    qsort([ X || X <- Rest, X < Pivot]) ++ [Pivot] ++ qsort([ Y || Y <- Rest, Y >= Pivot]).

The above example recursively calls the function qsort until there is no more to be sorted. The expression [ X || X <- Rest, X < Pivot] can be read as "Chose all X where X is a member of Rest and X is less than Pivot", resulting in a very easy way of handling Lists. Since you can evaluate any boolean expression between two different datatypes, the evaluation is straight forward - for example, 1 < a will return true.

However, a compare function can be used if the order on which Erlang bases its return value (true or false) needs to be changed. For example, if we would want an ordered list where a > 1 evaluates true.

Concurrency oriented language

Main strength of Erlang is support for concurrency. It has small but powerful set of primitives to create threads and communicate between them. Location of thread is transparent (it can be within the same operating system process or on different computer).

Code examples:

 Pid = spawn(Mod, Func, Args)     % execute function Func as new thread
 Pid ! a_message      % send message to the thread (asynchronously)
 receive       % receive message sent to this thread
   a_message -> do_something
 end.

Erlang contains mechanisms to deal with errors and to ensure high availability of the whole system. Dynamical replacement of code (hot swapping) is supported.

Distribution

Erlang was released as open source to ensure its dependence on single source and to increase awareness of the language. Distribution of the language together with libraries and real-time distributed database is known as Open Telecom Platform, OTP. Ericsson offers commercial support for Erlang.

Since taking the open source path in 1998, it became used by several companies world-wide, including Nortel and T-Mobile. However, it didn't and hasn't yet become a wide-spread mainstream programming language.

As of 2005, Erlang is under active development with regular releases. It is available for several Unix-like operating systems and Microsoft Windows.

Advantages

  • superb support for concurrency (it is no problem to create hundreds of thousands of threads)
  • high programmer productivity (Ericsson study claim 4x higher than C)
  • small and simple to learn: Erlang is not academic language but real-world tool designed to be useable by Ericsson programmers
  • scalability: large systems with millions lines of code were written in Erlang

Disadvantages

  • not intended for high-performance applications (interpreted language, uses garbage collection)
  • lack of static typing: many errors are caught only during runtime (over time the compiler is improved to catch more typing errors, though)
  • as it is not a mainstream language there are not many tools, books, libraries or skilled developers. For example GUI support is still in its infancy.

See also

External links


Template:Major programming languages smallde:Erlang (Programmiersprache) fr:Erlang (langage) it:Erlang (linguaggio) nl:Programmeertaal Erlang ru:Erlang sv:Erlang

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools