3. Elixir
● Funktionellt programmeringsspråk
● Dynamiskt typsystem
● Byggt ovanpå Erlang Virtual Machine
○ Kompileras till Erlang bytecode
○ Battle tested, Erlang skapades 1986
● Skapades av José Valim, för att öka
produktiviteten i Erlang plattformen
4. Varför Erlang?
"Erlang is the culmination of twenty-five
years of correct design decisions in the
language and platform."
5. Elixir i ett nötskal
● Enkla datastrukturer (immutable)
● Skicka meddelanden mellan isolerade processer (actor
model)
● Standard bibliotek för att bygga robusta system (OTP)
○ “Let it crash”
● Extensible
○ Meta programming
■ Macros
6. OTP - Open Telecom Platform
If half of Erlang's greatness comes
from its concurrency and
distribution and the other half
comes from its error handling
capabilities, then the OTP
framework is the third half of it.
7. Skalbart
● Lättviktiga processer
● Isolerade
○ Share nothing
○ Garbage Collection
○ Egen heap
● Meddelanden
○ Brevlåda
○ Distribuerat system
■ Andra maskiner
8. Feltolerant
● Organisera kod i processer
○ Applikationen är ett distribuerat system
○ Fokus på att hantera krascher
■ Istället för att försöka förhindra alla
problem
● Supervisors
● Återställer delar av systemet till ett känt
fungerande tillstånd
● Olika strategier för att starta om processer
● Let it crash
s
w w w
s
w w w
s
w w w
Om en process dör
Starta om den
10. Immutable data
● Application state (data) should only be
mutated using pure stateless functions
● A pure function refers to a function that takes
everything it needs as a parameter and
returns a new copy of data as its output.
12. Typespecs
● Tillägg som kan göra
programmen typsäkra
○ Används ej av kompilatorn
○ Kräver ett extra program
■ Dialyzer (OTP)
○ Dokumentation
● TypeScript vibbar?
17. Microservices by default
Det naturliga designmönstret
i Elixir är att organisera kod i
isolerade processer
“Elixir code is written as
microservices by default
without the extra baggage
that comes with
microservices.”
18. Verktyg
● IEx - Elixir Interactive Shell / REPL
○ Inte bara en REPL
○ Skal (shell) för att kommunicera
med existerande processer
■ Introspektion
● Observer
○ Inspektera systemet
○ :observer.start
20. Populära ramverk och bibliotek
Phoenix
Framework
Ecto
DSL for writing queries
and interacting with
databases in Elixir
Absinthe
GraphQL &
Elixir
21. Editor support
Bra stöd i Visual Studio Code
Ryktet säger att det även finns
stöd för Atom..
22. Böcker, nyhetsbrev och resurser
Introducing Elixir
Learning Elixir
Take Off With Elixir
Programming Phoenix
Functional Web Development With
Elixir, OTP and Phoenix
Elixir Radar (weekly newsletter)
https://elixir-lang.org/learning.html
Elixir School
https://elixirschool.com
http://learnyousomeerlang.com