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

A Sip of Elixir

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

A Sip of Elixir

An internal talk I gave at work to present the Elixir language and the Phoenix Framework to my colleagues.

Simone D'Avico

January 06, 2021

Transcript

25 slides
  1. October 2020 - 2 WHY AM I HERE? I have

    too many vacation days 2 October 2020 -
  2. October 2020 - 3 WHY AM I HERE? I have

    too many vacation days 3 October 2020 - I am waiting for my colleague Nicola to come back from lunch
  3. October 2020 - 4 MY VACATIONS IN NUMBERS • ~2

    weeks • 1 book Programming Phoenix • 1 video course The Pragmatic Studio LiveView course • 1 small app, many mini apps Rumbl
  4. October 2020 - 5 PROGRAM FOR TODAY • Erlang What

    it is and why it matters Who is using it, and how • Elixir Why it is better than plain Erlang A tour of syntax • Phoenix Framework High level presentation Demo: rumbl • Bonus: Phoenix LiveView
  5. October 2020 - 6 IN THE BEGINNING THERE WAS ERLANG

    Erlang was created at Ericsson in 1986. • The erlang is a unit of traffic density in a telecommunications system. • Erlang also stands for Ericsson Language
  6. October 2020 - 7 ERLANG RUNTIME SYSTEM DESIGN • Distributed

    Out of the box • Fault tolerant Let it crash • Massively scalable Actor model • Massively concurrent Lightweight processes
  7. October 2020 - 8 BATTERIES INCLUDED (1) • ETS Key/Value

    in memory store • Mnesia Distributed database based on ETS The Erlang OS distribution includes OTP, a set of libraries to build highly concurrent and distributed systems
  8. October 2020 - 9 BATTERIES INCLUDED (2) • Dialyzer Static

    code analysis tool “Discrepancy analyze for Erlang” • Observer System monitoring and inspection • …
  9. October 2020 - 10 STUFF IMPLEMENTED WITH ERLANG (1) •

    League of Legends Chat servers • Call of Duty Multiplayer infrastructure • WhatsApp 900M users infra managed by 50 engineers 2 million connections on a single node
  10. October 2020 - 11 STUFF IMPLEMENTED WITH ERLANG (2) •

    Discord 5M users with Erlang, 11M with Erlang + Rust • Heroku Router of their PaaS, plus other pieces • AXD-301 0.6 seconds of downtime in 20 years (!) Continuous Deployment with scp (!!!)
  11. October 2020 - 13 STANDING ON THE SHOULDERS OF GIANTS

    (1) Elixir: runs on the same runtime • Builds on top of Erlang OTP • Provides some abstractions to handle concurrency: GenServer, GenStages, Agents • Modern language features: mix, ExUnit, Hex Docs, macros (!), progressive typing, formatter…
  12. October 2020 - 15 STANDING ON THE SHOULDERS OF GIANTS

    (RESUMED) Elixir: runs on the same runtime • Builds on top of Erlang OTP • Provides some abstractions to handle concurrency: Tasks, GenServers, GenStages, Agents • Modern language features: mix, ExUnit, Hex Docs, macros (!), progressive typing, formatter…
  13. October 2020 - 16 ACTOR MODEL IN ELIXIR Processes •

    think infinite loops • are independent • are location transparent • exchange messages • keep internal state Elixir is multiparadigm: this is OOP as envisioned by Alan Kay!
  14. October 2020 - 17 STANDING ON THE SHOULDERS OF GIANTS

    (2) • Borrows from different communities • Nice tooling for building web applications • Nice tooling for building IoT applications Phoenix Framework Nerves IoT Platform
  15. October 2020 - 18 STANDING ON THE SHOULDERS OF GIANTS

    (2) • Borrows from different communities • Nice tooling for building web applications • Nice tooling for building IoT applications Phoenix Framework Nerves IoT Platform
  16. October 2020 - 19 THE PHOENIX FRAMEWORK • MVC •

    Both APIs and server rendered templates • Real time client server communication • Code generators • LiveDashboard • Convention over configuration
  17. October 2020 - 20 HTTP LAYER Plug: a specification for

    composable modules for connection management • Front and center of Phoenix HTTP layer • Functional approach to request handling: @spec create(Plug.Conn.t(), map) :: Plug.Conn.t()
  18. October 2020 - 21 DATA LAYER Ecto: data validation, persistence

    and querying • Changesets: data validation • Schemas: ORM mapping • Query: composable DSL for SQL Migrations, Data Seeding • Sandbox: run integration tests agains the DB without worrying about data integrity
  19. October 2020 - 22 VIEW LAYER Phoenix Views: Phoenix templating

    system • Html with embeddable Elixir expressions • Utilities for binding forms to changesets • Can render anything, not only html
  20. October 2020 - 23 REAL-TIME UTILITIES • PubSub: built in

    publish-subscribe mechanism • Channels: real time client-server communication • Presence: user presence tracking • LiveView: build real-time apps with only server side code GenServer PubSub Channels Presence LiveView
  21. October 2020 - 24 LET’S HACK Let’s create a small

    web application 24 October 2020 -
  22. October 2020 - 25 LEARNING RESOURCES • Programming Elixir •

    Programming Phoenix • Real Time Phoenix • Pragmatic Studio - Phoenix LiveView course • Elixir School • r/elixir reddit • Elixir forum • GOTO Conf 2019 - The Soul of Erlang and Elixir

More Decks by Simone D'Avico

Other Decks in Programming