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
2
150
Why Elixir? (Intro to Elixir)
A brief introduction of Elixir. Level: beginners.
Ventsislav Nikolov
May 22, 2017
Tweet
Share
More Decks by Ventsislav Nikolov
See All by Ventsislav Nikolov
Building Multiplayer Real-Time Game with Elixir and Phoenix
ventsislaf
4
2.4k
Other Decks in Technology
See All in Technology
UIパフォーマンス最適化: AIを活用して100倍の速度向上を実現した事例
kinocoboy2
0
130
MCPを理解する
yudai00
14
10k
経済メディア編集部の実務に小さく刺さるAI / small-ai-with-editorial
nkzn
2
390
AOAI で AI アプリを開発する時にまず考えたいこと
mappie_kochi
1
690
SaaS公式MCPサーバーをリリースして得た学び
kawamataryo
4
1.1k
AIとSREで「今」できること
honmarkhunt
3
720
Gateway H2 モジュールで スマートホーム入門
minoruinachi
0
140
Global Azure2025(GitHub Copilot ハンズオン)
tomokusaba
2
760
データベース04: SQL (1/3) 単純質問 & 集約演算
trycycle
PRO
0
730
2025年8月から始まるAWS Lambda INITフェーズ課金/AWS Lambda INIT phase billing changes
quiver
1
1k
Previewでもここまで追える! Azure AI Foundryで始めるLLMトレース
tomodo_ysys
2
670
Асинхронная коммуникация в Go: от понятного к душному. Дима Некрасов, Otello, 2ГИС
lamodatech
0
2.1k
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
5
600
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.4k
How to Ace a Technical Interview
jacobian
276
23k
A Tale of Four Properties
chriscoyier
159
23k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.7k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
How to Think Like a Performance Engineer
csswizardry
23
1.6k
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!