Processes, Modules, and Compilation

Erlang programs are built from a number of parallel processes. Processes evaluate functions that are defined in modules. Modules are files with the extension .erl and must be compiled before they can be run. Having compiled a module, we can evaluate the functions in the module from the shell or directly from the command line in an operating system environment.

In the next sections, we’ll look at compiling modules and evaluating functions in the shell and from the OS command line.

Compiling and Running “Hello World” in the Shell

Make a file called hello.erl with the following content:

hello.erl
 
-module​(hello).
 
-export​([start/0]).
 
 
start() ->
 
io:format(​"Hello world~n"​).

To compile and run this, ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.