Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby...
Transcript of Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby...
![Page 1: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/1.jpg)
Drinking the Elixir@jocranford
![Page 2: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/2.jpg)
![Page 3: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/3.jpg)
Why Elixir?
Concurrency Support
Accessibility
Performance
Impact on hiring
![Page 4: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/4.jpg)
🤔 But why not just write Erlang?
![Page 5: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/5.jpg)
Elixir =
Erlang libraries + Elixir tools
Elixir
Erlang
![Page 6: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/6.jpg)
Prolog sucks ass for building entire applications. But that hasn't deterred Erlang from stealing it's
dynamite syntax.
Damien Katz, creator of Couch DB
![Page 7: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/7.jpg)
Despite some great properties, I never was (and I’m still not) quite comfortable programming in Erlang. The coding experience somehow never felt very fluent, and the
resulting code was always burdened with excessive boilerplate and duplication.
Saša Jurić, author of Elixir in Action
![Page 8: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/8.jpg)
!= +
![Page 9: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/9.jpg)
Our Journey.
![Page 10: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/10.jpg)
Doing concurrency in Erlang or Elixir versus other languages is a bit like doing branches in Git vs Subversion.
Devin Torres, Nano Core Team
![Page 11: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/11.jpg)
OTP
![Page 12: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/12.jpg)
OhteepeeOTP
![Page 13: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/13.jpg)
Ohteepee
Concurrent Systems Platform
OTP
![Page 14: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/14.jpg)
Supervisor
Supervisor
Worker Worker Worker
Worker WorkerWorker
![Page 15: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/15.jpg)
Monolith Ruby on Rails
Unicorn
Worker Worker
Worker Worker
![Page 16: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/16.jpg)
A little story about workers dying quietly.
![Page 17: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/17.jpg)
What we learned
sasl logging library is excellent
Workers that die gracefully are not restarted
![Page 18: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/18.jpg)
What we learned
sasl logging library is excellent
Workers that die gracefully are not restarted
Expect the unexpected
Be prepared for some frustration
![Page 19: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/19.jpg)
Accessibility
class Greeter def hello(name) puts "Hello, #{name}" end end
Greeter.new.hello("Jo")
defmodule Greeter do def hello(name) do IO.puts "Hello, #{name}" end end
Greeter.hello("Jo")
![Page 20: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/20.jpg)
Elixir looks familiar
Map Hash
List Array
sort of like
sort of like
Atom Symbolequivalent of
Enum similar interface to Enum
Stream similar interface to Stream
![Page 21: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/21.jpg)
The Paradigm Shift
When we fell in love with Elixir
![Page 22: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/22.jpg)
The Pipe Operator
|>
![Page 23: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/23.jpg)
def index(conn, _params) do status = MicroStatus.version(Waffle.Status)
send_resp( put_resp_content_type( conn,("application/json"), :ok, status ) ) end
With no Pipe Operator
![Page 24: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/24.jpg)
def index(conn, _params) do status = MicroStatus.version(Waffle.Status)
conn |> put_resp_content_type("application/json") |> send_resp(:ok, status) end
With the Pipe
![Page 25: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/25.jpg)
Pattern Matching
x = 1
![Page 26: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/26.jpg)
![Page 27: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/27.jpg)
![Page 28: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/28.jpg)
![Page 29: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/29.jpg)
If {:ok, contents} = File.read("file.txt") IO.puts contents end
![Page 30: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/30.jpg)
![Page 31: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/31.jpg)
def max([head | []]) do head end
def max([head | tail]) do _max(head, max(tail)) end
defp _max(one, two) when one > two do one end
defp _max(one, two) when two > one do two end
![Page 32: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/32.jpg)
Fewer nil checks
Fewer if statements
Eliminate early returns
Shorter functions
Much tidier code!
![Page 33: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/33.jpg)
Even for single threaded programming, mutability brings an uncertainty about how a program will execute. And I do not miss the
mutability at all. Functional programming and immutability helps to clarify things and makes it easier to reason about code.
Lau Taarnskov, Tech Blogger
![Page 34: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/34.jpg)
Mix
IEx
Logger
ExUnit
![Page 35: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/35.jpg)
Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an
accident.
Devin Torres, Tech Blogger
![Page 36: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/36.jpg)
Immature is a word boring people use to describe fun people.
Will Ferrell
![Page 37: Drinking the Elixir - YOW! Conferences · Elixir is what would happen if Erlang, Clojure, and Ruby somehow had a baby and it wasn’t an accident. Devin Torres, Tech Blogger. Immature](https://reader034.fdocuments.net/reader034/viewer/2022043011/5fa6803573d79c72036a86df/html5/thumbnails/37.jpg)
Thanks!