4. Elixir
Modern programming language
Erlang Virtual Machine (BEAM)
Erlang compatible
Battle-tested concurrency and distribution model
IEx: Interactive Shell
Mix: Build and package management tool
5. Elixir
2012: R&D project at Plataformatec (Brazil). First public release.
2014: Version 1.0.0. Some real-world usage of Elixir in production systems.
2016: Version 1.2.0
6. Elixir
In Python
" ".join(map(str.capitalize, "hello_there_world".split("_")))
In Elixir
"hello_there_world"
|> String.split("_")
|> Enum.map(&String.capitalize/1)
|> Enum.join(" ")
using the pipeline operator: |>
8. Erlang
Used in 50 % of all telecom switches
Erlang Virtual Machine (BEAM)
Massively Scalable
High Availability
Actor Model
Unfamiliar syntax -- Erlang started life as a modified Prolog, and this shows.
10. Erlang
Functions are defined basically by a mathematical formula
area({square, Side}) -> Side * Side;
area({circle, Radius}) -> math:pi() * Radius * Radius.
“square” and “circle” are atoms since they start with a lowercase letter
“Side” and “Radius” are variables since they start with an uppercase letter
11. Erlang
Decode TCP segments:
decode(<< SourcePort:16, DestinationPort:16,
SequenceNumber:32,
AckNumber:32,
DataOffset:4, _Reserved:4, Flags:8,
WindowSize:16,
Checksum:16, UrgentPointer:16,
Payload/binary>>) when DataOffset>4
“SourcePort:16”: 16 is the number of bits to be matched to the variable SourcePort
“when DataOffset>4”: Guard expression, can use simple tests and variable comparisons
14. Phoenix Framework
Web Framework for Elixir, inspired by Ruby on Rails
MVC (Model - View - Controller)
Optimized for “Developer joy” and productivity
Massively better performance than RoR (and concurrency actually works!)
Plug
Ecto
Channels (Sockets), PubSub, etc.
16. Phoenix Framework
Linux, OS X, Windows
PostgreSQL, MySql, SQL Server
Works great on all combinations
Easy to get started
Easily deployed to Heroku
Efficient! Can even run on a Raspberry PI 2:
540 requests per second on a $35 piece of hardware using on average 90% CPU and only 16 MB RAM
22. One convenient package
Don’t have to worry about dependencies
Mix build system (Elixir dependencies)
Hex package manager (Erlang dependencies)
Code editor: e.g. Atom with language-elixir plugin
25. Real world use
Bleacher Report: http://bleacherreport.com/
Second largest sport website in the world
80 million unique users per month
Far above 100,000 requests per minute
Highly personalized content
Previously used Ruby on Rails
Performance issues, needed lots of caching layers
Phoenix allows a real-time strategy instead of caching
26. Real world use
High-level benefits
Scalability
Fault-tolerance
Functional
Meta-programming
Specific benefits
List manipulation
Highly personalized real-time lists