Skip to content
José Valim edited this page Sep 17, 2019 · 38 revisions

1. What are the main problem domains Elixir is suitable for?

In short:

  • data processing
  • embedded software and systems
  • 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]

Furthermore, most languages rely on Fortran or C libraries to perform numeric computing, and those can be integrated into the Erlang VM via NIFs (Native Implemented Functions).

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?

If you have OTP 20 or greater installed you can run export ERL_AFLAGS="-kernel shell_history enabled" from your shell's profile.

4. Why is my list of integers printed as a string?

For example:

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] ++ [0]
[27, 35, 51, 0]

iex(3)> inspect [27, 35, 51], charlists: :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.

Clone this wiki locally