Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Elixir – Belarus Ruby User Group 25 Jan 2014
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Sergey Nartimov
January 25, 2014
Programming
680
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Elixir – Belarus Ruby User Group 25 Jan 2014
Sergey Nartimov
January 25, 2014
Transcript
35 slides
Elixir Сергей Нартымов Brainspec https://github.com/lest twitter: @just_lest
Elixir is a metaprogrammable, functional language built atop the Erlang
VM.
Elixir
Metaprogramming
Metaprogramming iex> nil?(1) false iex> nil?(nil) true defmacro nil?(x) do
quote do: unquote(x) == nil end
Metaprogramming iex> nil?(1) false iex> nil?(nil) true defmacro nil?(x) do
quote do: unquote(x) == nil end
Metaprogramming if(foo, do: bar, else: baz) if foo do bar
else baz end
Metaprogramming defmacro unless(clause, options) do do_clause = Keyword.get(options, :do, nil)
else_clause = Keyword.get(options, :else, nil) quote do if(unquote(clause), do: unquote(else_clause), else: unquote(do_clause)) end end
Metaprogramming Lisps traditionally empowered developers because you can eliminate anything
that’s tedious through macros, and that power is really what people keep going back for. — Rich Hickey
Functions
Function capture iex> list = ["foo", "bar", "baz"] ["foo","bar","baz"] iex>
Enum.map list, fn(x) -> size(x) end [3,3,3] iex> Enum.map list, &size/1 [3,3,3] iex> fun = &rem(&1, 2) #Function<6.80484245 in :erl_eval.expr/5> iex> fun.(4) 0
Function capture iex> list = ["foo", "bar", "baz"] ["foo","bar","baz"] iex>
Enum.map list, fn(x) -> size(x) end [3,3,3] iex> Enum.map list, &size/1 [3,3,3] iex> fun = &rem(&1, 2) #Function<6.80484245 in :erl_eval.expr/5> iex> fun.(4) 0
Partial application iex> list = ["foo", "bar", "baz"] ["foo","bar","baz"] iex>
Enum.map list, fn(x) -> size(x) end [3,3,3] iex> Enum.map list, &size/1 [3,3,3] iex> fun = &rem(&1, 2) #Function<6.80484245 in :erl_eval.expr/5> iex> fun.(4) 0
Pipeline operator
f3(f2(f1(state))) state |> f1 |> f2 |> f3
f3(f2(f1(state))) state |> f1 |> f2 |> f3
list |> Enum.filter(&(&1 > 0)) # take positive numbers |>
Enum.map(&(&1 * &1)) # square each one |> Enum.reduce(0, &(&1 + &2)) # calculate sum
Polymorphism
Protocols
Protocols defprotocol Inspect do def inspect(thing, opts) end defimpl Inspect,
for: Atom do def inspect(false), do: "false" def inspect(true), do: "true" def inspect(nil), do: "nil" def inspect(atom) do # ... end end
Protocols defimpl Inspect, for: List do # ... end defimpl
Inspect, for: Integer do # ... end
ExUnit A unit test framework
ExUnit ExUnit.start defmodule MyTest do use ExUnit.Case test "the truth"
do assert true end end $ elixir assertion_test.exs
ExUnit ExUnit.start defmodule MyTest do use ExUnit.Case test "the truth"
do assert true end end $ elixir assertion_test.exs
ExUnit assert 1 + 1 == 2 refute 1 +
3 == 3 assert 1 + 1 == 3 # Expected 2 to be equal to (==) 3
Mix A build tool
Mix defmodule MyProject.Mixfile do use Mix.Project def project do [
app: :my_project, version: "0.0.1", deps: deps ] end # Configuration for the OTP application def application do [] end defp deps do [] end end
Mix defp deps do [ { :some_project, github: "some_project/other", tag:
"0.3.0" }, { :another_project, ">= 1.0.2", git: "https://example.com/another/repo.git" } ] end
Other
Other • Unicode strings
Other • Unicode strings • String sigils, heredocs
Other • Unicode strings • String sigils, heredocs • Documentation
Other • Unicode strings • String sigils, heredocs • Documentation
• List comprehentions
Resources • http://elixir-lang.org/ • http://joearms.github.io/2013/05/31/a-week- with-elixir.html • http://www.theerlangelist.com/2014/01/ why-elixir.html •
http://devintorr.es/blog/2013/06/11/elixir- its-not-about-syntax/
Спасибо https://github.com/lest twitter: @just_lest Сергей Нартымов Brainspec
More Decks by Sergey Nartimov
See All by Sergey Nartimov
PubSub at Rails
lest
0
160
Rails in production - RubyConfBY 22 Mar 2015
lest
1
170
Sequel - BRUG 21 Feb 2015
lest
0
110
Authentication Security – RUBYSPB
lest
2
210
Geospatial applications on Rails
lest
8
460
Design patterns – Belarus Ruby on Rails User Group 23 Feb 2013
lest
8
680
Ruby Stdlib – Minsk.rb October 2012
lest
10
440
Background jobs with realtime results – RailsClub'Moscow 2012
lest
5
240
Other Decks in Programming
See All in Programming
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
170
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
830
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
210
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
190
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
370
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
130
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
2k
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
140
地方こそサーバーレス — 10年続けた、顔が見えるチームで確かな基盤を / Serverless Matters Most in Regional Areas — 10 Years of Building Reliable Foundations with Close-Knit Teams
seike460
PRO
1
350
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
3
1.7k
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
130
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
210
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Navigating Team Friction
lara
192
16k
Thoughts on Productivity
jonyablonski
76
5.5k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Skip the Path - Find Your Career Trail
mkilby
1
290
Designing Powerful Visuals for Engaging Learning
tmiket
1
650
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
4
1.2k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
520
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
660
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
Designing for Timeless Needs
cassininazir
1
560