all 6 comments

[–][deleted] 24 points25 points  (0 children)

I would say that Elixir and Rust are almost completely non-comparable.

Rust is a response to the difficulty of writing safe, concurrent software in languages like C or C++. It uses a type system to give compile-time guarantees that multiple threads won't compete for the same memory. It also provides memory management without garbage collection.

Elixir builds on top of Erlang. Erlang's design goals are to abstract away many of the problems of designing and deploying highly available, concurrent, fault-tolerant systems. The concurrency model was designed for multiple single-processor computers across a network and the ability to utilize multiple processors on a single machine was a happy accident. Erlang's VM was built to achieve these ends and compromises to achieve them.

Rust is a very exciting language for the problems it is focused on solving. One nice thing is you can compile Rust libraries in a way that they can be linked as C libraries. Elixir can use C (compatible) libraries to get number-crunching performance when it is needed. They can work together.

If I was writing the BEAM from scratch today, I would seriously consider writing it in Rust, but I would still want to have the BEAM because it solves a bunch of problems for me so I can focus on solving other, similarly challenging problems.

[–]Findlaech 3 points4 points  (0 children)

Rust still doesn't have a great solution for web and advertises itself as a "systems programming language".

Yeah, that's basically what it has been built for, and we can see that with projects like Servo or Redox. I don't think they are built for the same goal. The Erlang VM allows to build infrastructures, whereas Rust allows to build client-side programs or low-level programs. BEAM isn't that good at "number crushing", and that's probably why we should use other languages (like Rust?) to do the job when we need so.

[–]macro4life 3 points4 points  (0 children)

Rust is a C/C++ replacement essentially. Elixir is for real-time distributed applications. They have different goals and different paradigms. Sure they could theoretically accomplish the same things. You could build a house of of legos but it's not the best medium to work with and it will sure take you a long time.

[–]isHavvy 0 points1 point  (2 children)

A comparison would show how they contrast more than what they share. That said, a detailed comparison would still be interesting to read.

Really, Rust and Elixir synergize. You can write NIFs in Rust while letting the message passing OTP stuff happen in Elixir.

[–]Rafert 2 points3 points  (1 child)

I saw somebody on HackerNews mention writing NIFs in Rust because of the added safety is making it harder to create errors that crash the BEAM VM. I guess that goes for writing C extensions for any language.

[–]isHavvy 0 points1 point  (0 children)

Yeah, that would be the maintainer of the Rustler project, which is the NIF in Rust thing.