by ilovecaching · 7y ago · 0 comments
That said, I completely switched over to rust many months ago and rarely look back. Rust is a tribute to C++, an incorporation of lessons learned that sheds all of the baggage C++ will never be rid of. Rust also has less of learning curve than C++ (although both are quite high), simply because C++ has so many odds and ends to keep track of these days.
Rust has also made me realize how bad class based OO is as an abstraction. OO glues together operator overloading, methods, inheritance, all into one package. Rust breaks those concepts into component parts that provide much better abstractions with less keywords and jargon to worry about.
The first code block in the article made my jaw drop, and my first thought was "what the hell has happened to C++? I was only away for 5 years". Then I saw the "simple style" example and breathed a sigh of relief. That is the C/C++ I recognize. Even the third example with structs is not necessary. The author is right. Sometimes reusability is overrated. Duplication is better than the wrong abstraction.
It's a useful answer to the point: Well what if it was 15 for loops with a bunch of esoteric function calls. The struct example would still be better.
To borrow an old bit of snark: I don't know what the "default" programming language of 2025 will look like, but I know it will be called C++.
Like Ethernet (the original subject of that snark), C++ has evolved into a form unrecognizable to those who saw its birth. Unlike Ethernet, the older forms haven't gone away. They still reappear often in large/old/important codebases, keeping compiler writers busy and everyone else less productive. I'm generally the last person to suggest replacing things that already work, but C++ really does just need to get paved over.
This kind of language advertising where one can't even bother mentioning one negative thing about the product is sad but effective, because people want to believe that there's a perfect language out there...
That doesn't even come close to being relevant. Address the argument, not the person.
C++ has issues and problems because it's too old and it's not going to get rid of the old baggage, hence it will have to carry it forward while adding new stuff on top (concepts, ranges...). Those issues are not going away, they will only get worse over time.
Rust has different kinds of issues and problems because it's still relatively young. For instance, pretty bad compile times (even compared to C++ with heavy templates use). But that's solvable, it will just take time. Most issues with the language itself that I've personally encountered were of the kind "it's not stabilized yet" or "it's not fully implemented yet".
This works really well in practice for us. We use GCC to compile.
I see it as being like walking into an armoury and being able to choose anything you want. Chances are, if you want to resolve a domestic dispute, you don't want a claymore. Or a Howitzer. Or an aircraft carrier, or a lump of unshielded semi-critical plutonium. But that's OK, you don't have to choose them. You can walk right past those shelves to the shelf with the megaphone and the padded vest, and just take those.
That's how you program with C++.
Is this an Ammu-Nation ad? :)
It reduces mental overhead.
Last I heard D was definitely not all of those (it doesn't even have a straight story on garbage collection, as its creator said himself! [1]), and I'm not sure about Rust or Nim.
[1] https://www.quora.com/Which-language-has-the-brightest-futur...
To clarify, I didn't necessarily mean that D is not reliable, just that it doesn't have the combination of stable+reliable+supported that C++ enjoys.
What a nightmare.
I spent more time figuring out the idiosyncrasies of cgo than actually writing useful code. And in many cases, cgo couldn't actually do what I needed to do. I had to write some functions and see inside of the .go file.
I'm sure rust would have been easier to call C with since the languages bare inherently more compatible, but I don't want to go down that path again right now.
I recommend Rust or D for your next try since compiler quality is best for those. D will be easiest to learn. You can always use unsafe in either if memory management gets in way.
Hard to beat C++ and Qt in this case, IMO.
I've worked on an image processing project in C for a while and am now doing one in rust and would never want to go back. The code is much cleaner and easy to maintain. The zero-cost abstractions really pay off, and the safety guarantees means you don't spend so much of your time chasing heisenbugs from subtle threading and locking issues.
I use Rust as my main language, but as far as I have seen gtk-rs is the only somewhat mature binding for an existing UI toolkit. This is not coincidental, since Gtk+ is a C (with objects) toolkit, it is much easier to bind than toolkits in other languages. Unfortunately, outside Linux, Gtk+ also looks pretty out of place.
AFAIK, there isn't any binding for e.g. Qt or Cocoa that has wide API coverage and is mature. Definitely not for production-level work. I think currently the only viable solution is to write a core in C++, expose C functions and write the UI in C++, Swift, etc.
In a production ready manner?
It's not a given for Rust, and especially not a given for D or Nim (since they don't have any large companies behind them).
D and Nim are a bit more iffy since they have built in GC. It can be turned off, but at that point you lose a major selling point over C++, memory safety.
There are tools to help you out, like c2nim, but in my experience the output it produces requires fixing to get it working, and of course when the upstream library changes or adds to its API those sorts of things have to be taken into account as well.
Sure, incremental linkers exist [1], but all of them tend to do O(n) work on every invocation. Source control software, even developed explicitly to scale [2], behaves the same way. Makefiles as well; Tup [3] tries to solve this, in vain since the linking step is still holding everything up. There is so much inherent inability to scale built into our tools. So on big projects everything grinds to a halt as you cannot buy enough developers and hardware to keep up with O(n^2) forever.
[1] MSVC cl, GNU gold
[2] git: http://lkml.iu.edu/hypermail/linux/kernel/0504.0/2022.html
[3] tup: http://gittup.org/tup/manual.html
That's not to say I don't allow for trade-offs.. I gladly trade some milliseconds (or, grudgingly seconds) for features.