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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Ventsislav Nikolov
May 22, 2017
Technology
2
160
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.5k
Other Decks in Technology
See All in Technology
8万デプロイ
iwamot
PRO
2
180
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.1k
マルチロールEMが実践する「組織のレジリエンス」を高めるための組織構造と人材配置戦略
coconala_engineer
3
590
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
11k
AWS DevOps Agent vs SRE俺 / AWS DevOps Agent vs me, the SRE
sms_tech
3
330
Datadog の RBAC のすべて
nulabinc
PRO
2
310
EMからICへ、二周目人材としてAI全振りのプロダクト開発で見つけた武器
yug1224
5
470
us-east-1 に障害が起きた時に、 ap-northeast-1 にどんな影響があるか 説明できるようになろう!
miu_crescent
PRO
12
3.8k
元エンジニアPdM、IDEが恋しすぎてCursorに全業務を集約したら、スライド作成まで爆速になった話
doiko123
1
450
Claude Cowork Plugins を読む - Skills駆動型業務エージェント設計の実像と構造
knishioka
0
290
Kaggleの経験が実務にどう活きているか / kaggle_findy
sansan_randd
6
1k
類似画像検索モデルの開発ノウハウ
lycorptech_jp
PRO
4
1k
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
247
13k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Six Lessons from altMBA
skipperchong
29
4.2k
Leo the Paperboy
mayatellez
4
1.5k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
810
Are puppies a ranking factor?
jonoalderson
1
3.1k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
230
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
170
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
210
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
140
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
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!