PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Elixir

Elixir

Elixir is a pl created in 2011 by José Valim.

#38on PLDB 11Years Old 55.9kUsers
31Books 3Papers 89kRepos

Try now: Riju · TIO

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. Read more on Wikipedia...


Example from Riju:
IO.puts("Hello, world!")
Example from hello-world:
#!/usr/bin/env elixir IO.puts "Hello World"
Example from the Hello World Collection:
# Hello world in Elixir defmodule HelloWorld do IO.puts "Hello, World!" end
Example from Linguist:
%{"cowboy": {:hex, :cowboy, "1.0.0"}, "cowlib": {:hex, :cowlib, "1.0.1"}, "hackney": {:hex, :hackney, "0.14.3"}, "hound": {:hex, :hound, "0.6.0"}, "httpoison": {:hex, :httpoison, "0.5.0"}, "idna": {:hex, :idna, "1.0.1"}, "phoenix": {:hex, :phoenix, "0.10.0"}, "plug": {:hex, :plug, "0.11.1"}, "poison": {:hex, :poison, "1.3.1"}, "ranch": {:hex, :ranch, "1.0.0"}}
Example from Wikipedia:
task = Task.async fn -> perform_complex_action() end other_time_consuming_action() Task.await task

Keywords in Elixir

after and catch do else end false fn in nil not or rescue true when

Language features

Feature Supported Example Token
Unicode Identifers
δ = 0.00001
Case Sensitivity
Exceptions
raise "oops, something went wrong"
Pattern Matching
def fib(0), do: 1
def fib(1), do: 1
def fib(n) when n >= 2, do: fib(n-1) + fib(n-2)
Runtime Guards
def abs(number) when number > 0, do: number
def abs(number), do: -number
Garbage Collection
Multiline Strings
template = """
This is the first line.
This is the second line.
This is the third line.
"""
Infix Notation
seven = 3 + 4
Scientific Notation
1.23e45
Anonymous Functions
fn -> IO.puts("hello world") end
Pipes
"Elixir" |> String.graphemes() |> Enum.frequencies()
Streams
https://hexdocs.pm/elixir/Stream.html
Macros
https://hexdocs.pm/elixir/Macro.html
Polymorphism
https://hexdocs.pm/elixir/Protocol.html
Range Operator
1..3
Single Dispatch
Maps
%{key: "value"}
Booleans true false
Binary Literals
# 0b[01]+
Integers
# \d(_?\d)*
Floats
# \d(_?\d)*\.\d(_?\d)*([eE][-+]?\d(_?\d)*)?
Hexadecimals
# 0x[\da-fA-F]+
Octals
# 0o[0-7]+
Strings
"Hello world"
"
Lists
my_list = [1, 2, 3, 4, 5]
Regular Expression Syntax Sugar
~r/integer: \d+/
Print() Debugging IO.puts
Message Passing
send(pid, :ping)
Line Comments
# A comment
#
Default Parameters Pattern
def multiply(a, b \\ 1) do
  a * b
end
Conditionals
if true do
  IO.puts("Hello world")
end
Assignment
name = "John"
File Imports
# Alias the module so it can be called as Bar instead of Foo.Bar
alias Foo.Bar, as: Bar

# Require the module in order to use its macros
require Foo

# Import functions from Foo so they can be called without the `Foo.` prefix
import Foo

# Invokes the custom code defined in Foo as an extension point
use Foo
Comments
# this is a comment
Disk Output
File.write!("helloworld.txt", "Hello, world!\n")
Shebang
#!/usr/bin/env elixir
Case Insensitive Identifiers ϴ
Multiple Dispatch ϴ
Units of Measure ϴ
Pointers ϴ
Semantic Indentation ϴ
MultiLine Comments ϴ

Books about Elixir from ISBNdb

title authors year publisher
Learning Elixir Ballou, Kenny 2016 Packt Publishing
"Programming Elixir 1.2: Functional > Pragmatic > Fun" https://isbndb.com/book/9781680501667 Thomas, Dave 2016 Pragmatic Bookshelf
"Programming Elixir 1.3: Functional > Pragmatic > Fun" https://isbndb.com/book/9781680502008 Thomas, Dave 2016 Pragmatic Bookshelf
"Programming Elixir ≥ 1.6: Functional > Pragmatic > Fun" https://isbndb.com/book/9781680502992 Thomas, Dave 2018 Pragmatic Bookshelf
The Little Elixir & OTP Guidebook Tan Wei Hao, Benjamin 2016 Manning Publications
Elixir Cookbook Pereira, Paulo A 2015 Packt Publishing
Elixir in Action Juric, Saša 2015 Manning
Programming Phoenix LiveView: Interactive Elixir Web Programming Without Writing Any JavaScript Tate, Bruce A. and DeBenedetto, Sophie 2022 Pragmatic Bookshelf
Learning Elixir Ballou, Kenny 2016 Packt Publishing
Erlang and Elixir for Imperative Programmers Loder, Wolfgang 2016 Apress
Phoenix Web Development: Create rich web applications using functional programming techniques with Phoenix and Elixir Voloz, Mike and Richey, Brandon 2018 Packt Publishing
Adopting Elixir Ben Marx; Jose Valim; Bruce Tate 20180314 Pragmatic Bookshelf
Introducing Elixir Simon St. Laurent; J. David Eisenberg 20161222 O'Reilly Media, Inc.
Introducing Elixir Laurent, Simon St.; Eisenberg, J. David 20151216 O'Reilly Media, Inc.
Introducing Elixir Simon St. Laurent 20140910 O'Reilly Media, Inc.
Mastering Elixir Andre Albuquerque; Daniel Caixinha 30-07-2018 Packt Publishing
Programming Ecto: Build Database Apps in Elixir for Scalability and Performance Wilson, Darin and Meadows-Jonsson, Eric 20190416 Pragmatic Bookshelf
Programmer Passport: Elixir Bruce Tate 20220622 Pragmatic Bookshelf
Designing Elixir Systems With OTP James Edward Gray II; Bruce A. Tate 20191202 Pragmatic Bookshelf
Concurrent Data Processing in Elixir Svilen Gospodinov 20210725 Pragmatic Bookshelf
Craft GraphQL APIs in Elixir with Absinthe Bruce Williams; Ben Wilson 20180327 Pragmatic Bookshelf
Build a Weather Station with Elixir and Nerves Alexander Koutmos; Bruce Tate; Frank Hunleth 20220106 Pragmatic Bookshelf
Build a Binary Clock with Elixir and Nerves Frank Hunleth; Bruce Tate 20220802 Pragmatic Bookshelf
Property-Based Testing with PropEr, Erlang, and Elixir Fred Hebert 20190117 Pragmatic Bookshelf
Designing Elixir Systems With OTP James Edward Gray II; Bruce A. Tate 20191202 Pragmatic Bookshelf
Genetic Algorithms in Elixir Sean Moriarity 20210120 Pragmatic Bookshelf
Exploring Graphs With Elixir Tony Hammond 20221025 Pragmatic Bookshelf
Testing Elixir Andrea Leopardi; Jeffrey Matthias 20210330 Pragmatic Bookshelf
Metaprogramming Elixir Chris McCord 20150129 Pragmatic Bookshelf
Learn Functional Programming with Elixir Ulisses Almeida 20180201 Pragmatic Bookshelf
Functional Web Development with Elixir, OTP, and Phoenix Lance Halvorsen 20180101 Pragmatic Bookshelf

Publications about Elixir from Semantic Scholar

title authors year citations influentialCitations
Elixir programming language evaluation for IoT Geovane Fedrecheski and L. Costa and M. Zuffo 2016 6 0
A Gradual Type System for Elixir Mauricio Cassola and Agustín Talagorria and Alberto Pardo and Marcos Viera 2020 2 0
An Elixir library for programming concurrent and distributed embedded systems Humberto Rodríguez-Avila and E. G. Boix and W. Meuter 2017 1 0
powershell.html · elixir.html · erlang.html

View source

PLDB - Build the next great programming language · v2022 · Day 33 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com