Everyone is excited about Elixir, the programming language built on top of Erlang that shares the same abstractions as Erlang but is inspired by Ruby and it's developer friendliness.
I've been thinking for a while about giving it a try. However, since it's most important features are related with concurrency and that's the reason Erlang was created to begin with, I thought it would be better to start with Erlang.
Here I put together some of my notes about the language, although to really get it into my system I have to find a fun project to build with it. Preferably a project that needs concurrency!
sudo apt install erlang sudo apt install erlang-base
It comes with a linter. If you are using atom, there is a
language-erlang plugin for syntax highlighting and a
Erlang also comes with a shell prompt that you start like this:
erl Erlang (BEAM) emulator version 220.127.116.11 Eshell V18.104.22.168 (abort with ^G) 1>
It says to press Ctrl + G to exit, but the only way I could achieve it is by hitting Ctrl + C and then a for "abort".
Just like in a SQL shells you often have to finish everything with a
; end all sentences with a dot, and if you have several lines in a function, each finishes with a comma and the last one with a dot, as if it was a sentence in English. It does throw an error, just silently returns the prompt.
Erlang code is compiled to bytecode so it can be used by the VM:
erlc -v filename.erl
this will generate
filename.beam. Now you can run it inside the erl bash:
erl 1> filename:function(argument)
I couldn't find any official Erlang version managers, but this Github repository created in 2012 seems to still be maintained. Not sure if this is what Erlang people use though.
Apparently it looks like it also comes with a testing framework, EUnit.
Finally, the gitignore site has an Erlang specific gitignore file to use in your projects.
There is a learn X in Y minutes dedicated page for Erlang.
BIFs are functions that are built into Erlang to do tasks that are impossible to program in Erlang.
In Erlang functions should always return something, if you are not, then Erlang will return the atom
Also, the last logical expression of a function to be executed will be returned to the caller automatically, like in Ruby and other imperative languages. Comments are marked with a
% symbol, like in LaTeX. Function notation is
It's a best practice to not use
import for external modules and rather make the dependency explicit by using
io:format(foo), for example.
Module name and file name have to be the same, extension is
There are function declarations made up of function clauses, which are separated by
; rather than using
greet(male, Name) -> io:format("Hello, Mr. ~s!", [Name]); greet(female, Name) -> io:format("Hello, Miss. ~s!", [Name]); greet(_, Name) -> io:format("Hello, ~s!", [Name]).