Elixir is an open source programming language created in 2011 by José Valim.
| #29on PLDB | 15Years Old | 89kRepos |
git clone https://github.com/elixir-lang/elixirElixir 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...
IO.puts("Hello, world!")
#!/usr/bin/env elixir
IO.puts "Hello World"
%{"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"}}
task = Task.async fn -> perform_complex_action() end
other_time_consuming_action()
Task.await taskafter and catch do else end false fn in nil not or rescue true when| Feature | Supported | Example | Token |
|---|---|---|---|
| Standard Library | ✓ | IO.puts "Hello, World!" | |
| 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.23e+45 | |
| 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 defmodule Example do defmacro macro_inspect(value) do IO.inspect(value) value end def fun_inspect(value) do IO.inspect(value) value end end | |
| 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 | ✓ | # A comment | |
| Disk Output | ✓ | File.write!("helloworld.txt", "Hello, world!\n") | |
| Shebang | ✓ | #!/usr/bin/env elixir | |
| Case Insensitive Identifiers | X | ||
| Multiple Dispatch | X | ||
| Units of Measure | X | ||
| Pointers | X | ||
| Semantic Indentation | X | ||
| MultiLine Comments | X |