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
Intro to Elixir
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Mario Alberto Chávez
November 05, 2015
Programming
170
0
Share
Intro to Elixir
Presentation about Elixir programming language
Mario Alberto Chávez
November 05, 2015
More Decks by Mario Alberto Chávez
See All by Mario Alberto Chávez
Ruby Internals V3
mario_chavez
0
67
Beyond the Rails Way
mario_chavez
1
130
Elm, una mejor manera de hacer frontend
mario_chavez
0
250
Rediscovering ActiveRecord
mario_chavez
2
350
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
430
Pitch para Startups
mario_chavez
1
150
Understanding KPIs
mario_chavez
1
120
Logic Programming
mario_chavez
0
130
El nuevo comercio electrónico
mario_chavez
0
86
Other Decks in Programming
See All in Programming
権限チェックの一貫性を型で守る TypeScript による多層防御
mnch
4
920
今さら聞けないCancellationToken
htkym
0
200
横断組織出身のQAEがインプロセスQAEでつまずいたこと・活かせたこと
ty89
0
440
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
180
AI駆動開発勉強会 広島支部 第一回勉強会 AI駆動開発概要とワークショップ
hayatoshimiu
0
400
inferと仲良くなる10分間
ryokatsuse
1
270
ビジネスモデルから紐解く、AI+型駆動開発
hirokiomote
2
3.6k
Swiftのレキシカルスコープ管理
kntkymt
0
200
New "Type" system on PicoRuby
pocke
1
300
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
210
Inspired By RubyKaigi (EN)
atzzcokek
0
320
GitHub Copilot CLIのいいところ
htkym
2
1.2k
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
150
KATA
mclloyd
PRO
35
15k
4 Signs Your Business is Dying
shpigford
187
22k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
44k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
420
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
What's in a price? How to price your products and services
michaelherold
247
13k
Un-Boring Meetings
codingconduct
0
300
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
150
How GitHub (no longer) Works
holman
316
150k
Transcript
Intro to Elixir Mario Alberto Chávez @mario_chavez
Compiles to BEAM byte code Runs on Erlang VM
Concurrency
Concurrency Lightweight processes |>Are applications |>Requires a minimum of 2k
of memory |>Are supervised |>Fault-tolerant |>Garbage collected independent |>Run on multicore machines
Concurrency Actor pattern |>Receive messages |>Process data |>Talk to other
processes |>Start new processes |>Respond to messages
Concurrency Distributed
OTP is simple to design complex systems
Functional
Functional Unlearn OO |>Inmutable data |>No objects |>No classes |>No
Inheritance
Functional Functions transform data |>Small and focused |>Composable |>Repeatable |>Don’t
have side effects |>Data is passed by Value
Simple, clean, fun syntax
Atoms :ok, :accepted
Tuples { :ok, 1, “data” }
Lists [1, “data”, :ok, {“a”}]
Maps data = %{ name: “Mario”, language: “Elixir” } data.name
=> “Mario” data[:language] => “Elixir
Keywords List data = [name: “Mario”, language: “Elixir”] data[:name]
=> “Mario” data.name ** (ArgumentError) argument error
Ranges (1..5)
Functions adder = fn(a) -> fn(b) -> a + b
end end add2 = adder.(2) add.(3) => 5
Inline functions Enum.map([1, 2], fn(value) -> value * value end)
=> [1, 4] Enum.map([1, 2], &(&1 * &1)) => [1, 4]
Named functions defmodule Math do def add2(value) do value +
2 end end Math.add2(5) => 7
Pattern matching
Match operator = a = 1 => 1 1 =
a => 1 2 = a ** (MatchError) no match of right hand side value: 1 ^a = 2 ** (MatchError) no match of right hand side value: 2
Deconstruction list = [1, 3, 5, 7] [1, a |
tail] = list a => 3 tail => [5, 7]
Deconstruction data = %{ name: “Mario”, language: “Elixir” } %{
name: name } = data name => “Mario”
Multiple clauses require Integer, only: [is_odd/1] defmodule Math do def
mult(0), do: 0 def mult(x) when Integer.is_odd(x), do: x * 3 def mult(x), do: x * -3 end Math.mult(0) => 0 Math.mult(3) => 9 Math.mult(6) => -18
Functions composition
Pipeline [7, nil, 3, nil, 5, 1] |> Enum.filter(&(&1))
|> Enum.sort |> Enum.map(&(&1 * 2)) |> Enum.join(", ") => ”2, 6, 10, 14"
Many more
Metaprogramming Language extensibility |>Metaprogramming is core to Elixir |>Add new
functionality |>Create DSLs
mix Compilation and tasks tools |>Compiles code |>Execute tasks |>Creates
project template
hex package manager |>Resolves dependencies |>Install libraries
docs beautiful and complete help
Web development Phoenix Framework
Learn more Resources |>Elixir playground http://elixirplayground.com |>Slack channel for help
|>Programming Elixir Book
Intro to Elixir Mario Alberto Chávez @mario_chavez