Learn the commands to install Erlang programming language on Ubuntu 20.04 LTS Focal fossa Linux and also an example to create Hello World program.
Erlang is an open-source programming language that is nowadays often used for (massively) parallel programming and distributed systems. However, the origins lie in applications in the field of telecommunications, the language was developed for and at Ericsson.
Their strength is the parallel processing of program logic, a very efficient and lightweight notification system for interprocess communication as well as pronounced fault tolerance. Furthermore, erlang makes it possible to replace or update modules at the runtime of the program without rebooting, whereby a high availability of the system is achieved.
There are not many applications in the desktop area that are based on this language. Some examples are the XMPP server, RabbitMQ server, the document-oriented database CouchDB, the web server Yaws, and application wings3d.
Erlang is a functional programming language. This means that a complete Erlang program consists exclusively of a series of functions and their calls. In contrast to imperative programming languages, there is no “schedule” of a program, but the flow is determined by functions, their return values, and events. Erlang manages almost without loops and assignments but increasingly relies on recursions. Erlang programs consist almost exclusively of modules that interact with each other. Each function is written into a module and nested in the modules together.
One of Erlang’s strengths is that you can easily change code at run time. So you don’t have to stop a server application to fix something or fix a bug, but you can simply replace the corresponding module at runtime. As a result, Erlang programs achieve high availability. Ericsson has estimated the availability of its Erlang systems at over 99% per year.
Estimated reading time: 5 minutes
The steps given here can be used for other versions of Ubuntu such as 22.04 or 18.04 including Debian 11 or Linux Mint.
Let’s install the latest available updates for Ubuntu 20.04 using the system’s default package manager APT.
Also, install common tools:
To install the packages from the official repository of Erlang, the system needs to verify the package we are getting are in the same state as they were released by its developers. For that GPG key is needed. Let’s add that:
Although we don’t need to add an additional repository to get the packages for installing Erlang on Ubuntu 20.04, however, the version will not be the latest. Therefore, to get the latest version of this programming language, here we are adding Erlang’s official repository, manually.
Run system update:
To rebuild the APT package index cache, run:
After adding the repository, we can download and install the latest version of Erlang on our Ubuntu 20.04 desktop or server system using the APT package manager. Here is the command to follow:
To test Erlang programs, to maintain, or just to play around with Erlang a bit, the Erlang shell is ideal. This is automatically installed with Erlang and can be installed from the terminal by the command
Let’s try to create a simple program. In most languages, the Hello World program is the first thing you write. This can also be done in Erlang, but it should be clear that this looks a bit complicated in Erlang, as Erlang has its strength in complexity and not in simple programs.
First, you create a file
hello.erl with the following content:
Create a file to write code:
Paste the following code:
Save the file using Ctrl+O, hit the Enter key, and Ctrl+X to exit the text editor.
Compile and run the created erlang program.
Switch to erlang shell:
Now, compile the program using:
Run the program:
You will have the output:
Hello World How2shout
To exit the ERLang Shell:
Ctrl+G and then type q and hit the Enter key.
In the future, if you want to completely remove Erlang from Ubuntu 20.04 completely, here is the command to do that:
⇒ How to Install RabbitMQ Server on Ubuntu 20.04 LTS
⇒ Install the latest R Programming Language version on Debian 11
⇒ Install Yandex Browser on Ubuntu 20.04 LTS Linux
⇒ How to Install SSH Server on Ubuntu 20.04 LTS
How to Install RabbitMQ Server on Ubuntu 20.04 LTS
Install Yandex Browser on Ubuntu 20.04 LTS Linux
How to Install SSH Server on Ubuntu 20.04 LTS
How to install CyberPanel on Ubuntu 20.04 LTS Server
How to Install Yandex Browser on Ubuntu 22.04 LTS
How to install PHP 7.4 on Ubuntu 22.04 LTS Jammy Linux
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Linux Shout was crafted as a part of our main portal H2S Media to publish Linux-related tutorials and open source Software.