Clone this wiki locally
1. What are the main problem domains Elixir is suitable for?
- data processing
- network related tasks: from plain sockets to web servers and frameworks
- writing reliable, distributed, and highly available software.
2. Can Elixir be used to write programs that rely heavily on fast numerical computations?
Elixir will most likely show worse performance compared to a compiled imperative language when performing a strictly sequential (CPU) or uniformly parallel (GPU) computation. However, there are lots of use-cases where Erlang's concurrency features (that Elixir takes full advantage of) might be put to good use in mathematical computation contexts.
Here are a few resources on the subject that describe technical computing in Erlang (applies to Elixir as well).
- From Telecom Networks to Neural Networks; Erlang, as the unintentional Neural Network Programming Language [video]
- High-performance Technical Computing with Erlang [slides]
- When does Erlang's parallelism overcome its weaknesses in numeric computing? [stackoverflow.com]
- Go, F# and Erlang -- implementation of matrix multiplication and prime number test in each of the three languages [paper]
3. How do I start a shell (IEx) with my project and all its dependencies loaded and started?
iex -S mix inside your project's directory.
3.1. How to have my IEx session history to be persistent over different IEx sessions?
There's a very nice module [erlang-history] that does the trick for both elixir and erlang shells.
4. Why is my list of integers printed as a string?
iex(1)> [27, 35, 51] '\e#3'
Pretty-printing of lists is done by using Erlang's native function. It is designed to print lists as strings when all elements of the list are valid ASCII codes.
You can avoid this by appending
0 to your list, or by disabling char list printing:
iex(2)> [27, 35, 51] ++  [27, 35, 51, 0] iex(3)> inspect [27, 35, 51], char_lists: :as_lists "[27,35,51]"
Also see this post to the Elixir-Lang mailing list for a bit more on the reasoning behind this design choice: https://groups.google.com/d/msg/elixir-lang-talk/0xxH9HxdQnU/LHgK8elhEQAJ
5. Which functions are allowed in guards?
The Erlang VM only allows a limited set of expressions in guards. For an up to date list please read Expressions in guard clauses in the Elixir Website.
For a few good reasons, Elixir doesn't include an
append function in the
List module. In no particular order:
Due to the underlying implementation of Elixir's lists, appending to a list is an O(n) operation. It's always much more efficient to prepend to the list and reverse the list. Prepending is O(1).
If you need to append to a list there's the
++operator available. Since that's implemented in Erlang and Elixir avoids re-implementing things in Erlang unless it's necessary, we suggest people use the ++ to append to a list e. g.
l ++ [new_list]