How to install Erlang programming language on Ubuntu 20.04 LTS

How To Install Erlang On Ubuntu 20.04 LTS

On this tutorial we will discuss how to install Erlang version 23.x on Linux Ubuntu 20.04 LTS.

Introduction

From Erlang’s official website, we can get information if 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.

OTP is set of Erlang libraries and design principles providing middle-ware to develop these systems. It includes its own distributed database, applications to interface towards other languages, debugging and release handling tools. In short, OTP is a collection of libraries and middleware for Erlang.

On this article we will guide you through Erlang installation on Ubuntu 20.04 LTS. The article will be divided into several sub sections, as follow :

  1. Import Erlang GPG Key and Adding Repository
  2. Install Erlang on Ubuntu
  3. Test Erlang with Hello World Program



Import Erlang GPG key And Adding Repository

The first step is to add Erlang APT repository to our Ubuntu system. We will download Erlang repository package from its official website and install on our system. For this purpose we just submit the command : wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add - and echo "deb https://packages.erlang-solutions.com/ubuntu focal contrib" | sudo tee /etc/apt/sources.list.d/rabbitmq.list

The screen shot is as shown below :

ramans@otodiginet:~$ wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add -
--2020-12-03 20:23:13-- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
Resolving packages.erlang-solutions.com (packages.erlang-solutions.com)… 13.32.168.77
Connecting to packages.erlang-solutions.com (packages.erlang-solutions.com)|13.32.168.77|: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
2020-12-03 20:23:33 (9.98 MB/s) - written to stdout [3133/3133]
OK

Adding Erlang Repository :

ramans@otodiginet:~$ echo "deb https://packages.erlang-solutions.com/ubuntu focal contrib" | sudo tee /etc/apt/sources.list.d/rabbitmq.list
deb https://packages.erlang-solutions.com/ubuntu focal contrib
Add Erlang Repository

Install Erlang On Ubuntu

After adding Erlang respository was done, the next step is to install it. it is better if we update the system first. The installation process is a simple task, just submit the command line : sudo apt update and sudo apt install erlang.

ramans@otodiginet:~$ sudo apt update
ramans@otodiginet:~$ sudo apt install erlang
[sudo] password for ramans:
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
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-examples erlang-ftp
erlang-gs erlang-ic erlang-ic-java erlang-inets erlang-inviso erlang-jinterface erlang-megaco erlang-mnesia
erlang-mode erlang-observer erlang-odbc erlang-os-mon erlang-parsetools erlang-percept erlang-pman
erlang-public-key erlang-reltool erlang-runtime-tools erlang-snmp erlang-src erlang-ssh erlang-ssl
erlang-syntax-tools erlang-test-server erlang-tftp erlang-toolbar erlang-tools erlang-tv erlang-typer erlang-wx
erlang-xmerl libodbc1 libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 tcl tcl8.6 tk tk8.6
Suggested packages:
erlang-manpages erlang-doc xsltproc fop libmyodbc odbc-postgresql tdsodbc unixodbc-bin tcl-tclreadline
The following NEW packages will be installed:
erlang 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-examples
erlang-ftp erlang-gs erlang-ic erlang-ic-java erlang-inets erlang-inviso erlang-jinterface erlang-megaco
erlang-mnesia erlang-mode erlang-observer erlang-odbc erlang-os-mon erlang-parsetools erlang-percept erlang-pman
erlang-public-key erlang-reltool erlang-runtime-tools erlang-snmp erlang-src erlang-ssh erlang-ssl
erlang-syntax-tools erlang-test-server erlang-tftp erlang-toolbar erlang-tools erlang-tv erlang-typer erlang-wx
erlang-xmerl libodbc1 libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 tcl tcl8.6 tk tk8.6
0 upgraded, 55 newly installed, 0 to remove and 356 not upgraded.
Need to get 44.5 MB/45.5 MB of archives.
After this operation, 133 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Erlang installation on Ubuntu

The installation was completed done, to verify it, we have to use the Shell Erlang, by submitting command line : erl.

ramans@otodiginet:~$ erl
Erlang/OTP 23 [erts-11.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]
Eshell V11.1 (abort with ^G)

It show if the Erlang that has been installed on the system has version 23.x (the latest stable version).

Test Erlang with Hello World Program

On this section we will show you how to use the Erlang shell by doing simple mathematics operator and creating a simple Erlang script which showng “Hello World” text. For this purpose, just follow the steps below :

  • Mathematics operator example
ramans@otodiginet:~$ erl
Erlang/OTP 23 [erts-11.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]
Eshell V11.1 (abort with ^G)
1> 4 + 8.
12
2> (42 + 77) * 66 / 3.
2618.0
3> (4 + 3) * 4 / 4.
7.0
4>
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
(l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
a
Erlang shell example
Erkang Examples
  • Hello World

The ‘Hello World’ application program is done by creating an erlang file called as hellotest01.erl. Then fill it with a simple script, as shown below :

ramans@otodiginet:~$ vi hellotest01.erl
 % Test to display Hello World Erlang Code
-module(hellotest01).
-import(io,[fwrite/1]).
-export([helloworld/0]).
helloworld() ->
fwrite("Hai Guys.. , Erlang World!\n").
ramans@otodiginet:~$ erl
Erlang/OTP 23 [erts-11.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]
Eshell V11.1 (abort with ^G)
1> c(hellotest01).
{ok,hellotest01}
2> hellotest01,helloworld().
** exception error: undefined shell command helloworld/0
3> hellotest01:helloworld().
Hai Guys.. , Erlang World!
ok
Erlang test

Conclusion

On this article, we have tried to install Erlang on Ubuntu 20.04 LTS. To deep dive Erlang programming language, we could go to its documentation on https://www.erlang.org/docs.

Share this article via :

One thought on “How To Install Erlang On Ubuntu 20.04 LTS

Leave a Reply

Your email address will not be published. Required fields are marked *