When comparing Nim vs Elixir, the Slant community recommends Elixir for most people. In the question“What is the best programming language to learn first?” Elixir is ranked 9th while Nim is ranked 22nd. The most important reason people chose Elixir is:
Leverages the existing Erlang BEAM VM
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Great metaprogramming features
There are generics, templates, macros in Nim. They can allow you to write new DSL for your application, or avoid all boilerplate stuff.
Pro Strict typing
Checks your code at compile time.
Pro Has built-in unittest module
With built-in "unittest" module you can create test with a very readable code.
Pro Compile-time execution
Nim has a built-in VM, which executes macros and some other code at compile time. For example, you can check if you're on Windows, and Nim will generate code only for it.
Pro Has built-in async support
Nim has "asyncdispatch" module, which allows you to write async applications.
Pro Really cross-platform
The same code can be used for web, server, desktop and mobile.
Pro Easy to read
Nim has a lot of common with Python in terms of syntax. Indentation-based syntax, for/while loops.
Pro Multi paradigm
Imperative, OOP, functional programming in one language.
Pro Easy to integrate with another languages
You can use Nim with any language that can be interfaced with C. There's a tool which helps you to create new C and C++ bindings for Nim - c2nim.
Also, you can use Nim with Objective C or even JavaScript (if you're compiling for these backends).
Pro Garbage-collected
You don't need to deal with all those manual memory allocations, Nim can take care of it. But also you can use another GC, or tweak it for your real-time application or a game.
Pro Type interferencing
You only need to specify types in your procedures and objects - you don't need to specify type when you're creating a new variable (unless you're creating it without initialization).
Pro Built-in Unicode support
You can use unicode names for variables, there is "unicode" module for operations with unicode.
Pro Supports UFCS (Unified Function Call Syntax)
writeLine(stdout, "hello") can be written as stdout.writeLine("hello")
proc add(a: int): int = a + 5 can be used like 6.add.echo or 6.add().echo()
Pro Great for concurrency
Leverages the existing Erlang BEAM VM
Pro Great getting started tutorials
The tutorials are very clear and concise (even for a person not used to functional programming). Plus they are also very mobile friendly.
Pro Powerful metaprogramming
Write code that writes code with Elixir macros. Macros make metaprogramming possible and define the language itself.
Pro Full access to Erlang functions
You can call Erlang functions directly without any overhead: https://elixir-lang.org/getting-started/erlang-libraries.html
Pro Scalability
Elixir programming is ideal for applications that have many users or are actively growing their audience. Elixir can easily cope with much traffic without extra costs for additional servers.
More details can be found here.
Pro Great as a first functional programming language!
Pro Great documentation
Elixir's documentation is very good. It covers everything and always helps solving any problem you may have. It's also always available from the terminal.
Pro Syntax is similar to Ruby, making it familiar for people used to OOP
All of the benefits of Erlang; without as steep a learning curve of prolog based syntax. Elixir is heavily inspired by Ruby's syntax which many people love.
Pro Easy to download libraries
Comes with built in build tool called "mix". This will automatically download libraries and put them in the scope of the application when you add them to the "deps" function and run mix deps.get
Cons
Con Deployment is still not as easy as it should be
Con Some design choices may seem strange
Some design choices could have been a little more appealing, for example: using "do...end" comes natural in Ruby for blocks but Elixir uses them for everything and it looks pretty weird:
Enum.map [1, 2, 3], fn(x) -> x * 2 end
or
receive do
{:hello, msg} -> msg
{:world, msg} -> "won't match"
end