Using an interactive shell (REPL)

Elixir:
Using an interactive shell (REPL)

How to:

To launch IEx, open your terminal and type iex. Here’s a taste:

iex> name = "Elixir Programmer"
"Elixir Programmer"
iex> String.length(name)
17
iex> Enum.map([1, 2, 3], fn num -> num * 3 end)
[3, 6, 9]

Output should show variable assignment, function results, and an anonymous function at work.

Deep Dive

The IEx shell has been a part of Elixir since its early days. José Valim, the creator of Elixir, drew inspiration from the interactive shells of other languages like Python’s python and Ruby’s irb. While IEx shares many features with these, it is built to handle Elixir’s concurrent nature and is fully integrated with the Erlang VM capabilities.

Alternatives to IEx in the Erlang ecosystem include erl, the Erlang shell. But IEx provides a more Elixir-friendly environment, with features like comprehensive tab completion, history, and helpers.

The IEx REPL is more than a playground; it can seamlessly connect to a running system. This is crucial for debugging live applications. The underlying implementation relies on the BEAM (the Erlang VM), ensuring features like hot code swapping are supported right in the shell.

See Also

Check these out for further reading and resources: