DEV Community

Tzelon Machluf
Tzelon Machluf

Posted on

Three Ways to Start an Elixir Program

The elixir command used to run a single Elixir source file.

> elixir source.ex

When you run this command two things happen:

  1. The file source.ex is compiled in-memory, and the resulting modules are loaded to the VM.
  2. Every code outside of a module is executed.

The mix tool

> mix run

When you want to run a project created by mix (mix new project_name)

iex Elixir's interactive shell.

> mix my_source_file.ex

When you want to load a module to the VM in interactive mode.
Note that code outside of the module will not be executed.

You can also use mix and run a project and load the interactive shell with iex -S mix run

Top comments (0)