Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Say Hello to Elixir

The Guild
February 27, 2014

Say Hello to Elixir

Arjan van der Gaag talks about Elixir and how to apply some of the lessons learned to every day OOP with Ruby.

The Guild

February 27, 2014
Tweet

More Decks by The Guild

Other Decks in Programming

Transcript

  1. – erlang.org Erlang is a programming language used to build

    massively scalable soft real-time systems with requirements on high availability. Erlang's runtime system has built-in support for concurrency, distribution and fault tolerance.
  2. Anonymous functions iex> Enum.map [1, 2, 3], fn n ->

    n * 2 end [2, 4, 6] iex> Enum.map [1, 2, 3], &(&1 * 2) [2, 4, 6]
  3. Named functions & modules defmodule Greeter do def greet(name) do

    IO.puts "Hello, #{name}" end end iex> Greeter.greet("James") "Hello, James" iex> Enum.each ["john", “paul”], &Greeter.greet/1 "Hello, john" "Hello, paul"
  4. defmodule MyMap do ! ! ! ! ! end Pattern

    matching ! def map([], _), do: [] ! ! ! def map([head | tail], fun) do [fun.(head) | map(tail, fun)] end
  5. Assert defmodule TruthTest do use ExUnit.Case test "considers two strings

    equal" do assert "foo" == "bar" end end ! ! ! ! ! ! ! ! 1) test considers two strings equal (TruthTest) ** (ExUnit.ExpectationError) expected: "foo" to be equal to (==): "bar" at test/demo/truth_test.exs:5
  6. Actors fib = spawn(Fibonacci, :server, [self]) fib <- { :number,

    17 } ! ! ! receive do ! ! ! ! ! ! end ! ! ! ! { :ok, result } -> IO.puts "Received response:" IO.puts result ! ! ! ! ! ! ! { _, error } -> IO.puts “An error occured!” IO.puts error
  7. Find out more • elixir-lang.org • erlang.org • Programming Elixir

    (Dave Thomas) • Meet Elixir (Peepcode play-by-play with José Valim) • exercism.io • Gary Bernhardt: Boundaries