News for hackers. Stuff that matters.
Re:The biggest threat to Rust's sustainability by jgilias on Friday March 19, 2021 @05:44AM (#26511527)
I've done my share of C++ and now Rust, and I don't really get why people keep saying that Rust is a 'cleaned-up C++'. In my opinion this couldn't be further from my subjective truth. I see C++ as an effort to extend C to enable object oriented programming patterns. And everything else being added to it as more and more people have come to appreciate patterns from other programming paradigms. But fundamentally C++ to me is still 'C with classes'.

Whereas Rust, to me at least, is 'ML-ish with curly braces'. So, a language firmly based in the ML heritage with C-like syntax. So, fundamentally working with types and 'typeclasses' and heavily leaning towards filter/map/fold/reduce/lift/unlift type of thinking. Sure, throwing funtions around as first class objects are not as easy or straightforward as it is in 'real FP' languages, but that's a trade-off I'm willing to take for the guarantees that Rust provides.

I'm genuinely curious what's the reasoning behind being able to assert that 'Rust is a cleaned-up C++'.

Re:The biggest threat to Rust's sustainability by floatboth on Friday March 19, 2021 @06:42AM (#26511859)
Rust is rather more like "Haskell-ish C++". (Typeclasses were popularized by Haskell and are not available in SML or OCaml.) While the C++ heritage is obviously the memory management – no runtime, heavy use of scope based deterministic destruction ("RAII"). Also the compile-time metaprogramming that gets monomorphized. (All those template/generic instantiations that can bloat the binaries if overused :D)
Re:The biggest threat to Rust's sustainability by Zababa on Friday March 19, 2021 @08:11AM (#26512352)
For reference, here's the "influences" page of the Rust reference: https://doc.rust-lang.org/reference/influences.html

SML, OCaml, C++ and Haskell are all mentionned.

Re:The biggest threat to Rust's sustainability by jgilias on Friday March 19, 2021 @06:54AM (#26511909)
I've been bashed before for saying something along the lines of "Haskell-ish C++". Their fair point being that the only Haskell influence is the typeclasses, and all other ML-influences are just ML-influences that are not unique to Haskell. Fair enough :)
Re:The biggest threat to Rust's sustainability by TinkersW on Friday March 19, 2021 @06:11AM (#26511685)
Have you not seen much modern C++? If you are used to this style of C++, Rust is a very obvious variant of it, but with more static guarantees with regards to safety. Working heavily with types has been common in C++ for a couple decades now, and there are libraries with bring in filter/map/fold/reduce/lift/unlift style.
Re:The biggest threat to Rust's sustainability by jgilias on Friday March 19, 2021 @06:22AM (#26511750)
The code I've had to work with was definitely more on the OOP paradigm side. Can you provide an example project with a more 'modern' C++ code base that I could check out?
Re:The biggest threat to Rust's sustainability by pron on Friday March 19, 2021 @05:57AM (#26511606)
You're doing the comparison from the bottom-up, perhaps like how a programming language connoisseur would look at them -- how the linguistic features of C++ and Rust were constructed -- while I'm looking at them from the top down, how just a programmer who doesn't particularly care about PL theory would: what is their design philosophy? Both are low-level languages (so, low-abstraction), which try hard through various syntactical techniques and a nice dose of implicitness to make code, once written, appear high-level on the page. I find those two languages almost indistinguishable in terms of "feel." It doesn't feel like Python, it doesn't feel like Java or Go, and it doesn't feel like C; it feels like C++.
Re:The biggest threat to Rust's sustainability by jgilias on Friday March 19, 2021 @06:46AM (#26511878)
I do agree that Rust 'feels' more like C++ than Python or Java. But then, from my limited experience with dabbling into Haskell, to me it feels more like Haskell than C++. In Rust, from the language perspective, I have to deal with things like these:

- Doing Option<T> -> Option<U>

- At what point do I do Option<T> -> Result<T>

- Should I transpose Vec<Option<T>> to Option<Vec<T>> now or later?

- Often reaching for algebraic data types

- How to map over this to collect it into what I need

- Ah, it needs to implement Hash, Eq, PartialEq ... SomeTrait to make it work the way I want

- Pattern matching all over the place

All of which to me mentally feels more like something along the lines of F#, OCaml or Haskell than C++ that 'normal people write'.

Re:The biggest threat to Rust's sustainability by golergka on Friday March 19, 2021 @06:07AM (#26511662)
Because people know C++ but don't know ML.
Re:The biggest threat to Rust's sustainability by pjmlp on Friday March 19, 2021 @09:57AM (#26513363)
Depends on the people.

When I did my degree, C++ was taught in the second year and Caml Light in the third.

Re:The biggest threat to Rust's sustainability by carapace on Friday March 19, 2021 @10:45AM (#26513904)
It's like C++ is a gas-powered chainsaw and Rust is a newfangled electric "smart" chainsaw.
Re:The biggest threat to Rust's sustainability by steveklabnik on Friday March 19, 2021 @11:02AM (#26514114)
I often use "table saw" when making this sort of analogy, because there's even a more direct comparison: https://www.sawstop.com/
Re:The biggest threat to Rust's sustainability by carapace on Friday March 19, 2021 @02:30PM (#26516804)
(As an aside, WOW! What a great invention! The folks who sent in pictures of their tiny cuts (instead of severed fingers) nearly made me cry.)

That's a brilliant metaphor to drive home the safety advantages of Rust! "It's a table saw that won't chop off your fingers!"

That's a "shut up and take my money" proposition. (And it helps that it's a really good table saw too.)

(As another aside, I got to the testimonial from an employer talking about the peace of mind of knowing the workers on the shop floor are safe and it "clicked" for me: you've got metrics and liability for job site safety so you can quantify that peace of mind. We still not there with software quality liability eh?)

Re:The biggest threat to Rust's sustainability by wealthyyy on Friday March 19, 2021 @05:27PM (#26518292)
Reminds me that unprofitable hotness electric car company whose core business is to manipulate both balance sheet and government.