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
Mario Alberto Chávez
November 05, 2015
Programming
0
130
Intro to Elixir
Presentation about Elixir programming language
Mario Alberto Chávez
November 05, 2015
Tweet
Share
More Decks by Mario Alberto Chávez
See All by Mario Alberto Chávez
Ruby Internals V3
mario_chavez
0
46
Beyond the Rails Way
mario_chavez
1
68
Elm, una mejor manera de hacer frontend
mario_chavez
0
190
Rediscovering ActiveRecord
mario_chavez
2
310
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
360
Pitch para Startups
mario_chavez
1
100
Understanding KPIs
mario_chavez
1
66
Logic Programming
mario_chavez
0
91
El nuevo comercio electrónico
mario_chavez
0
50
Other Decks in Programming
See All in Programming
ECSのサービス間通信 4つの方法を比較する 〜Canary,Blue/Greenも添えて〜
tkikuc
11
2.3k
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
1k
CSC509 Lecture 09
javiergs
PRO
0
130
Java ジェネリクス入門 2024
nagise
0
640
開発効率向上のためのリファクタリングの一歩目の選択肢 ~コード分割~ / JJUG CCC 2024 Fall
ryounasso
0
380
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
180
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
320
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
460
Sidekiqで実現する 長時間非同期処理の中断と再開 / Pausing and Resuming Long-Running Asynchronous Jobs with Sidekiq
hypermkt
6
2.8k
カラム追加で増えるActiveRecordのメモリサイズ イメージできますか?
asayamakk
4
1.7k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
230
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
370
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
43
13k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Statistics for Hackers
jakevdp
796
220k
The Language of Interfaces
destraynor
154
24k
For a Future-Friendly Web
brad_frost
175
9.4k
Speed Design
sergeychernyshev
24
580
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
Building an army of robots
kneath
302
42k
Rails Girls Zürich Keynote
gr2m
93
13k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Designing for Performance
lara
604
68k
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