Getting started with Erlang programming on FreeBSD
Erlang is a functional programming language invented at Ericsson built to be highly scalable, high available, fault taulerant and it allows you to change code modules at runtime. FreeBSD's stability and Erlang's robustness make a perfect team.
Erlang is gaining more and more popularity due to it's robustness and fault tolerancy. When Facebook baught WhatsApp in Jan 2014, it came to public attention that WhatsApp is built on FreeBSD and Erlang technology that can handles 1.000.000 simulatneous connection with only one server.
Software built on Erlang
Prominent software that is built on Erlang includes
- Apache CouchDB, a JSON database
- ejabberd, a massively scalable XMPP server,
- RabbitMQ, a robust message queue,
- Riak, a linear scalable NoSQL key-value storage,
- WhatsApp, the most successful instant messenger
Erlang on FreeBSD
Typically for FreeBSD, you install software through a port or package. I'll assume you to install the package by running
pkg install erlang which installs you Erlang/OTP 18.2.x. OTP stands for Open Telecom Platform and is a set of components that make Erlang so great. When I write about Erlang, I really mean Erlang/OTP.
First steps with the interpreter
You start the Erlang interpreter by starting
erl. A shell starts and waits for your input. You can quit it by typing
q(). The dot is importing because it marks the end of your input and Erlang begins to execute your code.
Display code paths
# erl Erlang R16B03-1 (erts-5.10.4) [source] [async-threads:10] [hipe] [kernel-poll:false] Eshell V5.10.4 (abort with ^G) 1> code:get_path(). [".","/usr/local/lib/erlang/lib/kernel-2.16.4/ebin", "/usr/local/lib/erlang/lib/stdlib-1.19.4/ebin", "/usr/local/lib/erlang/lib/xmerl-1.3.6/ebin", "/usr/local/lib/erlang/lib/wx-1.1.2/ebin", "/usr/local/lib/erlang/lib/webtool-0.8.9.2/ebin", "/usr/local/lib/erlang/lib/typer-0.9.5/ebin", "/usr/local/lib/erlang/lib/tv-184.108.40.206/ebin", "/usr/local/lib/erlang/lib/tools-2.6.13/ebin", "/usr/local/lib/erlang/lib/toolbar-220.127.116.11/ebin", "/usr/local/lib/erlang/lib/test_server-3.6.4/ebin", "/usr/local/lib/erlang/lib/syntax_tools-1.6.13/ebin", "/usr/local/lib/erlang/lib/ssl-5.3.3/ebin", "/usr/local/lib/erlang/lib/ssh-3.0/ebin", "/usr/local/lib/erlang/lib/snmp-4.25/ebin", "/usr/local/lib/erlang/lib/sasl-2.3.4/ebin", "/usr/local/lib/erlang/lib/runtime_tools-1.8.13/ebin", "/usr/local/lib/erlang/lib/reltool-0.6.4.1/ebin", "/usr/local/lib/erlang/lib/public_key-0.21/ebin", "/usr/local/lib/erlang/lib/pman-18.104.22.168/ebin", "/usr/local/lib/erlang/lib/percept-0.8.8.2/ebin", "/usr/local/lib/erlang/lib/parsetools-2.0.10/ebin", "/usr/local/lib/erlang/lib/otp_mibs-1.0.8/ebin", "/usr/local/lib/erlang/lib/os_mon-2.2.14/ebin", "/usr/local/lib/erlang/lib/orber-22.214.171.124/ebin", "/usr/local/lib/erlang/lib/observer-126.96.36.199/ebin", "/usr/local/lib/erlang/lib/mnesia-4.11/ebin", [...]|...] 2>
Further links to Erlang programming
A very good resource for Erlang programming is Learn You Some Erlang for Great Good!