News for hackers. Stuff that matters.
Re:I've just learned Rust and I think I'm in love by xyproto on Friday March 30, 2018 @12:35PM (#16717569)
I understand the advantages of Rust over C or C++, but what are the advantages over OCaml, Standard ML, D and Go?
Re:I've just learned Rust and I think I'm in love by kllrnohj on Friday March 30, 2018 @01:17PM (#16717932)
Rust'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.

Re:I've just learned Rust and I think I'm in love by vvanders on Friday March 30, 2018 @01:47PM (#16718220)
I 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.

Re:I've just learned Rust and I think I'm in love by nickpsecurity on Friday March 30, 2018 @03:41PM (#16719180)
I'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

Re:I've just learned Rust and I think I'm in love by earenndil on Friday March 30, 2018 @11:24PM (#16721509)
Acide from GC, all of those apply to d.
Re:I've just learned Rust and I think I'm in love by nicoburns on Friday March 30, 2018 @12:47PM (#16717679)
Over 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.

Re:I've just learned Rust and I think I'm in love by readams on Friday March 30, 2018 @12:37PM (#16717590)
Rust'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.
Re:I've just learned Rust and I think I'm in love by cynicalkane on Friday March 30, 2018 @12:51PM (#16717711)
The 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.

Re:I've just learned Rust and I think I'm in love by jpm_sd on Friday March 30, 2018 @12:54PM (#16717735)
If I understand correctly, Go is the new C++ and/or Java, whereas Rust is the new C.
Re:I've just learned Rust and I think I'm in love by ChrisSD on Friday March 30, 2018 @12:57PM (#16717758)
Not 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.

Re:I've just learned Rust and I think I'm in love by ovao on Friday March 30, 2018 @01:53PM (#16718284)
Go could be considered a modern C, in that it follow's C's spirit of simplicity and clarity at the expense of power and expressiveness, but it is often not used as a replacement of C for various reasons. One of Go's stated design goals was (and is) to achieve performance parity with C, but it falls short of reaching that goal in many cases.

With its type system and support for generics (in C++: templates), Rust has much more in common with C++ than it does with C.

Re:I've just learned Rust and I think I'm in love by staticassertion on Friday March 30, 2018 @02:02PM (#16718376)
> in that it follow's C's spirit of simplicity and clarity at the expense of power and expressiveness

Wow, I strongly feel the opposite about C. It is hardly simple or clear - understanding what your code will do after the compiler's done with it seems almost impossible, reasoning about runtime behavior similarly so. The complexity involved in managing memory, etc, is so significant.

But it is extremely powerful.

I see go as being extremely simple, but also very weak in terms for expressiveness, relying on the runtime for memory and concurrency management.

I agree that Rust has more in common with C++.

Re:I've just learned Rust and I think I'm in love by ovao on Friday March 30, 2018 @03:00PM (#16718838)
I was shooting for a simple answer, but perhaps some more clarification would be useful.

I describe C as "simple" in the sense that it's A) not a large language, by specification and B) somewhat by virtue of the former, there's generally a small range of possible implementations of any given problem (which helps C programs have "clarity"). Go is very C-like in that it also has both of these attributes, quite deliberately. C could be considered complex, however, by virtue of the amount of behavior that is unspecified/at the compiler's discretion. In that sense its safety often is difficult to reason about, but C programs themselves are generally easy to reason about. Go luckily doesn't have many opportunities for programs to be "complex" in that way.

C is "powerful" in the sense that it offers programmers deep control over memory. Given that, (effectively) anything that can be implemented in any other language can be implemented in C, with varying levels of difficulty. It isn't "powerful" from the language perspective itself — in terms of expressiveness or the features that it affords programmers — in the same way that C++ or Rust are "powerful".

A lot of the adjectives we use to describe languages aren't particularly well-defined, so some disagreement about them is almost a given. But hopefully that clarifies.

Re:I've just learned Rust and I think I'm in love by staticassertion on Friday March 30, 2018 @06:42PM (#16720430)
Yeah, that makes a lot of sense to me. Thanks.
Re:I've just learned Rust and I think I'm in love by zerr on Friday March 30, 2018 @01:04PM (#16717834)
No, it's more like Go is (not enough to be) new Python or node.js.
Re:I've just learned Rust and I think I'm in love by weberc2 on Friday March 30, 2018 @06:00PM (#16720146)
Go 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.
Re:I've just learned Rust and I think I'm in love by zerr on Saturday March 31, 2018 @01:47AM (#16721938)
I meant the possible target audience. While their initial goal was to attract C++ engineers, eventually they attracted (some) python or node.js devs.
Re:I've just learned Rust and I think I'm in love by weberc2 on Tuesday April 03, 2018 @09:28AM (#16744395)
Ah, I understand and agree. Thanks for clarifying!
Re:I've just learned Rust and I think I'm in love by zokier on Friday March 30, 2018 @01:51PM (#16718268)
Funny, 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.
Re:I've just learned Rust and I think I'm in love by rs86 on Friday March 30, 2018 @06:03PM (#16720162)
Rust 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

Re:I've just learned Rust and I think I'm in love by sametmax on Friday March 30, 2018 @12:39PM (#16717600)
Lower level, possible isolated unsafe code, more compilation checks, supported by Mozilla. More active and enthusiastic community than D, OCaml or Standard ML.