Elixir (programming language)


Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang virtual machine. Elixir builds on top of Erlang and shares the same abstractions for building distributed, fault-tolerant applications. Elixir also provides productive tooling and an extensible design. The latter is supported by compile-time metaprogramming with macros and polymorphism via protocols.
Elixir is used by companies such as PagerDuty, Discord, E-MetroTel, Pinterest, Moz, Bleacher Report, The Outline, Inverse, Divvy, FarmBot and for building embedded systems. The community organizes yearly events in the United States, Europe and Japan as well as minor local events and conferences.

History

José Valim is the creator of the Elixir programming language, a research and development project of Plataformatec. His goals were to enable higher extensibility and productivity in the Erlang VM while keeping compatibility with Erlang's ecosystem.
José Valim aimed to create a programming language for large-scale sites and apps. Being a Ruby developer, he used the best features of Ruby, Erlang, and Clojure to develop a high-concurrency and low-latency language. Elixir was designed to handle large data volumes. Its speed and capabilities spread Elixir in telecommunication, eCommerce, and finance industries.
On July 12, 2018, Honeypot released a mini-documentary on Elixir.

Versioning

Elixir mostly follows semantic versioning and has only 1 major version with no plans for a second. Each of the minor versions supports a specific range of Erlang/OTP versions.

Features

The following examples can be run in an iex shell or saved in a file and run from the command line by typing elixir .
Classic Hello world example:

iex> IO.puts
Hello World!

Comprehensions

iex> for n <- , rem 1, do: n*n

Pattern Matching

iex> =
iex> a
iex> =
iex> a
"world"

Pattern Matching

iex> case File.read do
iex> -> IO.puts
iex> -> IO.puts
iex> end

Pipe Operator

iex> "1" |> String.to_integer |> Kernel.*

Modules

defmodule Fun do
def fib, do: 0
def fib, do: 1
def fib, do: fib + fib
end

Sequentially spawning a thousand processes

for num <- 1..1000, do: spawn fn -> IO.puts end

Asynchronously performing a task

task = Task.async fn -> perform_complex_action end
other_time_consuming_action
Task.await task

Noteworthy Elixir projects