blog

Home / DeveloperSection / Blogs / What is Erlang?

What is Erlang?

Sunil Singh3341 22-May-2015

Erlang was developed at Ericsson and was designed from the ground up for writing scalable, fault-tolerant, distributed, non-stop, soft-realtime applications.Everything in the language, runtime, and libraries reflects that purpose, which makes Erlang the best platform for developing this kind of software. 

Data structures

Erlang has eight primitive data types:

Integers — integers are written as sequences of decimal digits, for

Example, 12, 12375 and -23427 are integers.

Atoms — atoms are used within a program to denote distinguished values. They are written as strings of consecutive alphanumeric char- acters, the first character being a small letter. Atoms can obtain any character if they are enclosed within single quotes and an escape convention exists which allows any character to be used within an atom.

Floats — floating point numbers are represented as IEEE 754 [43] 64-bit floating point numbers. Real numbers in the range ±10308 can be represented by an Erlang float.

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-eecient way of storing binary data. Erlang primitives exist for composing and decomposing binaries and for eecient input/output of binaries. For a full treatment of binaries see [34].

Pids — Pid is short for Process Identifier—a Pid is created by the Er- lang primitive spawn(...) Pids are references to Erlang processes.

Ports — ports are used to communicate with the external world. Ports are created with the BIF3 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.4 Funs are created by expressions of the form: fun(...) -> ... end.

 Two compound data types:

Tuples — tuples are containers for a fixed number of Erlang data types. The syntax {D1,D2,...,Dn} denotes a tuple whose argu- ments are D1, D2, ... Dn. The arguments can be primitive data types or compound data types. The elements 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.

Strings — strings are written as doubly quoted lists of characters, this is syntactic sugar for a list of the integer ASCII codes for the characters in the string, thus for example, the string "cat" is short- hand for [97,99,116].

Records — records provide a convenient way for associating a tag with each of the elements in a tuple. This allows us 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.

Use Erlang if you want your application to:

handle very large number of concurrent activities

be easily distributable over a network of computers

be fault-tolerant to both software & hardware errors

scale with the number of machines on the network

be upgradable & reconfigurable without having to stop & restart

be responsive to users within certain strict timeframes

stay in continuous operation for many years


Features of Erlang:-

Free & open-source. Erlang is distributed under a permissive open-source license and is free to use for any open-source, freeware, or commercial projects.

Cross-platform. Erlang runs on Linux, FreeBSD, Windows, Solaris, Mac OS X, and even embedded platforms such as VxWorks.

Well-supported. A dedicated team of engineers is employed by Ericsson to work on Erlang. Commercial support & services are available from Erlang Solutions and a number of other companies. There is also a responsive community around the world, centered around the Erlang Mailing List & IRC (#erlang on Freenode).

Plays well with the outside world. Integration with existing Java, .NET, C, Python, or Ruby code is straightforward. There is an interface to the underlying OS should you need one. Solid libraries to work with XML, JSON, ASN.1, CORBA etc are also available.

HiPE. The High-Performance Erlang Compiler can compile Erlang to native code on Windows, Linux, and Mac OS X and comes with the standard Erlang distribution.

Static typing, when you need it. You can annotate your code with type information & use Dialyzer, a powerful type checker, to ensure the correctness of your code and gain performance. Dialyzer comes bundled with Erlang, and also supports gradual typing to give you maximum flexibility.

Bit syntax. Another feature unique to Erlang that makes working with binary data a breeze. Writing programs such as binary file readers or network protocol parsers is easier in Erlang than in any other language. Erlang code that uses the binary syntax is compiled into very efficient machine code, often beating hand-written C code in performance.


Leave Comment

Comments

Liked By