1 Introduction


In this tutorial we are going to get you started with Elixir. This chapter will focus on ensuring Elixir is installed and that you can sucessfully run Elixir's Interactive Shell, called IEx.

Our requirements are:

  • Erlang - Version 17.0 onwards
  • Elixir - Version 1.0.0 onwards

Let's get started!

If you find any errors in the tutorial or on the website, please report a bug or send a pull request to our issue tracker. If you suspect it is a language bug, please let us know in the language issue tracker.

1.1 Installation

If you still haven't installed Elixir, run to our installation page. Once you are done, you can run elixir -v to get the current Elixir version.

1.2 Interactive mode

When you install Elixir, you will have three new executables: iex, elixir and elixirc. If you compiled Elixir from source or are using a packaged version, you can find these inside the bin directory.

For now, let's start by running iex (or iex.bat if you are on Windows) which stands for Interactive Elixir. In interactive mode, we can type any Elixir expression and get its result. Let's warm up with some basic expressions:

Interactive Elixir - press Ctrl+C to exit (type h() ENTER for help)

iex> 40 + 2
iex> "hello" <> " world"
"hello world"

It seems we are ready to go! We will use the interactive shell quite a lot in the next chapters to get a bit more familiar with the language constructs and basic types, starting in the next chapter.

1.3 Running scripts

After getting familiar with the basics of the language you may want to try writing simple programs. This can be accomplished by putting Elixir code into a file and executing it with elixir:

$ cat simple.exs
IO.puts "Hello world
from Elixir"

$ elixir simple.exs
Hello world
from Elixir

Later on we will learn how to compile Elixir code (in Chapter 8) and how to use the Mix build tool (in the Mix & OTP guide). For now, let's move on to Chapter 2.