an introduction to erlang and elixir
TRANSCRIPT
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 - ELIXIRdefmodule 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"]) endend
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 blankdefimpl Blank, for: Number do def blank?(_), do: falseend
# Just empty list is blankdefimpl Blank, for: List do def blank?([]), do: true def blank?(_), do: falseend
# Just the atoms false and nil are blankdefimpl Blank, for: Atom do def blank?(false), do: true def blank?(nil), do: true def blank?(_), do: falseend
Wednesday, September 25, 13
METAPROGRAMMING - ELIXIR
defmodule MyMacro do defmacro unless(clause, options) do quote do: if(!unquote(clause), unquote(options)) endend
require MyMacrounless 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, [email protected],
Wednesday, September 25, 13