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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Ventsislav Nikolov
May 22, 2017
Technology
170
2
Share
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.5k
Other Decks in Technology
See All in Technology
そのSLO 99.9%、本当に必要ですか? 〜優先度付きSLOによる責任共有の設計思想〜 / Is that 99.9% SLO really necessary? Design philosophy of shared responsibility through prioritized SLOs
vtryo
0
830
おいらのAWSアップデートの追い方〜Slack×AgentCore〜
yakumo
1
110
Purview Endpoint DLP 動かしてみた
kozakigh
1
440
PdM・Eng・QAで進めるAI駆動開発の現在地/aidd-with-pdm-eng-qa
shota_kusaba
0
250
"スキルファースト"で作る、AIの自走環境
subroh0508
0
610
Cortex(Code) を ML モデルの 精度改善サイクルに組み込む.pdf
oimo23
0
200
開発サイクルのボーダーレス化に伴う組織変革から学んだこと / Organizational Transformation Amid the Borderless Development Cycle
mii3king
0
230
AI飲み会幹事エージェントを作っただけなのに
ykimi
0
240
Gaussian Splattingの表現力を拡張する — 高周波再構成とインタラクションへのアプローチ —
gpuunite_official
0
190
freeeで運用しているAIQAについて
qatonchan
1
640
Loadbalancing exporter internals
ymotongpoo
1
110
GitHub Copilot CLI で考える複数エージェント設計
tomokusaba
0
110
Featured
See All Featured
It's Worth the Effort
3n
188
29k
4 Signs Your Business is Dying
shpigford
187
22k
Discover your Explorer Soul
emna__ayadi
2
1.1k
A Soul's Torment
seathinner
6
2.8k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
300
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
ラッコキーワード サービス紹介資料
rakko
1
3.3M
Designing Powerful Visuals for Engaging Learning
tmiket
1
370
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
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!