AN INTRODUCTION TO
ERLANG AND ELIXIR
Wednesday, September 25, 13
WHAT IS ERLANG
Modular, Declarative Language who’s syntax descends from
prolog
Wednesday, September 25, 13
WHAT IS ELIXIR
Modular, Declarative language with meta programming
facilities whose syntax descends (mostly) from Ruby
Wednesday, September 25, 13
ERLANG VM - WHY SO
INTERESTING
Built Around Concurrency
Built in scheduler
Async IO
Concurrent Garbage collector
Wednesday, September 25, 13
ERLANG VM - WHY SO
INTERESTING
Small Number of Serializable Types
Pattern Matching
Processes
Process Linking
Immutable Data
Wednesday, September 25, 13
ERLANG VM
Erlang
Elixir
Joxa
LFE
The Concurrent Schemer
Reia
Wednesday, September 25, 13
ERLANG VM - TYPES
Numbers
Atoms
Bit Strings and Binaries
Fun
Tuple
List
Wednesday, September 25, 13
ERLANG VM -
FEATURES
Expressions
Functions
Modules
Process
Wednesday, September 25, 13
RECORDS - ERLANG
-module(records).
-record(robot, {name,
type=industrial,
hobbies,
details=[]}).
first_robot() ->
#robot{name="Mechatron",
type=handmade,
details=["Moved by a small man inside"]}.
Wednesday, September 25, 13
RECORDS - ELIXIR
defmodule Records do
defrecord Robots, name: nil,
type: industrial,
hobbies: nil,
details: ["Moved by a small man inside"]
def first_robot do
Robot.new(name: "Mechatron",
type: :handmade,
details: ["Moved by a small man inside"])
end
end
Wednesday, September 25, 13
POLYMORPHISM -
ELIXIR
defprotocol Blank do
@doc "Returns true if data is considered blank/empty"
def blank?(data)
end
# Numbers are never blank
defimpl Blank, for: Number do
def blank?(_), do: false
end
# Just empty list is blank
defimpl Blank, for: List do
def blank?([]), do: true
def blank?(_), do: false
end
# Just the atoms false and nil are blank
defimpl Blank, for: Atom do
def blank?(false), do: true
def blank?(nil), do: true
def blank?(_), do: false
end
Wednesday, September 25, 13
METAPROGRAMMING -
ELIXIR
defmodule MyMacro do
defmacro unless(clause, options) do
quote do: if(!unquote(clause), unquote(options))
end
end
require MyMacro
unless 2 + 2 == 5, do: call_function()
Wednesday, September 25, 13
DOWNSIDES - ERLANG
No Metaprogramming
No Polymorphism (mostly)
Obscure Syntax
Records are horrible
Wednesday, September 25, 13
DOWNSIDES - ELIXIR
Its young, so changes a fair amount
Truthiness is the devil
Macros are not sufficiently flexible (as what I am used to in
lisp)
Awkward syntax
Fair amount of inconsistency
Not really accepted by Erlangers
Wednesday, September 25, 13
UPSIDES - ERLANG
Simple, Regular Syntax
Stable - Infrequent Changes
Robust and Extraordinarily well tested
Wednesday, September 25, 13
UPSIDES - ELIXIR
Metaprogramming, Metaprogramming, Metaprogramming
Polymorphism
Non stable (ie, improving) syntax
Robust, usable shell
Did I say metaprogramming
Wednesday, September 25, 13
WRAPPING UP
Rate This Talk - http://speakerrate.com/talks/26081-an-
introduction-to-erlang-elixir-eric-merritt
Contact me - @ericbmerritt, ericbmerritt@gmail.com,
Wednesday, September 25, 13

An introduction to Erlang and Elixir

  • 1.
    AN INTRODUCTION TO ERLANGAND ELIXIR Wednesday, September 25, 13
  • 2.
    WHAT IS ERLANG Modular,Declarative Language who’s syntax descends from prolog Wednesday, September 25, 13
  • 3.
    WHAT IS ELIXIR Modular,Declarative language with meta programming facilities whose syntax descends (mostly) from Ruby Wednesday, September 25, 13
  • 4.
    ERLANG VM -WHY SO INTERESTING Built Around Concurrency Built in scheduler Async IO Concurrent Garbage collector Wednesday, September 25, 13
  • 5.
    ERLANG VM -WHY SO INTERESTING Small Number of Serializable Types Pattern Matching Processes Process Linking Immutable Data Wednesday, September 25, 13
  • 6.
    ERLANG VM Erlang Elixir Joxa LFE The ConcurrentSchemer Reia Wednesday, September 25, 13
  • 7.
    ERLANG VM -TYPES Numbers Atoms Bit Strings and Binaries Fun Tuple List Wednesday, September 25, 13
  • 8.
  • 9.
    RECORDS - ERLANG -module(records). -record(robot,{name, type=industrial, hobbies, details=[]}). first_robot() -> #robot{name="Mechatron", type=handmade, details=["Moved by a small man inside"]}. Wednesday, September 25, 13
  • 10.
    RECORDS - ELIXIR defmoduleRecords do defrecord Robots, name: nil, type: industrial, hobbies: nil, details: ["Moved by a small man inside"] def first_robot do Robot.new(name: "Mechatron", type: :handmade, details: ["Moved by a small man inside"]) end end Wednesday, September 25, 13
  • 11.
    POLYMORPHISM - ELIXIR defprotocol Blankdo @doc "Returns true if data is considered blank/empty" def blank?(data) end # Numbers are never blank defimpl Blank, for: Number do def blank?(_), do: false end # Just empty list is blank defimpl Blank, for: List do def blank?([]), do: true def blank?(_), do: false end # Just the atoms false and nil are blank defimpl Blank, for: Atom do def blank?(false), do: true def blank?(nil), do: true def blank?(_), do: false end Wednesday, September 25, 13
  • 12.
    METAPROGRAMMING - ELIXIR defmodule MyMacrodo defmacro unless(clause, options) do quote do: if(!unquote(clause), unquote(options)) end end require MyMacro unless 2 + 2 == 5, do: call_function() Wednesday, September 25, 13
  • 13.
    DOWNSIDES - ERLANG NoMetaprogramming No Polymorphism (mostly) Obscure Syntax Records are horrible Wednesday, September 25, 13
  • 14.
    DOWNSIDES - ELIXIR Itsyoung, so changes a fair amount Truthiness is the devil Macros are not sufficiently flexible (as what I am used to in lisp) Awkward syntax Fair amount of inconsistency Not really accepted by Erlangers Wednesday, September 25, 13
  • 15.
    UPSIDES - ERLANG Simple,Regular Syntax Stable - Infrequent Changes Robust and Extraordinarily well tested Wednesday, September 25, 13
  • 16.
    UPSIDES - ELIXIR Metaprogramming,Metaprogramming, Metaprogramming Polymorphism Non stable (ie, improving) syntax Robust, usable shell Did I say metaprogramming Wednesday, September 25, 13
  • 17.
    WRAPPING UP Rate ThisTalk - http://speakerrate.com/talks/26081-an- introduction-to-erlang-elixir-eric-merritt Contact me - @ericbmerritt, ericbmerritt@gmail.com, Wednesday, September 25, 13