Compiling a Module
Learn how to define a module and organize functions inside it.
Compiling in Elixir
Elixir always compiles and always executes source code. Both elixir
and elixirc
do both things. In addition to the Elixir file extension .ex
, Elixir also supports .exs
files for scripting. Elixir treats both files exactly the same way; the only difference is in the objective. The .ex
files are meant to be compiled while .exs
files are used for scripting. When executed, both extensions compile and load their modules into memory, although only .ex
files write their bytecode to disk in the format of .beam
files.
Once a program grows beyond a couple of lines, we want to structure it. Elixir makes this easy. We break our code into named functions and organize these functions into ...