Erlang Dev Environment Setup
Introduction
Developed at Ericsson, Erlang is one of the oldest general purpose language still used in prodction system. This post is just notes about setting up a development environment for erlang projects.
Sample code here
Install Erlang
Windows
Download exe and install :https://www.erlang.org/downloads
Ubuntu
sudo apt-get install erlang
Install rebar3
https://github.com/erlang/rebar3
run bootstrap script (post installing erlang). Make sure erl and rebar3 are in path
Install VS code plugin for erlang
https://marketplace.visualstudio.com/items?itemName=pgourlain.erlang
Create first script project
rebar3 new escript <project-name>
First Code
In main file of created project (usually src\erapp.erl) ) add following line in main function
io:fwrite("hello, world\n"),
Build
rebar3 escriptize
Run
_build/default/bin/erapp
Running Single File
- Write Code
- Open Shell
- Go To code dir
- Start Erlang shell :
erl - Compile code :
c(modulename). - Run code :
modulename:func(). - Exit :
halt().
Running Single FIle (no shell)
erlc filename.erl
erl -noshell -s modulename func 