Ubuntu

How to Install and Run the Erlang Programming Language in Ubuntu 20.04

How to Install and Run the Erlang Programming Language in Ubuntu 20.04

Introduction

Erlang is a concurrent programming language with a garbage-collected runtime environment designed for concurrency, fault tolerance, and distributed application architectures. Concurrent processes are used to structure Erlang applications. These processes communicate asynchronously by exchanging messages and do not share memory. Erlang processes are small and belong to the language rather than the operating system.Ericsson’s OTP product unit is responsible for its support and maintenance.

Erlang is a programming language for building Massively scalable soft real-time systems with high availability requirements.Telecoms,banking,E-commerce,Computer Telephone and instant messaging are few examples of the applications.

1.Installation using repository

1. Adding repository entry

Using the wget command, pulling all the packages of the Erlang solution and adding the Erlang Solution repository to the system.

[email protected]:~$ wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
[email protected]:~$ sudo dpkg -i erlang-solutions_2.0_all.deb

2.Installing Erlang

Update the system with the latest release packages by a given command.

[email protected]:~$ sudo apt-get update

Now, install the erlang packages using apt-get install command

[email protected]:~$ sudo apt-get install erlang

After installing the packages the question pops up whether you want to proceed or not for further installation. Type y for further installation.

Login to Ergan shell to check the installation process is successful.

[email protected]:~$ erl

2.File created for testing Erlang

vim command is used to open the file for editing the information.

[email protected]:~$ vim hello.erl

Following steps are added to the file created in the name of hello.erl to execute the erlang programming code.

% Test of Erlang Code

-module(hello).

-import(io,[fwrite/1]).

-export([helloworld/0]).

helloworld() ->

        fwrite("Linuxways says hi!\n").

Now,login to the Erlang shell to test the file created and execute the given code to check if the programming is running.(Do not forget to use the full stop sign (.) at the end). 

[email protected]:~$ erl
1>  c(hello).

2> hello:helloworld().

Another program is also tested for better understanding.

[email protected]:~$ vim output.erl
-module(output).

-export([double/1,mult/2]).

mult(X,Y) ->

X*Y.

double(X) ->

mult(2,X)

Now,login to the Erlang shell to test the file created and execute the given code to check if the program is running.

[email protected]:~$ erl
1> c(output).

2> output:double(20).

3> output:mult(5,10).

 The Erlang programming language is successfully installed and tested in the Linux system.

3.Conclusion

The above given command and its example is for the installation of Erlang Programming language on Ubuntu 20.04 .Thank you for checking it out!

Similar Posts