Stefan Wintermeyer
February 20, 2017
110

# Elixir Mini Introduction for Zürich Meetup

## Stefan Wintermeyer

February 20, 2017

## Transcript

1. Elixir
Stefan Wintermeyer
@wintermeyer

2. Elixir is a functional, concurrent,
general-purpose programming
language that runs on the Erlang
virtual machine (BEAM).
https://en.wikipedia.org/wiki/Elixir_(programming_language)

3. defmodule ModuleName do
def hello do
IO.puts "Hello World"
end
end
http://elixir-lang.org/crash-course.html

4. IEx
Elixir’s interactive shell

5. Why would I want to
learn Elixir?
Why invest the time and effort? I’m happy with Ruby and OO.

6. Three Main Reasons
Spoiler Alert: Concurrency is not one of them.

7. 1. Speed
Elixir runs circles around Ruby and Python.

8. 2. Stability
Speed is nothing without stability.

9. 3. Hot-Code Upgrades
Zero Downtime!

10. Some Code Examples

11. Assigning Values to
Variables

12. iex(1)> a = 1
1
iex(2)>

13. iex(1)> a = 1
1
iex(2)> a = 2
2
iex(3)>

14. iex(1)> a = 1
1
iex(2)> a = 2
2
iex(3)> ^a = 3
** (MatchError) no match of right hand
side value: 3

15. Tuples

16. iex(1)> {a, b, c} = {10, 20, 30}
{10, 20, 30}
iex(2)>

17. iex(1)> {a, b, c} = {10, 20, 30}
{10, 20, 30}
iex(2)> a
10
iex(3)>

18. Pattern Matching

19. iex(1)> {a, b, c} = {10, 20, 30}
{10, 20, 30}
iex(2)>

20. iex(1)> {a, b, c} = {10, 20, 30}
{10, 20, 30}
iex(2)> {a, 20, c} = {10, 20, 30}
{10, 20, 30}
iex(3)>

21. iex(1)> {a, b, c} = {10, 20, 30}
{10, 20, 30}
iex(2)> {a, 20, c} = {10, 20, 30}
{10, 20, 30}
iex(3)> {a, 1, c} = {10, 20, 30}
** (MatchError) no match of right hand
side value: {10, 20, 30}

22. If you want to get your
feed wet with Elixir I
recommend two projects.

23. If you like hardware try
http://nerves-project.org

24. If you like the web try
www.phoenixframework.org

25. Phoenix Framework
Productive. Reliable. Fast.
Phoenix != Rails

26. mix phoenix.new blog
Y
cd blog
vim config/dev.exs
brew install postgres
brew services start postgres
createuser -W --createdb blog
demo
mix ecto.create
mix phoenix.gen.html Post posts subject body
vim web/router.ex
resources "/posts", PostController
mix ecto.migrate
mix phoenix.server
Blog Example

27. Thank you!
@wintermeyer