Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Learn Elixir at Manchester Lambda Lounge

796 visualizaciones

Publicado el

A short introduction to Elixir presented by Chi-chi Ekweozor at Manchester UK's MadLab on 20 February.
Learn how to use the ubiquitous pipeline operator |> to consume functions as data, pattern matching, modules, lists and other language constructs.

Publicado en: Software
  • Sé el primero en comentar

  • Sé el primero en recomendar esto

Learn Elixir at Manchester Lambda Lounge

  1. 1. Learn Elixir Manchester Lambda Lounge, Monday 20 Feb 2017, 7pm Presented by Chi-chi Ekweozor @thisischichi
  2. 2. “Elixir is a dynamic, functional language with Ruby-like syntax that runs on the Erlang virtual machine. It can be described as the language for the modern, real time, hyper-connected world with first class support for concurrency, fault tolerance and high availability, all courtesy of its Erlang pedigree.”
  3. 3. • Elixir is a functional language. There are two things to remember: Immutable data: any function that transforms data will return a new copy of it We can combine functions, and run them in parallel if we please, using lightweight Elixir ‘processes’
  4. 4. Learn Elixir • Install Elixir • What is pattern matching? • Meet Lists, and Modules • Meet the Pipe Operator |> • Resources for learning
  5. 5. Install Elixir
  6. 6. To install Elixir on your computer, follow the instructions at: http://elixir-lang.org/install.html
  7. 7. iex - Interactive Elixir To test your Elixir installation was successful, start an Elixir session. At your regular shell prompt, type iex.
  8. 8. Elixir Basics
  9. 9. Learn Elixir • Install Elixir • What is pattern matching? • Meet Lists, and Modules • Meet the Pipe Operator |> • Resources for learning
  10. 10. Pattern matching?
  11. 11. Type this into your terminal: iex> a = 1 iex> a + 3
  12. 12. Now, type this into your terminal: iex> a = 1 iex> 1 = a iex> 2 = a
  13. 13. Lists, and pattern matching: iex> list = [ 1, 2, 3 ] iex> [ a, b, c ] = list iex> a, iex> b, etc etc
  14. 14. More lists: iex> list = [ 1, 2, 3 ] iex> [ a, 2, b ] = list iex> a, iex> b, etc etc
  15. 15. There’s more to this than might be immediately apparent: iex> list = [ 1, 2, 3 ] iex> [ a, 1, b ] = list
  16. 16. Learn Elixir • Install Elixir • What is pattern matching? • Meet Lists, and Modules • Meet the Pipe Operator |> • Resources for learning
  17. 17. Now meet Modules
  18. 18. clause
  19. 19. Learn Elixir • Install Elixir • What is pattern matching? • Meet Lists, and Modules • Meet the Pipe Operator |> • Resources for learning
  20. 20. The Pipe Operator |>
  21. 21. We’ve all seen code like this: people = DB.find_customers orders = Orders.for_customers(people) tax = sales_tax(orders, 2016) filing = prepare_filing(tax)
  22. 22. The alternative was to write: filing = prepare_filing(sales_tax(Orders.for_customers(DB.find_customers), 2016))
  23. 23. Elixir has a better way of writing it…
  24. 24. The Pipe or Pipeline Operator |> takes the result of the previous expression and feeds it to the next one as the first argument
  25. 25. In Elixir, the awkward to read function becomes:
  26. 26. filing = DB.find_customers |> Orders.for_customers |> sales_tax(2016) |> prepare_filing
  27. 27. Putting it all together, a |> exercise:
  28. 28. Learn Elixir • Install Elixir • What is pattern matching? • Meet Lists, and Modules • Meet the Pipe Operator |> • Resources for learning
  29. 29. Learning Resources
  30. 30. Books: Programming Elixir 1.3 by Dave Thomas Elixir in Action by Saša Jurić Websites: elixir-lang.org elixirforum.com elixirschool.com

×