An introduction to Erlang and Elixir

2,308 views

Published on

Published in: Technology, News & Politics

An introduction to Erlang and Elixir

  1. 1. AN INTRODUCTION TO ERLANG AND ELIXIR Wednesday, September 25, 13
  2. 2. WHAT IS ERLANG Modular, Declarative Language who’s syntax descends from prolog Wednesday, September 25, 13
  3. 3. WHAT IS ELIXIR Modular, Declarative language with meta programming facilities whose syntax descends (mostly) from Ruby Wednesday, September 25, 13
  4. 4. ERLANG VM - WHY SO INTERESTING Built Around Concurrency Built in scheduler Async IO Concurrent Garbage collector Wednesday, September 25, 13
  5. 5. ERLANG VM - WHY SO INTERESTING Small Number of Serializable Types Pattern Matching Processes Process Linking Immutable Data Wednesday, September 25, 13
  6. 6. ERLANG VM Erlang Elixir Joxa LFE The Concurrent Schemer Reia Wednesday, September 25, 13
  7. 7. ERLANG VM - TYPES Numbers Atoms Bit Strings and Binaries Fun Tuple List Wednesday, September 25, 13
  8. 8. ERLANG VM - FEATURES Expressions Functions Modules Process Wednesday, September 25, 13
  9. 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. 10. 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
  11. 11. 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
  12. 12. 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
  13. 13. DOWNSIDES - ERLANG No Metaprogramming No Polymorphism (mostly) Obscure Syntax Records are horrible Wednesday, September 25, 13
  14. 14. 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
  15. 15. UPSIDES - ERLANG Simple, Regular Syntax Stable - Infrequent Changes Robust and Extraordinarily well tested Wednesday, September 25, 13
  16. 16. UPSIDES - ELIXIR Metaprogramming, Metaprogramming, Metaprogramming Polymorphism Non stable (ie, improving) syntax Robust, usable shell Did I say metaprogramming Wednesday, September 25, 13
  17. 17. 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

×