Both nim and rust are new (less than 10 years), and compile to native machine code to avoid dependency problems, and claim to be efficient.
Both support generics, macros, FP and OOP.
They seem very similar to me. So, could anyone with experience in both languages compare them and make some comments? particularly the advantages of nim over rust!
While Rust has some support for macros, they aren't nearly as powerful as they are in Nim. You can do some pattern matching and rewriting in Rust, but you cannot generate AST trees programmatically.
Rust, by design, exceeds in memory safety. Nim allows ptr and ref types, while Rust's memory model has a higher abstraction where the developer tells the language the owner / lifetime of a value, and the language cares for the gory details itself. On the other hand, the learning curve is steeper, and you have to think more about lifetimes and ownership whenever you write code.
For the same reason, foreign function calls are not as easy as they are in Nim. You have to write them in an unsafe scope.
Generics are, afaik, pretty similar to what Nim offers. Nim's concepts are a very similar concept to Rust's traits.
Afaik, Rust lacks the following Nim features:
I cannot say anything about concurrency, because I neither have used it in Nim nor in Rust yet. One last thing I can say about Rust is that I strongly dislike its (C-like) syntax. But that's a question of personal preference.
Hi Guys!
Recently I played a lot with new languages. I really like Rust's promise about memory safety, it has a decent iterator library, Option for error handling, etc. If I could choose a language where I had to work with thousands of coders on the same codebase, it would be Rust. However, compared to Nim, I always feel that I have to type a lot in Rust. The resulting Nim code is much smaller, easier to overview. Also Nim has better templates & macros!
Peter
In rust, you are a servant, supplicating the language designers to allow you to program in a certain way, working hard to satisfy their demands.
In Nim, you are a king.