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

Elixir Mini Introduction for Zürich Meetup

Elixir Mini Introduction for Zürich Meetup

Stefan Wintermeyer

February 20, 2017
Tweet

More Decks by Stefan Wintermeyer

Other Decks in Technology

Transcript

  1. Elixir Stefan Wintermeyer @wintermeyer

  2. Elixir is a functional, concurrent, general-purpose programming language that runs

    on the Erlang virtual machine (BEAM). https://en.wikipedia.org/wiki/Elixir_(programming_language)
  3. defmodule ModuleName do def hello do IO.puts "Hello World" end

    end http://elixir-lang.org/crash-course.html
  4. IEx Elixir’s interactive shell

  5. None
  6. Why would I want to learn Elixir? Why invest the

    time and effort? I’m happy with Ruby and OO.
  7. Three Main Reasons Spoiler Alert: Concurrency is not one of

    them.
  8. 1. Speed Elixir runs circles around Ruby and Python.

  9. 2. Stability Speed is nothing without stability.

  10. 3. Hot-Code Upgrades Zero Downtime!

  11. Some Code Examples

  12. Assigning Values to Variables

  13. iex(1)> a = 1 1 iex(2)>

  14. iex(1)> a = 1 1 iex(2)> a = 2 2

    iex(3)>
  15. iex(1)> a = 1 1 iex(2)> a = 2 2

    iex(3)> ^a = 3 ** (MatchError) no match of right hand side value: 3
  16. Tuples

  17. iex(1)> {a, b, c} = {10, 20, 30} {10, 20,

    30} iex(2)>
  18. iex(1)> {a, b, c} = {10, 20, 30} {10, 20,

    30} iex(2)> a 10 iex(3)>
  19. Pattern Matching

  20. iex(1)> {a, b, c} = {10, 20, 30} {10, 20,

    30} iex(2)>
  21. iex(1)> {a, b, c} = {10, 20, 30} {10, 20,

    30} iex(2)> {a, 20, c} = {10, 20, 30} {10, 20, 30} iex(3)>
  22. iex(1)> {a, b, c} = {10, 20, 30} {10, 20,

    30} iex(2)> {a, 20, c} = {10, 20, 30} {10, 20, 30} iex(3)> {a, 1, c} = {10, 20, 30} ** (MatchError) no match of right hand side value: {10, 20, 30}
  23. If you want to get your feed wet with Elixir

    I recommend two projects.
  24. If you like hardware try http://nerves-project.org

  25. None
  26. If you like the web try www.phoenixframework.org

  27. None
  28. Phoenix Framework Productive. Reliable. Fast. Phoenix != Rails

  29. None
  30. mix phoenix.new blog Y cd blog vim config/dev.exs brew install

    postgres brew services start postgres createuser -W --createdb blog demo mix ecto.create mix phoenix.gen.html Post posts subject body vim web/router.ex resources "/posts", PostController mix ecto.migrate mix phoenix.server Blog Example
  31. Thank you! @wintermeyer