drinking the elixir - yow! conferences · elixir is what would happen if erlang, clojure, and ruby...
Post on 10-Aug-2020
3 Views
Preview:
TRANSCRIPT
Drinking the Elixir@jocranford
Why Elixir?
Concurrency Support
Accessibility
Performance
Impact on hiring
🤔 But why not just write Erlang?
Elixir =
Erlang libraries + Elixir tools
Elixir
Erlang
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
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
!= +
Our Journey.
Doing concurrency in Erlang or Elixir versus other languages is a bit like doing branches in Git vs Subversion.
Devin Torres, Nano Core Team
OTP
OhteepeeOTP
Ohteepee
Concurrent Systems Platform
OTP
Supervisor
Supervisor
Worker Worker Worker
Worker WorkerWorker
Monolith Ruby on Rails
Unicorn
Worker Worker
Worker Worker
A little story about workers dying quietly.
What we learned
sasl logging library is excellent
Workers that die gracefully are not restarted
What we learned
sasl logging library is excellent
Workers that die gracefully are not restarted
Expect the unexpected
Be prepared for some frustration
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")
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
The Paradigm Shift
When we fell in love with Elixir
The Pipe Operator
|>
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
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
Pattern Matching
x = 1
If {:ok, contents} = File.read("file.txt") IO.puts contents end
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
Fewer nil checks
Fewer if statements
Eliminate early returns
Shorter functions
Much tidier code!
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
Mix
IEx
Logger
ExUnit
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 is a word boring people use to describe fun people.
Will Ferrell
Thanks!
top related