SlideShare a Scribd company logo
1 of 39
Download to read offline
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

Logging in JavaScript - part-1
Logging in JavaScript - part-1Logging in JavaScript - part-1
Logging in JavaScript - part-1Ideas2IT Technologies
 
PHPerぼためぼPerlć…„é–€@ Kansai.pm#12
PHPerぼためぼPerlć…„é–€@ Kansai.pm#12PHPerぼためぼPerlć…„é–€@ Kansai.pm#12
PHPerぼためぼPerlć…„é–€@ Kansai.pm#12Kazuki KOMORI
 
Getting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot FrameworkGetting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot FrameworkSarah Sexton
 
Word Play in the Digital Age: Building Text Bots with Tracery
Word Play in the Digital Age: Building Text Bots with TraceryWord Play in the Digital Age: Building Text Bots with Tracery
Word Play in the Digital Age: Building Text Bots with TracerySarah Sexton
 
Augeas
AugeasAugeas
Augeaslutter
 
Thinking Outside The [Sand]Box
Thinking Outside The [Sand]BoxThinking Outside The [Sand]Box
Thinking Outside The [Sand]BoxMichael Genkin
 
Ruby iterators
Ruby iteratorsRuby iterators
Ruby iteratorsTim Cull
 

What's hot (10)

Logging in JavaScript - part-1
Logging in JavaScript - part-1Logging in JavaScript - part-1
Logging in JavaScript - part-1
 
PHPerぼためぼPerlć…„é–€@ Kansai.pm#12
PHPerぼためぼPerlć…„é–€@ Kansai.pm#12PHPerぼためぼPerlć…„é–€@ Kansai.pm#12
PHPerぼためぼPerlć…„é–€@ Kansai.pm#12
 
Getting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot FrameworkGetting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot Framework
 
Word Play in the Digital Age: Building Text Bots with Tracery
Word Play in the Digital Age: Building Text Bots with TraceryWord Play in the Digital Age: Building Text Bots with Tracery
Word Play in the Digital Age: Building Text Bots with Tracery
 
Augeas
AugeasAugeas
Augeas
 
Cli2 Bibalex
Cli2 BibalexCli2 Bibalex
Cli2 Bibalex
 
Thinking Outside The [Sand]Box
Thinking Outside The [Sand]BoxThinking Outside The [Sand]Box
Thinking Outside The [Sand]Box
 
Ruby 101
Ruby 101Ruby 101
Ruby 101
 
Ruby iterators
Ruby iteratorsRuby iterators
Ruby iterators
 
ubunturef
ubunturefubunturef
ubunturef
 

Similar to Chicago Elixir - Elixir Intro

Clojureć…„é–€
Clojureć…„é–€Clojureć…„é–€
Clojureć…„é–€Naoyuki Kakuda
 
Elixir for rubysts
Elixir for rubystsElixir for rubysts
Elixir for rubystsDanni Friedland
 
CoderDojo: Intermediate Python programming course
CoderDojo: Intermediate Python programming courseCoderDojo: Intermediate Python programming course
CoderDojo: Intermediate Python programming courseAlexander Galkin
 
Ruby çš‹ćŒèȘžèš€ć…„é–€ć°ŽèŠœ
Ruby çš‹ćŒèȘžèš€ć…„é–€ć°ŽèŠœRuby çš‹ćŒèȘžèš€ć…„é–€ć°ŽèŠœ
Ruby çš‹ćŒèȘžèš€ć…„é–€ć°ŽèŠœWen-Tien Chang
 
Ruby 2: some new things
Ruby 2: some new thingsRuby 2: some new things
Ruby 2: some new thingsDavid Black
 
Poetic APIs
Poetic APIsPoetic APIs
Poetic APIsErik Rose
 
Crystal presentation in NY
Crystal presentation in NYCrystal presentation in NY
Crystal presentation in NYCrystal Language
 
Ruby ć…„é–€ çŹŹäž€æŹĄć°±äžŠæ‰‹
Ruby ć…„é–€ çŹŹäž€æŹĄć°±äžŠæ‰‹Ruby ć…„é–€ çŹŹäž€æŹĄć°±äžŠæ‰‹
Ruby ć…„é–€ çŹŹäž€æŹĄć°±äžŠæ‰‹Wen-Tien Chang
 
Origins of Elixir programming language
Origins of Elixir programming languageOrigins of Elixir programming language
Origins of Elixir programming languagePivorak MeetUp
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - StockholmJan Kronquist
 
(first '(Clojure.))
(first '(Clojure.))(first '(Clojure.))
(first '(Clojure.))niklal
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Introthnetos
 
What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)Kerry Buckley
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to RubyRyan Cross
 
Concurrent programming with Celluloid (MWRC 2012)
Concurrent programming with Celluloid (MWRC 2012)Concurrent programming with Celluloid (MWRC 2012)
Concurrent programming with Celluloid (MWRC 2012)tarcieri
 
Erlang is not a city in Germany
Erlang is not a city in GermanyErlang is not a city in Germany
Erlang is not a city in Germanymomo-13
 

Similar to Chicago Elixir - Elixir Intro (20)

Clojureć…„é–€
Clojureć…„é–€Clojureć…„é–€
Clojureć…„é–€
 
Elixir for rubysts
Elixir for rubystsElixir for rubysts
Elixir for rubysts
 
7li7w devcon5
7li7w devcon57li7w devcon5
7li7w devcon5
 
CoderDojo: Intermediate Python programming course
CoderDojo: Intermediate Python programming courseCoderDojo: Intermediate Python programming course
CoderDojo: Intermediate Python programming course
 
Ruby çš‹ćŒèȘžèš€ć…„é–€ć°ŽèŠœ
Ruby çš‹ćŒèȘžèš€ć…„é–€ć°ŽèŠœRuby çš‹ćŒèȘžèš€ć…„é–€ć°ŽèŠœ
Ruby çš‹ćŒèȘžèš€ć…„é–€ć°ŽèŠœ
 
Ruby 2: some new things
Ruby 2: some new thingsRuby 2: some new things
Ruby 2: some new things
 
Ruby 101
Ruby 101Ruby 101
Ruby 101
 
Poetic APIs
Poetic APIsPoetic APIs
Poetic APIs
 
Crystal presentation in NY
Crystal presentation in NYCrystal presentation in NY
Crystal presentation in NY
 
Ruby ć…„é–€ çŹŹäž€æŹĄć°±äžŠæ‰‹
Ruby ć…„é–€ çŹŹäž€æŹĄć°±äžŠæ‰‹Ruby ć…„é–€ çŹŹäž€æŹĄć°±äžŠæ‰‹
Ruby ć…„é–€ çŹŹäž€æŹĄć°±äžŠæ‰‹
 
Elixir
ElixirElixir
Elixir
 
Origins of Elixir programming language
Origins of Elixir programming languageOrigins of Elixir programming language
Origins of Elixir programming language
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - Stockholm
 
(first '(Clojure.))
(first '(Clojure.))(first '(Clojure.))
(first '(Clojure.))
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 
What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)
 
Ruby
RubyRuby
Ruby
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Concurrent programming with Celluloid (MWRC 2012)
Concurrent programming with Celluloid (MWRC 2012)Concurrent programming with Celluloid (MWRC 2012)
Concurrent programming with Celluloid (MWRC 2012)
 
Erlang is not a city in Germany
Erlang is not a city in GermanyErlang is not a city in Germany
Erlang is not a city in Germany
 

Recently uploaded

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Recently uploaded (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Chicago Elixir - Elixir Intro