Elixir has become in one of the most popular functional programming languages for web development; in this short presentation, I will try to make you know more about it.
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
What is the deal with Elixir?
1. What is the deal with Elixir?
Jorge Madrid
@mr_coffeey GitHub.com/MrCoffey
2. Are you happy with the language
you are currently working on?
!
3.
4.
5. “What Elixir brings to the table is a
complete different surface syntax, inspired
by Ruby. What you might call a “non-scary”
syntax, and a load of extra goodies.”
- Joe Armstrong
6. Production level-tested 30 years old technology
Features Inherited From Erlang
Framework for parallel and distributed programming OTP
Quickly scale
Pattern matching
Functional programming language
7. Friendly and familiar syntax
New Features brought by Elixir
Build-in unit testing suite
Support for meta-programming via macros
Doctests
Pipes
Phoenix
Mix
Support for umbrella applications
9. Erlang VM (BEAM)
Can distribute processes across all available CPU cores
Each process only about 1kb
Each process has its own Garbage Collector
It can handle calls from local or remotes nodes
10. Case Study - Bleacher Report
150 AWS Instances
Large engineering teams per app
Multiple complex caching strategies
8 year old Rails app
11. Case Study - Bleacher Report
1/5th the AWS instances (30)
10ms - 30ms average response times
Largest average spike: 400ms
About one engineer per app
No caching
Elixir / Phoenix rewrite
15. Basic Types
Floats
In Elixir, float numbers require a decimal
after at least one digit; they have 64 bit
double precision and support e for exponent
numbers:
17. Basic Types
Atoms
An atom is a constant whose name is their
value. If you’re familiar with Ruby these are
synonymous with Symbols:
Booleans true and false
a r e a l s o t h e
atoms :true and :false
respectively, as well
as module names.
18. Basic Types
String
Strings in Elixir are UTF-8 encoded and are
wrapped in double quotes, in Elixir single
quotes returns a charlist:
21. Basic Types
chartlists
A charlist is nothing more than a list of code
points. Char lists may be created with single-
quoted literals:
22. Basic Types
maps
Whenever you need a key-value store, maps are
the “go to” data structure in Elixir. A map is
created using the %{} syntax:
23. Basic Types
nil
Yes, Elixir also have a dark side 😕 ,
nevertheless, Elixir provides options to handle
and avoid it.
👆via pattern matching
✌returning tuples
35. Control Flow Structures
if and unless
Elixir also provides the macros if/2 and
unless/2 which are useful when you need to
check for only one condition:
39. Mix
Mix is Bundler, RubyGems, and Rake combined into
a executable, You need to have both mix and
elixir executables in your PATH. That’s what
happens when you install Elixir.
43. Modules and Functions
In order to create
our own modules in
Elixir, we use
the defmodule macro.
Here Math defines
the name of the
module.
modules
44. Modules and Functions
named functions
Inside a module, we can define
functions with def/2 and
private functions with defp/2
45. Modules and Functions
compilation
Let’s assume we have a file named math.ex with
the following contents:
T h i s f i l e c a n b e
compiled using elixirc
If we start iex our
module definition will
be available
46. alias, require, and import
In order to facilitate software reuse, Elixir provides three
directives (alias, require and import) plus a macro called use:
Modules and Functions
47. alias
alias, require, and import
In order to facilitate software reuse, Elixir provides three
directives (alias, require and import) plus a macro called use: