SlideShare a Scribd company logo
Intro to Elixir
Drew Olson
Braintree
brew install elixir
Functional
Concurrent
Immutable
Erlang?
Kind of.
It’s on the Erlang VM.
Metaprogramming
Polymorphism
Tooling
IO.puts "Hello, world!"
Types
1         #
1.0       #
:atom     #
{1, 2, 3} #
[1, 2, 3] #

integer"
float"
atom / symbol"
tuple"
list
[name: "Drew", age: 31]             # keyword"
[{:name, "Drew"}, {:age, 31}]       # keyword
HashDict.new(name: "Drew", age: 31) # HashDict
Modules & Functions
defmodule Greeter do"
  def greet(thing) do"
    IO.puts "Hello, #{thing}!""
  end"
end"
!

Greeter.greet("World")
Anonymous Functions
subject = "World""
!

greeter = fn(greeting) ->"
  IO.puts("#{greeting}, #{subject}!")"
end"
!

greeter.("Hello")
Records
defrecord Person,"
  name: nil,"
  age: nil"
!

drew = Person.new(name: "Drew", age: 31)"
!

IO.puts(drew.name)"
IO.puts(drew.age)
Protocols
defprotocol Checker do"
  @fallback_to_any true"
  def person?(data)"
end"
!

defimpl Checker, for: Person do"
  def person?(_) do"
    true"
  end"
end"
!

defimpl Checker, for: Any do"
  def person?(_) do"
    false"
  end"
end"
!

Checker.person?(Person.new)"
Checker.person?(HashDict.new)
Enum
list = [1, 2, 3]"
keyword = [a: 1, b: 2, c: 3]"
!

Enum.map list, fn(item) ->"
  item * 2"
end"
!

Enum.map keyword, fn({key, val}) ->"
  "#{key} -> #{val}""
end
Pattern Matching
list = [1, 2, 3]"
!

case list do"
  [head|_] ->"
    IO.puts(head)"
  [] ->"
    IO.puts("empty!")"
end
defmodule MyList do"
  def sum(list) do"
    sum(list, 0)"
  end"
!

  defp sum([head|rest], acc) do"
    sum(rest, acc + head)"
  end"
!

  defp sum([], acc) do"
    acc"
  end"
end"
!

MyList.sum([1, 2, 3])
but really
Enum.reduce [1, 2, 3], fn(item, acc) ->"
  acc + item"
end
Macros
not today :)
Concurrency
not today ;(
Tooling
mix
Bundler + Rake
defmodule Foo.Mixfile do"
  use Mix.Project"
!
  def project do"
    [ app: :foo,"
      version: "0.0.1","
      elixir: "~> 0.12.2","
      deps: deps ]"
  end"
!
  # Configuration for the OTP application"
  def application do"
    [mod: { Foo, [] }]"
  end"
!
  # Returns the list of dependencies in the format:"
  # { :foobar, git: "https://github.com/elixir-lang/foobar.git",
tag: "0.1" }"
  #"
  # To specify particular versions, regardless of the tag, do:"
  # { :barbat, "~> 0.1", github: "elixir-lang/barbat" }"
  defp deps do"
    []"
  end"
end
ExUnit
defmodule MyListTest do"
  use ExUnit.Case"
!

  test "it sums" do"
    assert MyList.sum([1, 2, 3]) == 6"
  end"
end
Demos
Thank you.
Questions?

More Related Content

What's hot (10)

PDF
Logging in JavaScript - part-1
Ideas2IT Technologies
 
KEY
PHPerのためのPerl入門@ Kansai.pm#12
Kazuki KOMORI
 
PPTX
Getting Started with Microsoft Bot Framework
Sarah Sexton
 
PPTX
Word Play in the Digital Age: Building Text Bots with Tracery
Sarah Sexton
 
PDF
Augeas
lutter
 
PDF
Cli2 Bibalex
Ahmed Mekkawy
 
PPTX
Thinking Outside The [Sand]Box
Michael Genkin
 
PDF
Ruby 101
Harisankar P S
 
PDF
Ruby iterators
Tim Cull
 
PDF
ubunturef
wensheng wei
 
Logging in JavaScript - part-1
Ideas2IT Technologies
 
PHPerのためのPerl入門@ Kansai.pm#12
Kazuki KOMORI
 
Getting Started with Microsoft Bot Framework
Sarah Sexton
 
Word Play in the Digital Age: Building Text Bots with Tracery
Sarah Sexton
 
Augeas
lutter
 
Cli2 Bibalex
Ahmed Mekkawy
 
Thinking Outside The [Sand]Box
Michael Genkin
 
Ruby 101
Harisankar P S
 
Ruby iterators
Tim Cull
 
ubunturef
wensheng wei
 

Similar to Chicago Elixir - Elixir Intro (20)

KEY
Clojure入門
Naoyuki Kakuda
 
PDF
Elixir for rubysts
Danni Friedland
 
PDF
7li7w devcon5
Kerry Buckley
 
PPTX
CoderDojo: Intermediate Python programming course
Alexander Galkin
 
PDF
Ruby 程式語言入門導覽
Wen-Tien Chang
 
PDF
Ruby 2: some new things
David Black
 
PDF
Poetic APIs
Erik Rose
 
PDF
Crystal presentation in NY
Crystal Language
 
PDF
Ruby 入門 第一次就上手
Wen-Tien Chang
 
PDF
Elixir
Robert Brown
 
PDF
Origins of Elixir programming language
Pivorak MeetUp
 
PDF
Clojure for Java developers - Stockholm
Jan Kronquist
 
PDF
(first '(Clojure.))
niklal
 
KEY
Clojure Intro
thnetos
 
PDF
What I learned from Seven Languages in Seven Weeks (IPRUG)
Kerry Buckley
 
KEY
Ruby
Kerry Buckley
 
KEY
Introduction to Ruby
Ryan Cross
 
KEY
Concurrent programming with Celluloid (MWRC 2012)
tarcieri
 
PDF
Erlang is not a city in Germany
momo-13
 
Clojure入門
Naoyuki Kakuda
 
Elixir for rubysts
Danni Friedland
 
7li7w devcon5
Kerry Buckley
 
CoderDojo: Intermediate Python programming course
Alexander Galkin
 
Ruby 程式語言入門導覽
Wen-Tien Chang
 
Ruby 2: some new things
David Black
 
Poetic APIs
Erik Rose
 
Crystal presentation in NY
Crystal Language
 
Ruby 入門 第一次就上手
Wen-Tien Chang
 
Elixir
Robert Brown
 
Origins of Elixir programming language
Pivorak MeetUp
 
Clojure for Java developers - Stockholm
Jan Kronquist
 
(first '(Clojure.))
niklal
 
Clojure Intro
thnetos
 
What I learned from Seven Languages in Seven Weeks (IPRUG)
Kerry Buckley
 
Introduction to Ruby
Ryan Cross
 
Concurrent programming with Celluloid (MWRC 2012)
tarcieri
 
Erlang is not a city in Germany
momo-13
 
Ad

Recently uploaded (20)

PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Ad

Chicago Elixir - Elixir Intro