Supriya Ghosh (Editor)

Elixir (programming language)

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Typing discipline
  
dynamic, strong

License
  
Apache License 2.0

Platform
  
Erlang

Paradigm
  
multi-paradigm: functional, concurrent, distributed, process-oriented

First appeared
  
2011; 6 years ago (2011)

Stable release
  
1.4.0 / 5 January 2017; 2 months ago (2017-01-05)

Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang virtual machine (BEAM). Elixir builds on top of Erlang and shares the same abstractions for building distributed, fault-tolerant applications. Elixir also provides a productive tooling and an extensible design. The latter is supported by compile-time metaprogramming with macros and polymorphism via protocols.

Contents

Elixir is successfully used in the industry by companies such as Pinterest and Moz. Elixir is also used for web development, by companies such as Bleacher Report and Inverse, and for building embedded-systems. The community organizes yearly events in both United States and Europe as well as minor local events and conferences.

History

José Valim is the creator of the Elixir programming language, an R&D project of Plataformatec. His goals were to enable higher extensibility and productivity in the Erlang VM while keeping compatibility with Erlang's ecosystem.

Features

  • A language that compiles to bytecode for the Erlang Virtual Machine (BEAM)
  • Everything is an expression
  • Erlang functions can be called from Elixir without run time impact, due to compilation to Erlang bytecode, and vice versa
  • Meta programming allowing direct manipulation of AST
  • 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.
  • Support for documentation via Python-like docstrings in the Markdown formatting language
  • Shared nothing concurrent programming via message passing (Actor model)
  • Emphasis on recursion and higher-order functions instead of side-effect-based looping
  • Lightweight concurrency utilizing Erlang's mechanisms.
  • Lazy and async collections with streams
  • Pattern matching
  • Unicode support and UTF-8 strings
  • 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 <filename>.

    Classic Hello world example:

    Comprehensions

    Pattern Matching

    Modules

    Sequentially spawning a thousand processes

    Asynchronously performing a task

    References

    Elixir (programming language) Wikipedia