DEV Community

Tzelon Machluf
Tzelon Machluf

Posted on

2

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay