What is Erlang and where it runs

What Erlang is

Erlang is a dynamic functional language created by Joe Armstrong, Robert Virding, and Mike Williams at Ericsson in the 1980s. You write plain text files, and the Erlang runtime runs them with no manual memory management.

Everything in Erlang is a term, and terms flow through the system as messages. Data never changes in place: functions take values in and return new values out, which makes programs easier to test and to reason about line by line.

erl

1> io:format("Hello from Erlang~n").
Hello from Erlang
ok
2> 2 + 2.
4

Where Erlang runs

Erlang runs on Linux, macOS, and Windows, so one script can travel between machines with almost no changes. Developers use it for messaging backends, chat servers, telecom gear, and databases.

The language and its virtual machine, called BEAM, are packaged together as OTP, the Open Telecom Platform. A running Erlang program is a forest of tiny processes that talk by messages.

Ask the runtime which OTP release it is:

erl

1> erlang:system_info(otp_release).
"27"

Why learn Erlang

Erlang teaches habits that transfer to other languages: immutable data, small functions, and failures that stay local. The error messages point at the exact line that needs attention.

Ruby also teaches habits that transfer to other languages: objects, methods, blocks, and tests. Many teams still build products with Ruby on Rails, while others use plain Ruby for scripts and DevOps tasks.

Born at Ericsson

Ericsson needed switches that survived software bugs without a reboot, so the language grew three rules: never share state, let processes fail alone, and restart the broken part only.

Matz designed Ruby for programmer happiness, and the community motto says it well: Matz is nice and so we are nice. Code should surprise you as little as possible and read from top to bottom with ease.

Next: Install Erlang and check the version

Questions

A new set of questions in a new order every time. Choose one answer for each, then check.

  1. Which company created Erlang?

    Answer

    Ericsson

    Erlang grew out of Ericsson's need for telephone switches that survive software bugs without a reboot.

  2. What is BEAM?

    Answer

    The virtual machine that runs Erlang programs

    BEAM is the virtual machine in the Erlang runtime: it loads the compiled code and runs the processes.

  3. What does OTP stand for?

    Answer

    Open Telecom Platform

    OTP, the Open Telecom Platform, is Erlang plus its standard libraries and design patterns.

  4. What is a term in Erlang?

    Answer

    Any piece of data the program works with

    Numbers, atoms, lists, tuples, maps and functions are all terms: the language has one data universe.

  5. What does 2 + 2. return in the shell?

    Answer

    4

    The shell evaluates the expression and prints its value, which is the number 4.

  6. What does io:format("Hello from Erlang~n"). print?

    Answer

    Hello from Erlang

    ~n is a newline in the format string, so the text is printed and the function returns ok.

  7. What does erlang:system_info(otp_release). return on this course?

    Answer

    The string "27"

    The function returns the release as a string, so the shell prints it with the quotes: "27".

  8. How do two Erlang processes share state?

    Answer

    They do not: they send each other messages

    Processes share nothing; a message is copied to the receiver, so no two processes write the same value.

  9. Which rule did Ericsson's switches need from the language?

    Answer

    Let the broken process fail alone and restart only it

    A failure stays inside its process, and a supervisor restarts that process while the rest of the system keeps running.

  10. On which systems does Erlang run?

    Answer

    Linux, macOS, and Windows

    OTP ships for the three desktop systems and for several embedded targets, and a program moves between them with few changes.

The examples on this page were run with Erlang/OTP 27 (erts-15.2.7.14) on Alpine Linux 3.24.3 (x86_64) in a Docker container.

Article author: Arthur Isaev

Banner image