ⓘ Elixir (programming language)

Elixir (programming language)

ⓘ 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.


1. History

Jose 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 Erlangs ecosystem.

Jose 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.


2. 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.


3. Features

  • Support for documentation via Python-like docstrings in the Markdown formatting language
  • Everything is an expression
  • Railway oriented programming via the with construct
  • Built-in tooling for managing dependencies, code compilation, running tests, formatting code, remote debugging and more
  • Shared nothing concurrent programming via message passing Actor model
  • Pattern matching to promote assertive code
  • Polymorphism via a mechanism called protocols. Like in Clojure, protocols provide a dynamic dispatch mechanism. However, this is not to be confused with multiple dispatch as Elixir protocols dispatch on a single type.
  • Unicode support and UTF-8 strings
  • Meta programming allowing direct manipulation of abstract syntax tree AST
  • Lazy and async collections with streams
  • Lightweight concurrency utilizing Erlangs mechanisms
  • A language that compiles to bytecode for the Erlang Virtual Machine BEAM
  • Erlang functions can be called from Elixir without run time impact, due to compilation to Erlang bytecode, and vice versa
  • Emphasis on recursion and higher-order functions instead of side-effect-based looping


4. Examples

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:


Pattern Matching destructuring

Pattern Matching multiple clauses

Pipe Operator


Sequentially spawning a thousand processes

Asynchronously performing a task


5. Noteworthy Elixir projects

  • Mix is a build automation tool that provides tasks for creating, compiling, and testing Elixir projects, managing its dependencies, and more.
  • Nerves is a platform, framework, and tooling environment for building embedded systems and devices.
  • Ecto is the database wrapper and query generator for Elixir.
  • Phoenix is a web development framework written in Elixir which implements the server-side Model View Controller MVC pattern.