3. What
- Programming language born in ~1986 and in use for ~30 years
- Designed by Ericsson for a specific kind of systems (industrial/business
driven design)
4. Goals
- Easier to reason about
- Easier to do it right
- More maintainable
- More concise
5. How
- Immutable data
- Actor model concurrency
- Really lightweight (think millions)
- Shares nothing (no locks, no mutexes)
- Communicate with asynchronous messages
- Hot swapping (upgrade without downtime)
- Extremely good at fault handling (let it crash)
- Incredibly robust platform (BEAM)
6. What’s wrong with Erlang?
Nothing! As nothing is wrong with C or ASSEMBLY
20. What is the difference between cond and case?
cond receives no arguments, and it allows
you to use a different condition in each
branch.
case receives an argument, and every
branch is pattern-matched against the
argument.
22. Keyword lists
- Keys must be atoms.
- Keys are ordered, as specified by
the developer.
- Keys can be given more than once.
23. Maps
- Maps allow any value as a key.
- Maps’ keys do not follow any ordering.
24.
25. Maps
- If you pass duplicate keys when creating a map, the last one wins:
- When all the keys in a map are atoms, you can use the keyword syntax for
convenience:
26. Dicts
In Elixir, both keyword lists and maps are called dictionaries. In other words, a
dictionary is like an interface (we call them behaviours in Elixir) and both keyword
lists and maps modules implement this interface.
33. alias, require and import
- alias allows you to set up
aliases for any given module
name. Imagine our Math
module uses a special list
implementation for doing math
specific operations:
34. require
In general a module does not need to be required before usage, except if we want
to use the macros available in that module
35. import
We use import whenever we want to easily access functions or macros from other
modules without using the fully-qualified name.
38. Protocols
Protocols are a mechanism to achieve polymorphism in Elixir. Dispatching on a
protocol is available to any data type as long as it implements the protocol. Let’s
see an example.