by jobs_throwaway · 4y ago · 0 comments
edit: thanks for downvoting a genuine question!
While a language made by committee is invariably garbage (citation: JavaScript), there is something to be said for stabilizing the standard for safety-sensitive systems like flight, space, medicine, automotive, and the ilk. Not a grate look if your space-balloon goes over like a lead-balloon.
Also, Rust is not something you can just "switch" to; it's not javascript or python. You have to UNLEARN a lot of bad nuns before you can truly be productive in Rust. Learning rust is a steep climb, coming from languages like C & C++; if you are coming from a language like python or lisp, it's a damn near smooth-vertical-shaft.
Frustratingly, a lot of the books for newbs are like: "So you wanna do this cool thing in Rust? Then do this tutorial project for this crate!", and they don't actually go over idiomatic rust algorithms. The way rust handles code and data, lends to "different" ways of solving problems. The best way to learn rust, is to read rust, but that can get confusing with the traits and typing bounds and lifetimes and unwraps. On the other hand you get to say "turbofish" a lot; so there's that, which is nice.
And so the issue becomes one of monkey-power. I can find bucket-fulls of hairless apes to bludgeon in C or C++ code, but it takes a more sophisticated `Ook<T>` to see the Octarine that is Rust.
Not everybody in the C++ community is convinced this is a benefit.
C++ has a lot of baggage and if you maintain old C++ software I'm sure it's a massive PITA but starting fresh in C++ isn't a bad experience.
In my opinion, memory safety also gets a little overblown. Most applications don't really need memory safety, and for the ones that do, C++ smart pointers are good enough. I'm sure plenty of people will have strong opinions against that.
Ultimately there is this sort of energy towards c++ because there are orders of magnitude more projects and developers that use C++, and it would be silly to stop work on C++ every time a C++ killer came along.
There are certainly a number of high-quality C libraries hanging around (SQLite, libcurl, etc) that might be used, but I don't think anyone's doing serious game dev in C these days. It really is all about C++, and C# for Unity.
I'm sure other people will be able to share reasons their organizations use C++
Rust is great and offers a great path forward, but it was not around 20+ years ago when $BIG_PROJECT was written. C++ was around, popular, and useful so $BIG_PROJECT was written in C++. $BIG_PROJECT made $BIG_COMPANY millions and is still in use today.
$BIG_PROJECT engineers are looking into migrating parts of $BIG_PROJECT to Rust, but the work is still early and the $BIG_PROJECT's millions of lines of C++ won't be replaced overnight. Improved, more uniform tooling for C++ would simplify maintenance for $BIG_PROJECT and make it easier to move $BIG_PROJECT to newer C++ toolchains and even other C++ toolchain vendors.
Maybe one day $BIG_PROJECT will migrate fully to Rust, or perhaps $BIG_PROJECT will be re-written from the ground up in Rust, but for now $BIG_PROJECT has to work.
First, the hacky build systems of old are increasingly unsustainable; I've seen quite a few projects migrate to things like cmake in part because not having that kind of build system just doesn't work anymore. (And you get people like Mozilla or Google who write their own build system just for their software, but the end result is the same--you've got some sort of modern-ish build system being integrated). Even at $WORK, some of our old build system stuff with confusing make rules and the like is being shifted to a (hopefully) cleaner cmake stuff, albeit far more slowly than I'd like.
Second, it's worth noting that tooling improvements can motivate change. The ur-example here is the compilation database idea Clang introduced. From what I've seen, every build system that can support it (sorry, autotools) has added information to extract this useful tool. If you can come up with similarly useful build system summary information that is useful for tooling, you're likely to see relatively swift adoption of it.
Third, C++ is already undergoing changes that will introduce build system breakages. Most notably and obviously, modules. Build systems need to adapt to support this, and if people are already making the switch to get new features, incorporating other useful tooling additions at the same time would see adoption.
The problem is that CMake is also a cardboard castle built on numerous hacks that break every time a wind blows by. For library users it might be bearable, but for library writers it is absolute hell. And the consistent churn of new half-baked features and subpar documentation really doesn't help. (People talk about "modern" CMake like they do with "modern" C++, the churn is so similar...)
The solution that I've found now is: I've built my own build system in Python that outputs a Ninja file, dead simple. Don't really have the urge to use CMake again (unless when I need to at $WORK)
Also not everyone believes in silver bullets and modern C++ is fairly god and easy enough to use. Just do not try to know ALL of the C++. This kind of expertise is needed by whole 2.5 people. Partially true for any complex enough language.
You are still more than welcome to start new projects in whatever language warms up your heart or rewrite already existing stuff.
P.S. I do not ever downvote post no matter what does it say.
[0] https://www.joelonsoftware.com/2000/04/06/things-you-should-...
But when I say "Rust does not have Qt" this is actually not what I refer to.
A big point of Qt is that you have a complete consistent library with an event loop that will handle everything from GUI to network / serial port communication / media playback / JS scripting / database access / ... transparently, with APIs that are fairly cohesive. With Rust whenever I looked at it it was async API flamewar and the need to use 50 libraries that all have slightly different conventions, namings, etc. Qt brings consistency, just like boost does, and that's why I like using those ; most of the time I don't even have to think about what the name of something is going to be in a class / type I've never used, because it's obvious from the naming scheme of the library.
A kitchen sink library, re-implementing absolutely everything. I do mean everything there's even a QString to use because heaven forfend a C++ library wouldn't have its own custom String class...
The temptation to build kitchen sink libraries is exactly what this proposal seems to be fighting. No, I don't expect they will win.
Although give it 10 years and that issue should be resolved.
So no. Rust does not have official Qt support.
this is ridiculous. rust does not have overloading ?
(Rust has operator overloading - but that’s not the same thing).
Rust's "constructors" aren't magic, whereas the C++ constructors are magic, so they need ad hoc polymorphism or you could only have one constructor for each type.
Let's compare familiar types which weren't built using some sort of FFI magic, C++ std::vector and Rust's alloc::vec::Vec.
std::vector has 10 constructors, they can't have different names, so they're distinguished by their parameters, perhaps your IDE will prompt you with a list of options or you'll remember the parameters you need to do what you intended.
Vec::new() makes a Vec, Vec::new_in(allocator) makes a Vec using a specific allocator, Vec::with_capacity(4) makes a Vec with capacity for 4 things and so on.
Somebody else mentioned operators, note that Rust doesn't really overload operators either. In Rust the operators are getting implemented. If you don't implement an operator, then it doesn't exist, whereas in C++ the operators often have some pre-defined behaviour and you can change that using overloading.
For example if your type Doodad should like to be able to use the + operator on other Doodads, you can implement core::ops::Add<Doodad> for Doodad - now the + operator works when both sides are Doodads. If you'd like a += b; to work, you'd implement core::ops::AddAssign<Doodad> for Doodad. These traits require methods with the appropriate signature e.g. AddAssign::add_assign(&mut self, rhs: Doodad) saying this function needs a mutable reference to a but consumes b.
Oh, before I forget:
Because Rust doesn't have ad hoc polymorphism often people realise they wanted parametric polymorphism here. For example C++ 23 can almost do "bananas".contains("nanas") finally, but it uses a bunch of overloading to pull that off, since Rust doesn't have this, it chose to reify the idea that's filling out that slot in the C++ functions as a Trait, and it calls this the trait Pattern. So, all the places where you mean "You know, for matching strings" you can use any of the ways of matching strings because they implement the Pattern trait
"bananas".contains('b')
"bananas".contains("nanas")
"bananas".contains(char::is_whitespace)
"bananas".contains(MyCustomThing { "is it fruit?" })It's a meme language that is only used for writing blog posts and internet commentary.
And not because he thinks Rust might be able to solve actual problems in kernel development?
I want whatever drugs you're taking.
Memory safety is one hell of a benefit. In contrast, if you look at Linux' coding style, C++ really doesn't have any benefit over C.
Not to mention, many of C++'s advantages come from the STL, which wouldn't work without extra work in kernelspace. Rust has been designed for running on bare metal from day 1.
(Actually, no, strike that, I don't want to sleep forever.)