Elixir is a programming language that stems from Erlang. Erlang is traditionally one of the more scable languages, and has powered the Telecom industry for years.
It’s a functional language that’s pretty fun / easy to write. It has some more complicated constructs in the form of OTP, but to get started it’s super easy. The syntax is very familiar to Ruby, but that’s where the similarities end
One of my favorite things is pattern matching
# In this example a User has been defined as
# %User{name: "John Doe", age: 42, other_attribute: "something"}
# This allows you to grab only what you need, for example the users name
%User{name: name} = User.get("John Doe")
name #=> "John Doe"
# This makes writing functions way funner, because you only have to worry
# about when the input is what you expect
def serve_drinks(%User{age: age}) when age >= 21 do
# Code that serves drinks!
end
def serve_drinks(%User{age: age}) do
# Don't serve drinks!
end
serve_drinks(User.get("John Doe"))
#=> Fails if the user is under 21