8 C
Texas
angeloma
Senior Writer and partner

How to install Erlang on Ubuntu 20.04?

Hello, friends. Erlang is still popular these days. Therefore, it’s a good idea to learn how to install it on Ubuntu 20.04 in case you want to get started with this language.

What is Erlang?

The Erlang website tells us:

Erlang is a programming language used to build massively scalable soft real-time systems with requirements on high availability. Some of its uses are in telecoms, banking, e-commerce, computer telephony, and instant messaging. Erlang’s runtime system has built-in support for concurrency, distribution, and fault tolerance.

Erlang uses concurrent processes to structure the application. These processes do not share memory and communicate asynchronously by passing messages. Erlang processes are very lightweight and belong to the language itself, not to the operating system. That is why it is very present in telecommunications applications or even in social networks such as Twitter.

Install Erlang on Ubuntu 20.04

Erlang is not present in the Ubuntu 20.04 repositories although it is very easy to install. To do this, open a terminal from the main menu and make sure the operating system is fully updated.

- Advertisement -
sudo apt update
sudo apt upgrade

With this step, the system will be up to date.

As Erlang is not present in the official Ubuntu repositories it is necessary to resort to other methods. Fortunately, the Erlang development team provides us with a repository that we have to add to perform the installation.

So, first, download and add the GPG key from it.

wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add -
--2021-04-08 17:11:49--  https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
Resolving packages.erlang-solutions.com (packages.erlang-solutions.com)... 13.226.159.11, 13.226.159.86, 13.226.159.60, ...
Connecting to packages.erlang-solutions.com (packages.erlang-solutions.com)|13.226.159.11|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3133 (3.1K) [text/plain]
Saving to: ‘STDOUT’

-                                          100%[=====================================================================================>]   3.06K  --.-KB/s    in 0s      

2021-04-08 17:11:50 (453 MB/s) - written to stdout [3133/3133]

OK

Now you can add the repository to the system with the following command

echo "deb https://packages.erlang-solutions.com/ubuntu focal contrib" | sudo tee /etc/apt/sources.list.d/erlang.list

To apply this change, you have to refresh APT

sudo apt update

And finally, you can install Erlang

sudo apt install erlang
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  adwaita-icon-theme erlang-appmon erlang-asn1 erlang-base erlang-common-test erlang-crypto erlang-debugger erlang-dev erlang-dialyzer erlang-diameter erlang-edoc
  erlang-eldap erlang-erl-docgen erlang-et erlang-eunit erlang-ftp erlang-gs erlang-ic erlang-inets erlang-inviso erlang-megaco erlang-mnesia erlang-observer
  erlang-odbc erlang-os-mon erlang-parsetools erlang-percept erlang-pman erlang-public-key erlang-reltool erlang-runtime-tools erlang-snmp erlang-ssh erlang-ssl
  erlang-syntax-tools erlang-test-server erlang-tftp erlang-toolbar erlang-tools erlang-tv erlang-typer erlang-wx erlang-xmerl fontconfig fontconfig-config
  fonts-dejavu-core gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3
  libavahi-common-data libavahi-common3 libcairo-gobject2 libcairo2 libcolord2 libcups2 libdatrie1 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1
  libepoxy0 libfontconfig1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgl1 libgl1-mesa-dri libglapi-mesa libglu1-mesa libglvnd0 libglx-mesa0 libglx0 libgraphite2-3
  libgtk-3-0 libgtk-3-common libharfbuzz0b libice6 libjbig0 libjpeg-turbo8 libjpeg8 libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libllvm11 libnotify4 libodbc1
  libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpixman-1-0 librest-0.7-0 librsvg2-2 librsvg2-common libsensors-config libsensors5 libsm6
  libsoup-gnome2.4-1 libtcl8.6 libthai-data libthai0 libtiff5 libtk8.6 libvulkan1 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwebp6 libwxbase3.0-0v5
  libwxgtk3.0-gtk3-0v5 libx11-6 libx11-data libx11-xcb1 libxau6 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-render0 libxcb-shm0 libxcb-sync1
  libxcb-xfixes0 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon0 libxrandr2 libxrender1
  libxshmfence1 libxss1 libxxf86vm1 tcl tcl8.6 tk tk8.6 ubuntu-mono x11-common
Suggested packages:
  erlang-manpages erlang-doc xsltproc fop erlang-ic-java colord cups-common gvfs liblcms2-utils libmyodbc odbc-postgresql tdsodbc unixodbc-bin librsvg2-bin lm-sensors
  tcl-tclreadline
.
.
.

To check that everything has been successful, you can log in to the Erlang shell.

erl
Erlang/OTP 23 [erts-11.1.7] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1]

Eshell V11.1.7  (abort with ^G)
1> 

To exit the shell you can press the keys CTRL + C.

Creating a Hello World file to test Erlang

All of the above is meaningless if we don’t run a Hello World file which is the ultimate test of Erlang’s performance.

With a text editor, create a file called helloworld.erl.

nano helloworld.erl

And add the following

-module(helloworld).
	-export([hello_world/0]).

	hello_world() -> io:fwrite("hello, world from osradar.com\n").

Don’t forget to put . at the end of each line as I have copied it.

Save the changes and close the editor.

Now access the Erl shell again.

erl

And compile the file:

c(helloworld).

Then, run the function in the file.

helloworld:hello_world().
1.- Erlang on Ubuntu 20.04
1.- Erlang on Ubuntu 20.04

And with this, Erlang will be ready.

Conclusion

Erlang is an important language that for many people goes unnoticed but it is still very useful to dedicate some time to it. Installing it in a system as popular as Ubuntu is something quite simple and within everyone’s reach.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article