Elixir (programming language)

Elixir
Paradigm multi-paradigm: functional, concurrent, process-oriented, homoiconic
First appeared 2012
1.0.4
dynamic, strong
Platform Erlang
License Apache License
.ex, .exs
Website elixir-lang.org

Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang Virtual Machine (BEAM). Elixir builds on top of Erlang to provide distributed, fault-tolerant, soft real-time, non-stop applications but also extends it to support metaprogramming with macros and polymorphism via protocols.[1]

History

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

Features

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:

IO.puts "Hello World!"

Comprehensions

for n <- [1,2,3,4,5], rem(n,2) == 1, do: n*n
#=> [1, 9, 25]

Pattern Matching

[1, a] = [1, 2]
# 'a' now equals 2
 
{:ok, [hello: a]} = {:ok, [hello: "world"]}
# 'a' now equals "world"

Modules

defmodule Fun do
  def fib(0) do 0 end
  def fib(1) do 1 end
  def fib(n) do fib(n-2) + fib(n-1) end   
end

References

  1. "Elixir". José Valim. Retrieved 2013-02-17.
  2. "Elixir - A modern approach to programming for the Erlang VM". Retrieved 2013-02-17.
  3. 3.0 3.1 3.2 3.3 3.4 3.5 "Elixir". Retrieved 2014-09-07.
  4. "Elixir Enumerable". Retrieved 2014-09-07.

External links