You are on page 1of 3

3/8/2016

Introduction - Elixir

HOME

INSTALL

GETTING STARTED

LEARNING

DOCS

BLOG

PACKAGES

Introduction

News: Elixir v1.2 released


Search...

1 Installation
2 Interactive mode
3 Running scripts
4 Asking questions

G ETTI N G ST A RTED

1. Introduction
2. Basic types

Welcome!

3. Basic operators
4. Pattern matching

In this tutorial we are going to teach you the Elixir foundation, the language
syntax, how to define modules, how to manipulate the characteristics of
common data structures and more. This chapter will focus on ensuring Elixir is
installed and that you can successfully run Elixirs Interactive Shell, called IEx.

5. case, cond and if


6. Binaries, strings and char
lists
7. Keywords and maps

Our requirements are:

8. Modules
9. Recursion

Elixir - Version 1.2.0 onwards


Erlang - Version 18.0 onwards
Lets get started!

10. Enumerables and streams


11. Processes
12. IO and the file system
13. alias, require and import

Ifyoufindanyerrorsinthetutorialoronthewebsite,please
reportabugorsendapullrequesttoourissuetracker.

14. Module attributes


15. Structs
16. Protocols

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

17. Comprehensions
18. Sigils
19. try, catch and rescue
20. Typespecs and behaviours
21. Erlang libraries

Interactive mode
When you install Elixir, you will have three new executables: iex, elixir and

22. Where to go next

M IX A N D OTP

elixirc. If you compiled Elixir from source or are using a packaged version,

you can find these inside the bin directory.

1. Introduction to Mix
2. Agent

http://elixir-lang.org/getting-started/introduction.html

1/3

3/8/2016

Introduction - Elixir

For now, lets 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. Lets warm up with some basic expressions.
Open up iex and type the following expressions:

3. GenServer
4. Supervisor and Application
5. ETS
6. Dependencies and umbrella
apps

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


help)
iex> 40 + 2
42

7. Task and gen-tcp


8. Docs, tests and with
9. Distributed tasks and
configuration

iex> "hello" <> " world"


"hello world"
M ETA -PROG RA M MI N G I N
EL IX I R

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. Quote and unquote


2. Macros
3. Domain Specific Languages

Note:ifyouareonWindows,youcanalsotry iex.bat --werl


whichmayprovideabetterexperiencedependingonwhich
consoleyouareusing.

S PON SORS

Running scripts
After getting familiar with the basics of the language you may want to try

EL IX I R RA D AR

writing simple programs. This can be accomplished by putting the following

A weekly Elixir email newsletter

Elixir code into a file:

with content curated by


Plataformatec. Subscribe

IO.puts "Hello world from Elixir"

Save it as simple.exs and execute it with elixir:

below.

Elixir
Radar
weekly

$ elixir simple.exs

Subscribe
now

newsletter

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, lets move on to Chapter
2.

Asking questions
http://elixir-lang.org/getting-started/introduction.html

2/3

3/8/2016

Introduction - Elixir

When going through this getting started guide, it is common to have questions,
after all, that is part of the learning process! There are many places you could
ask them to learn more about Elixir. The official places are:
#elixir-lang on freenode IRC
elixir-talk mailing list
However there are many places operated by the community, such as:
Elixir on Slack
elixir tag on StackOverflow
Elixir Forum
When asking questions, remember these two tips:
Instead of asking how to do X in Elixir, ask how to solve Y in Elixir. In
other words, dont ask how to implement a particular solution, instead
describe the problem at hand. Stating the problem gives more context
and less bias for a correct answer.

In case things are not working as expected, please include as much


information as you can in your report, for example: your Elixir version,
the code snippet and the error message alongside the error stacktrace.
Use sites like Gist to paste this information.
Top

Next

2012-2016 Plataformatec. All rights reserved.

http://elixir-lang.org/getting-started/introduction.html

3/3

You might also like