6 ms·
I understand the advantages of Rust over C or C++, but what are the advantages over OCaml, Standard ML, D and Go?
by xyproto 9y ago
I understand the advantages of Rust over C or C++, but what are the advantages over OCaml, Standard ML, D and Go?
- readams 9y agoRust's borrowing system is pretty unique and allows for safe concurrency in a way that none of those languages can. Compared to Go in particular Rust brings a much more powerful type system as well.
- sametmax 9y agoLower level, possible isolated unsafe code, more compilation checks, supported by Mozilla. More active and enthusiastic community than D, OCaml or Standard ML.
- nicoburns 9y agoOver Go: higher level code, more powerful ergonomic abstractions (generics, macros, etc), and of course the lack of runtime/GC. Over OCaml/Standard ML: more control over performance. It's also imperative first rather than functional first, which isn't neccessarily an advantage, but it is to people coming from a imperative programmig background. Over D: much more momentum behind the ecosystem.
- cynicalkane 9y agoThe design goal of Rust is to have C++-like efficiency with all the benefits of modern programming language theory and practice, as well as some new innovations. In particular, Rust wants to address the two problems of templating/polymorphism/generics and mutability/sharing with zero efficiency or safety sacrifices. (I am not a Rust developer, that's just my impression.) If you like OCaml/Haskell/etc but find yourself wishing you could make mutability and ownership more safe, or write very fast code more easily, and are willing to give up higher-order type system features for it, consider Rust. Go is a very different language than Rust even though both superficially resemble C. If you're using Go because you want something C-like but better, consider Rust.
- jpm_sd 9y agoIf I understand correctly, Go is the new C++ and/or Java, whereas Rust is the new C.
- ChrisSD 9y agoNot really. Rust is mainly "the new" C++ (and is also looking to encroach on C). Go is more like (a better) PHP or Java on a webserver.
- zerr 9y agoNo, it's more like Go is (not enough to be) new Python or node.js.
- weberc2 9y agoGo has very little in common with either of those languages except a GC. Go is statically typed, natively compiled, a good 10-100X faster, and it has great concurrency/parallelism stories. It also lacks classes and exceptions.
- zokier 9y agoFunny, I feel the opposite, Go being more like C and Rust being more like C++; mostly due Go's strive for simplicity while Rust seems more comfortable embracing C++ level of complexity.
- 9y ago
- kllrnohj 9y agoRust's combination of no GC, unsafe escape hatch, and zero-cost C ABI FFI (both function calls and struct layouts) are among its biggest technically differentiating factors. The FFI story seems to be overshadowed, but if you want to use things like Vulkan, DX12, etc... then C FFI performance becomes absolutely critical, and many languages are really bad at it.
- vvanders 9y agoI think the importance of selecting a C FFI is very much undersold. You pretty much get interop with every major language for free. I've embedded Rust in Python, Java, C# and WASM/ASMJS pretty much with just that one feature alone. Also makes the migration story really strong, which I think was largely driven by needing to be integrated into FireFox in a sane way.
- nickpsecurity 9y agoI've gone further to say the freight train of an ecosystem behind and legacy effects of C mean any intended replacement should be fully compatible with its structure, calling conventions, etc. This lets anyone leverage existing C libraries or those in new language seemlessly. From there, the new stuff might all be done in better language with optional, incremental rewrites of older stuff. https://lobste.rs/s/5pnqdv/why_is_sqlite_coded_c#c_vhdcyt https://lobste.rs/s/5pnqdv/why_is_sqlite_coded_c#c_vhdcyt
- earenndil 9y agoAcide from GC, all of those apply to d.
- rs86 9y agoRust enforces proper acquisition and releasing of resources, and that is very cool. For that it uses linear types, which is beyond what ML's type system can achieve. It allows rust to manage memory safely with no GC. The type system can show the compiler when to release resources. I think that can be done in C++ and maybe Haskell but Rust has it baked in. Think about all the low level resource management: network ports, files, heap memory... That's what rust does better. Check ATS for a ML-inspired language with some resource semantics closer to rust and stronger control and correctness primitives. http://www.ats-lang.org http://www.ats-lang.org