4 ms·
>Rust designers have consciously chosen to keep the language's abstraction capacity limited, which makes it more approachable, but reduces what is possible to e
by carlmr 6y ago
>Rust designers have consciously chosen to keep the language's abstraction capacity limited, which makes it more approachable, but reduces what is possible to express in libraries. That means libraries possible, even easy in C++ cannot be coded in Rust.
Like what? I can think of many examples where I can't express the abstraction from Rust nicely in C++. proc_macros, strong typing, macros that are part of the AST, enums with data, safe passing by reference, nice iterators (none of this begin() and end() line noise), less noisy lambda syntax, and of course memory safety.
It's especially nice abstractions where Rust shines, compared to C++.
- pjmlp 6y agoPlenty of those can be better expressed in C++20, alongside clang tidy and VC++ analysers. Compile time reflection and metaclasses already exist as VC++ prototype, demoed at Visual C++ 2020 virtual conference. While I enjoy using Rust, what I care about are the libraries and IDE tooling, specially for .NET and Java integrations, so for better or worse, C++ keeps being the tool to pick. Also I have big hopes for Rust/WinRT, but it is still very early for it to eventually reach C++/CX tooling, which even C++/WinRT is currently playing catch up and where WinUI team is placing their resources.
- carlmr 6y ago>Plenty of those can be better expressed in C++20, alongside clang tidy and VC++ analysers. Aside from lack of C++20 support on many targets, Clang tidy and extra analyzers require other people to take the same care as you do, an assumption that, as somebody mentioned in that article, is unreasonable to make in a non-solo project. >Compile time reflection and metaclasses already exist as VC++ prototype, demoed at Visual C++ 2020 virtual conference. A prototype in a Microsoft dialect of C++? That's apples and oranges. >While I enjoy using Rust, what I care about are the libraries and IDE tooling IDE tooling has gotten better, but of course that does still lag behind. While C++ build systems IMHO lag behind cargo, so for me that's a tie.
- pjmlp 6y agoIt isn't a Microsoft dialect, rather what might be coming in ISO C++23. Conan and vcpkg are already establishing themselves, and they have a killer feature over cargo, binary dependencies. Also too many Rust libraries still reach out to unsafe, needlessly.
- ncmncm 6y agoWillingness to lock oneself into corporate walled gardens never fails to mystify me. To my understanding, the only reason Java was embraced with any enthusiasm in 1995 was as a way off of Microsoft's frameworks treadmill.
- pjmlp 6y agoThen you will gladly refuse any contribution from Microsoft, Apple, Oracle, Google into Rust. Better let Microsoft know about their mistake to sponsor Rust.
- ncmncm 6y agoWhenever Microsoft can get people writing unportable software, and locked in again, they benefit; same for any corporate octopus. We don't.
- pjmlp 6y agoYet the Rust community doesn't seem to think the same way as you. I see the community quite happy with the corporate help it is receiving across the board. Waiting to see you pushing a Rust fork, corporate free of any kind of contribution.
- ncmncm 6y agoYou entirely miss the point. Any resources MS provide to improve the compiler is an obvious pure win for Rust users. Likewise, any portable code they release. But all the code other people write that only works in MS's walled garden benefits mainly Microsoft, at the wider community's expense. I am astonished at the need to explain this, as if the last several decades had not happened.
- pjmlp 6y agoYou are the one missing the point, either you embrace corporations support or not. There is no pick and choose here. Plus what makes Microsoft bad, and Oracle, Apple and Google contributions good then? I am astonished that FOSS religion keeps being a thing, while it has been proven in the last 25 years where most projects without corporate love end up.
- millstone 6y agoBoth C++ and Rust have nice abstractions. Since you asked for an example of a C++ one, consider a bignum library. In C++ you can write a natural-feeling library that provides familiar arithmetic. In Rust, you will be constantly smacked in the face with lifetimes, borrowing, etc. because there's no way to do implicit clones or borrows.
- ChrisSD 6y agoImplicit clones are enabled using the `Copy` marker trait in Rust.
- zozbot234 6y ago`Copy` implies that an object can be bitwise copied while preserving desired semantics; Rust has no exact equivalent to copy construction or move semantics in C++, which can be entirely implicit while involving custom code. (There's a 3rd-party `transfer` crate that enables a `Clone`-like marker for custom moves, however. It's used together with the Pin feature, so these moves are also explicit.)