6 ms·
I think that Rust's features allow for cleaner code bases.
by adamnemecek 6y ago
I think that Rust's features allow for cleaner code bases.
- Thaxll 6y agoI don't see why Rust would be cleaner than modern C++ codebase.
- leetcrew 6y agoc++ is a bit more verbose than rust. think about all the stdlib functions that take begin and end iterators for containers. there's an overload for std::set_difference that takes six arguments, five of them being iterators.
- pjmlp 6y agoRanges and fold expressions take care of that.
- adamnemecek 6y agoThere is a lot more than just those two.
- pjmlp 6y agoI was replying to the provided examples, more examples get more counterexamples.
- leetcrew 6y agothat's true and I am very excited for ranges. sadly I am still waiting for c++17 to be switched on in my build system :/ still there's lots of other stuff that's more verbose in c++ than rust, often because it was bolted on much later. think about getting individual elements out of a tuple. in c++: `std::get<0>(tuple)` for each desired element or `std::tie(elt0, std::ignore, elt2) = tuple;` in rust: `tuple.0`, not sure if there's an equivalent to the std::ignore/std::tie combo
- pjmlp 6y agoC++ has structured destruction now.
- Rusky 6y agoStructured bindings work for simple cases, but Rust's are much simpler and more powerful.
- pjmlp 6y agoUntil ISO C++23 papers for pattern matching get accepted.
- adamnemecek 6y agoWhy wait?
- pjmlp 6y ago40 years of IDE tooling, libraries, GUI toolkits, GPGPU designed for its memory model, shader language dialects with graphical debuggers, tier 1 support on the OS SDKs from Sony, Nintendo, Apple, Google, Microsoft, Arm, Samsung, Huawei, certified compilers for industrial deployments, an international standard independent of US sanctions.
- adamnemecek 6y agoThere is an equivalent to tie let Tuple { elt0, elt2, ..} = value.
- Rusky 6y agoRanges don't really exist yet.
- pjmlp 6y agoThen I wonder how I am using them.
- Qwertious 6y agoMaybe what you're using isn't ranges. But, they seem to work well enough that you think they're ranges, so who cares whether they're ranges or not? They work!
- Rusky 6y agoProbably by using a third-party library, with a pre-concepts-based implementation which is heavy on compile times. Unlike Rust, where they're built in and don't really have that cost. The context here is comparison between Rust and C++, for a side project begun over a year ago. Citing pre-standard C++ features with partial/experimental third party implementations doesn't really make the difference you seem to think, in that context.
- adamnemecek 6y agoTheoretically yes, practically it's a different story. Sure you can write clean modern cpp (the act of which is harder than writing clean Rust), but if your dependencies are still "C with classes", you are forced to particular patterns.
- pjmlp 6y agoWhile I agree, Rust also suffers from it, where " C with Classes" gets turned into "Rust with unsafe", although not required.
- adamnemecek 6y agoUnsafe is not as big of a deal as people make it seem.
- pjmlp 6y agoUsing C alongside static analysis like Frama-C is also quite safe, one could say.
- adamnemecek 6y agoIt's not just safety though. It's just...all of it. I legit don't enjoy writing C. Rust is fun to write 90% of the time.
- keldaris 6y agoThat's a completely fair point, but very subjective. There are lots of people (myself included) who feel exactly the opposite way.
- Jweb_Guru 6y agoFrama-C's analysis is neither sound nor complete and it's way way harder to set up and use than Rust.
- echelon 6y agoC++ is incredibly verbose (STL) and carries a lot of baggage and mental overhead. Rust has improved ergonomics in nearly every area except lifetime handling, which is a concern you want to think about and make explicit. I predict in ten years the gravitas for new projects will have shifted entirely to Rust. C++ is just too much of a burden to write and verify. C++ will still have plenty of healthy projects, but I think it'll be hard to attract new projects when Rust has come so far.
- pjmlp 6y agoFor that to really take off, the OS SDKs need to give tier 1 support to Rust. If Apple, Google, Sony, Nintendo and Microsoft do that, instead of the internal projects where they use Rust today, then it might happen.
- shaklee3 6y agoThey have about the same amount of verboseness in my experience.
- sitkack 6y agoHow do you define or enforce a "modern C++ codebase", this seems like an arbitrary comment to discount the parent's point.