Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Why Elixir? (Intro to Elixir)
Search
Ventsislav Nikolov
May 22, 2017
Technology
180
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Why Elixir? (Intro to Elixir)
A brief introduction of Elixir. Level: beginners.
Ventsislav Nikolov
May 22, 2017
More Decks by Ventsislav Nikolov
See All by Ventsislav Nikolov
Building Multiplayer Real-Time Game with Elixir and Phoenix
ventsislaf
4
2.6k
Other Decks in Technology
See All in Technology
DatadogのBits Chatが開発組織にもたらしたもの / What Bits Chat Has Brought Us
sms_tech
1
180
MIRU 2026 チュートリアル
keisuke198619
0
880
JavaScript 研修 (2026)
recruitengineers
PRO
2
500
Digitization部 紹介資料
sansan33
PRO
2
7.7k
変化の早いClaude Codeを 書籍に落とし込む
oikon48
7
1.4k
Cursor Meetup Sapporo - Cursor物語 続編
cocacola917
0
150
Software Supply Chain Attackからクラウド環境を守るためにできること
lhazy
2
240
今こそ聞きたいソフトウェア設計 ドメイン駆動設計再入門
masuda220
PRO
17
7k
FDEの心得
noriakioji
1
1.1k
AIエージェントを前提としたプラットフォーム エンジニアリング:GKEで作るAgent-Ready Golden Path
legalontechnologies
PRO
2
220
メルカリのグローバルアプリで挑んだ AlloyDB 運用と課題解決の実践記
hatappi
0
240
[ChatGPT Work LT]事務作業が苦手な人のための バックオフィスの「半」自動化
chimaki_iot
0
270
Featured
See All Featured
Speed Design
sergeychernyshev
33
2k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Marketing to machines
jonoalderson
1
5.7k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
A better future with KSS
kneath
240
18k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
480
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
270
Designing Experiences People Love
moore
143
24k
Transcript
WHY ELIXIR? Elixir Sofia Meetup May 2017
WHY ELIXIR? INTRO TO ELIXIR
Ventsislav Nikolov @ventsislaf
DISCLAIMER NO GIFs
None
WHAT IS ELIXIR?
• functional programming language • compiles to erlang bytecode •
immutable data • dynamically typed • concurrency, distribution, fault tolerance • hot code swapping
DATA TYPES (NOT ALL) 1_000_000 # Integer 314159.0e-5 # Float
:apple # Atom "Jon Snow" # String {:error, 404} # Tuple [1, 2, 3] # (Linked) List %{name: "Jon", age: 21} # Map
MODULES AND FUNCTIONS
ANONYMOUS FUNCTIONS add = fn(a, b) -> a + b
end add.(2, 5) # => 7
MODULES defmodule Math do def add(a, b) do a +
b end defp multiply(a, b) do a * b end end # warning: function multiply/2 is unused Math.add(2, 5) # => 7 Math.multiply(2, 5) # ** (UndefinedFunctionError) function Math.multiply/2 is undefined or private
IMMUTABILITY
colors = ["green", "apple", "red"] List.delete(colors, "apple") # => ["green",
"red"] colors # => ["green", "apple", "red"]
PATTERN MATCHING
= x = 1 # => 1 1 = x
# => 1 2 = x # ** (MatchError) no match of right hand side value: 1 x = 2 # => 2
DECOMPOSITION [x, y] = [1, 2] # x => 1,
y => 2 [1, x] = [1, 2] # x => 2 [_, x] = [1, 2] # x => 2 [head | tail] = [1, 2, 3] # head => 1, tail => [2, 3] %{name: name} = %{name: "Jon Snow", age: 21} # name => "Jon Snow"
RECURSION
def sum([]) do 0 end def sum([head | tail]) do
head + sum(tail) end
PIPE OPERATOR
Enum.sort(String.codepoints(String.downcase(word)))
lowercase = String.downcase(word) chars = String.codepoints(lowercase) ordered = Enum.sort(chars)
word |> String.downcase() |> String.codepoints() |> Enum.sort()
Elixir + Erlang = ❤
# Erlang rand:uniform(10). # Elixir :rand.uniform(10)
CONCURRENCY
PROCESSES (not OS) spawn fn -> IO.puts "Hello from another
process" end
LIGHTWEIGHT • created for couple of microseconds • 1-2 KB
initial memory footprint • up to hundreds of millions processes per VM
ISOLATION name = "Jon Snow" spawn fn -> IO.puts "Hello,
#{name}" end
MESSAGES pid = spawn fn -> receive do msg ->
IO.puts "received a message: #{msg}" end end send pid, "You know nothing, Jon Snow."
msg 1 msg 2 msg 3 mailbox
FAULT TOLERANCE
:one_for_one :one_for_all
DISTRIBUTION
None
$ iex --name one@host $ iex --name two@host $ iex
--name three@host # in node one iex> Node.connect :two@host iex> Node.connect :three@host iex> Node.list # => [:two@host, :three@host] # in node two iex> Node.list # => [:one@host, :three@host] iex> Node.spawn :three@host, fn -> IO.puts("hello") end
TOOLING
IEx (demo) $ iex iex> 2 + 5 7
MIX mix new app_name mix compile mix test mix deps.get
mix hex.publish
OBSERVER :observer.start
None
WHERE TO GO NEXT?
None
None
None
None
THANK YOU!