News for hackers. Stuff that matters.
Re:Ask HN: Why do you use Rust, when D is available? by ncmncm on Friday June 12, 2020 @01:38AM (#23496380)
> Normal people don't want to touch C++ anymore. Only people that think that CVEs are "just fault of bad developers" (LOL) can still be considering C++ a good language to start new projects in.

Deliberately inflammatory, and also false.

1. Rust has limited abstraction features to make it more approachable and implementable, but make it unable to express libraries that are easy in C++. This will not change soon, although Rust will accrete features at a steady rate. But the gap in feature sets will widen, not narrow with time.

2. The total number of people using Rust in production is easily less than the number who pick up C++ in any given week. It will be ten years before Rust is a mature industrial language, if it gets there. (It has made a good start in that direction, which is better than can be said for any other newish language.)

3. C++ and Rust will coexist for decades. The most ambitious work will continue to be done in C++, while Rust will be more than adequate for what might otherwise have been done in (the much less capable) C, Go, or Java.

4. D fizzled because it is too similar to C++, and therefore unnecessary. Rust found a ready audience in people intimidated by C++, frustrated with the limitations of C, Java, and Go, and ready to try something wholly new. Its designers have threaded the gap deftly, uniquely adopting C++'s greatest strength, the destructor (which it calls the "Drop trait"), and avoided weighing it down with garbage-collection. It has a bright future if it can multiply its adoption rate by two orders of magnitude.

As Stroustrup said, there are only two kinds of language: the ones people complain about, and the ones nobody uses.

With enough luck, by the time Rust is mature, it will have gained plenty to complain about. Rust will have got somewhere when you read more complaints about it than brags about having made it do something already done in a mature language.

Re:Ask HN: Why do you use Rust, when D is available? by secondcoming on Friday June 12, 2020 @05:21AM (#23497485)
I've been writing C++ professionally for 16 years. I'm doing it right now in fact, but snuck on to HN while a build is underway.

OP is right, unfortunately. C++ is a dying language. Mozilla, Microsoft and Google are all looking at Rust. Why? Because it's probably makes more sense to rewrite a buggy C++ component in Rust instead of updating it to use modern C++ (where admittedly, you have to go out of your way to get things wrong). The damage has been done.

I'm also concerned about our ability to hire in the future. C++ devs will either be too expensive, or just not there since it's not an attractive language any more.

I'm not a Rustafarian either, I've actually never used it but it would be negligent of me to not look at it. One concern I have with it is that the eco-system may be full of poor-quality ports of C/C++ libs, because that's how people work when they learn a new language.

Re:Ask HN: Why do you use Rust, when D is available? by mantap on Friday June 12, 2020 @05:43AM (#23497587)
C++ was a dying language in the 2000s. But they turned it around with C++11. Now it has iterative 3 yearly updates and it's getting pretty good.

It's far too premature to declare its death. The pace of development of C++ is decently fast and there's many stakeholders with millions of lines of C++ who are interested in C++ not dying. C++ is taught in universities around the world so the chance of C++ developers becoming expensive is low.

Re:Ask HN: Why do you use Rust, when D is available? by ncmncm on Friday June 12, 2020 @02:46PM (#23502357)
In fact, the number of C++ programmers is growing faster than ever. This is evident in the growing number and size of C++ conventions. (Bulgaria has its own, now.) Even ISO C++ Standard committee attendance is reliably a lot more than every previous meeting, even when held in inconvenient places. Attendance will hit 500 soon. The amount achieved at each meeting grows accordingly. Proposals get more scrutiny and draw on more experience.

To suggest C++ is a dying, slowing, or stagnant language is objectively delusional. The language is healthier than ever, and going gangbusters.

Re:Ask HN: Why do you use Rust, when D is available? by Aeolun on Friday June 12, 2020 @08:24AM (#23498507)
The C++ that they teach you in universities barely gets you started. I wouldn’t count on those for a steady supply.
Re:Ask HN: Why do you use Rust, when D is available? by gnulinux on Friday June 12, 2020 @02:05PM (#23501916)
The C++ they teach in universities is either just C, or putting Java spin on C (C-with-classes). I've never seen a decent "modern C++" class taught in universities.
Re:Ask HN: Why do you use Rust, when D is available? by mantap on Friday June 12, 2020 @08:46PM (#23505574)
Sure, but that's nothing a few years in the real world can't fix. The point is that C++ programmers are not some rare breed of neckbeard that are gradually going extinct. They are being produced en mass.
Re:Ask HN: Why do you use Rust, when D is available? by pjmlp on Saturday June 13, 2020 @11:45AM (#23510231)
I love that Java spin on C remark, given that stuff like Turbo Vision, MFC, OWL, PowerPlant, Motif++, CORBA, COM, VCL, SOM, CSet++, POET precede Java for several years, some almost a decade.
Re:Ask HN: Why do you use Rust, when D is available? by pjmlp on Saturday June 13, 2020 @04:08AM (#23507765)
While we see some adoption of Rust from Google and Microsoft, all their new releases are heavly focused on C++.

React Native, the new Games SDK for Android, WinUI 3.0 release, lifetime analysis support for Visual C++ and clang and lets not forget they are two major contributors to ISO C++.

While the Rust/WinRT efforts from Kenny Kerr are welcomed, that it is just yet another option alongside C#/WinRT, C++/WinRT, Python/WinRT and JavaScript/WinRT.

Re:Ask HN: Why do you use Rust, when D is available? by taylodl on Friday June 12, 2020 @08:43AM (#23498634)
COBOL has been dying since the early 80s yet to this day more than 80% of all daily business transactions are processed in COBOL and 5 billion lines of new COBOL are written every year. If this is what a dying language looks like then yes, C++ is a dying language.

P.S. I'm not a COBOL programmer nor have I ever been a COBOL programmer.

Re:Ask HN: Why do you use Rust, when D is available? by blub on Friday June 12, 2020 @12:00PM (#23500527)
The only language that one can honestly say that is dying (if not already dead) is VisualBasic. Perl and Delphi are probably going to continue to decline. Objective-C will be obsoleted by Swift some day, but is still relevant. Ruby's not too hot now, but far from dead AFAIK.

Other than that it's nonsense to say that X is dying.

Re:Ask HN: Why do you use Rust, when D is available? by secondcoming on Friday June 12, 2020 @12:34PM (#23500916)
C++ is being blamed for allowing people to write buggy, insecure programs. In my mind, that's different to just becoming unpopular; it's dying because it's too dangerous and too complicated.

Sure, it'll stick around for some years yet but all those jobs will become maintenance jobs. Very little greenfield projects will elect to use it outside of niche areas (games and maybe embedded - UK salaries for embedded dev are terrible). Both C++ and Rust can use LLVM, so the generated code is likely to be the same.

If you were starting a greenfield project today why would you choose to do it in C++?

I forgot to mention Go too.

Re:Ask HN: Why do you use Rust, when D is available? by ncmncm on Friday June 12, 2020 @02:55PM (#23502438)
In fact, essentially all new development in the highest-paid financial, HPC, CAE, telecomm, aerospace, and ML fields is pure C++. Rust is not a blip in any of them, and will not be for years to come. C is dead there (except in aerospace and telecomm), Go is nonexistent, and Java is mentioned on rare occasions.

To suggest C++ usage is in decline is, objectively, nothing short of delusional. For Rust, C++ will the one to beat in ten and twenty years, provided not too many have already skipped onto some new hotness.

Rust is an objectively better design than anything else that has arisen in 30+ years. That doesn't guarantee success.

I used to hope a better language would displace C++, and for a time thought Rust might be it, but that better language turned out to be C++ itself. Nothing else is even on the horizon.

Re:Ask HN: Why do you use Rust, when D is available? by krapht on Friday June 12, 2020 @02:37PM (#23502263)
My company starts new programs in C++ because everyone knows C++ already, we write modern C++, our libraries are written in C++, and our bugs are mostly not memory safety issues.
Re:Ask HN: Why do you use Rust, when D is available? by bigjake on Sunday June 21, 2020 @09:12PM (#23596635)
I would choose C++ because the tooling is superb, talent is widely available, it is performant, there are libraries for pretty much everything, and it's a great language.

Oh and by the way, LLVM is 100% c++.

Saying it is too dangerous and complicated is absurd. It is easy to write safe code in C++, having been doing it for almost 30 years.

You are throwing around lots of assertions - challenge you to back them up with real data.

Re:Ask HN: Why do you use Rust, when D is available? by mbrodersen on Sunday June 14, 2020 @12:16AM (#23515077)
The world runs on C/C++ code. And new C++ projects are started every single day.
Re:Ask HN: Why do you use Rust, when D is available? by bigjake on Sunday June 21, 2020 @09:05PM (#23596599)
I don't understand your claim that C++ is dying. Do you have data to back this up?
Re:Ask HN: Why do you use Rust, when D is available? by nindalf on Friday June 12, 2020 @03:06AM (#23496791)
1. Could you give a few examples of libraries that can’t be made in Rust due to lack of abstraction compared to C++? GUI libraries apart, I can’t think of anything offhand.

2. True, but growth curves are rarely linear. Here’s a rough proxy on users - the number of subscribers to /r/rust - https://subredditstats.com/r/Rust. Look at the growth between 2014-18 and 2018-2020. You’re extrapolating on current growth rate, but that may increase in future.

3. “Ambitious”. Nothing I’ve seen precludes using Rust for ambitious projects. In fact, seeing the experience of Dropbox, Mozilla, Facebook and others, there are some ambitious projects that could only have been done in Rust. I’m gonna say [citation needed].

I agree with Stroustrup and look forward to the day people complain about Rust :)

Re:Ask HN: Why do you use Rust, when D is available? by saurik on Friday June 12, 2020 @05:40PM (#23504200)
I am under the impression that Rust is lacking even the most basic level of dependent typing: being able to template over a value; pretty much every typesafe buffer library I have ever written uses this to make Random<32>() return not just "a buffer" but "a buffer of size 32", which makes doing parsing of various packet formats and combining sources of information a lot more reasonable. (I am also under the impression that the Rust people intend to fix this lacking, but until then I know I am going to feel a bit crippled.)
Re:Ask HN: Why do you use Rust, when D is available? by steveklabnik on Friday June 12, 2020 @06:10PM (#23504412)
The basics are in nightly, but yes, not yet. We’ll get there.
Re:Ask HN: Why do you use Rust, when D is available? by papaf on Friday June 12, 2020 @07:34AM (#23498211)
1. Could you give a few examples of libraries that can’t be made in Rust due to lack of abstraction compared to C++?

I'm guessing, but I think that something like Armadillo[1] would not be possible on stable Rust. Something like Catch[2] might also difficult to make ergonomic.

I don't program in C++ anymore and I would personally live with the lack of expression/abstraction for a safer language though.

[1] http://arma.sourceforge.net/speed.html [2] https://github.com/catchorg/Catch2/blob/master/docs/tutorial...

Re:Ask HN: Why do you use Rust, when D is available? by 0xFluegel on Friday June 12, 2020 @02:32PM (#23502203)
Can you elaborate on why Catch would be impossible or unergonomic? It's a test framework, right? Why would one even use it instead of the normal rust test framework?

Also, how is it ergonomic? I'd agree if you say that it's (one of?) the best for C++, and it's also my go-to option, but ergonomic?

Re:Ask HN: Why do you use Rust, when D is available? by adamnemecek on Friday June 12, 2020 @11:37AM (#23500302)
Why are they impossible in Rust? Are you aware of Rust's macros right?
Re:Ask HN: Why do you use Rust, when D is available? by ncmncm on Friday June 12, 2020 @02:59PM (#23502470)
Rust macros know nothing about types, but types are what do all the work at compile time.
Re:Ask HN: Why do you use Rust, when D is available? by adamnemecek on Saturday June 13, 2020 @11:10AM (#23509952)
Do they have to know about types?
Re:Ask HN: Why do you use Rust, when D is available? by ncmncm on Monday June 15, 2020 @12:28AM (#23523799)
Only to build designs that today are possible only in C++.

Type-aware macros might not be the best way to implement the features needed to match C++.

Re:Ask HN: Why do you use Rust, when D is available? by rational_indian on Friday June 12, 2020 @05:25AM (#23497500)
>Rust found a ready audience in people intimidated by C++, frustrated with the limitations of C, Java, and Go, and ready to try something wholly new.

What about people not intimidated by C++ and want to switch to Rust anyway? Why have you discounted them? Do such people exist in your world view? Do you think there might be a good reason for those people to choose Rust?

Re:Ask HN: Why do you use Rust, when D is available? by lordlic on Friday June 12, 2020 @08:26AM (#23498527)
I read that the same way until I realized that it would be fair to say that even I'm "intimidated" by C++ despite having quite a bit of experience with it. It's not a matter of cleverness or experience. You can know something inside and out, and still admit that it's out of control and worry about the costs of its complexity.
Re:Ask HN: Why do you use Rust, when D is available? by ncmncm on Saturday June 13, 2020 @05:28AM (#23508138)
If you are not intimidated by C++, you will be using those features that intimidate others to construct better libraries and programs than they can. Switching to Rust would mean a huge step down, where vast gaps in the feature set disable expressing what has been so easy.

There are kludgy workarounds for everything, more or less, but why switch to a limited language with immature tooling and practically nonexistent immediate prospects, when C++ demand is going up, up, and up?

Memory safety is just not an issue at the level where coders of modern C++ work. I have had exactly one lifetime error in five years, caught in initial testing. My bugs are overwhelmingly specification omissions and logic mistakes that Rust suffers from exactly as much.

My day-to-day experience is to write 2000 lines and, when it compiles, it works correctly, modulo a "!" short or extra. Then, I spend a few days refining the design, which often means deleting code. Things Rust promises to help with consume only trivial attention. Library features not expressible in Rust prevent many more and bigger problems.

Rust has some nice qualities I would rather C++ had--pattern match support, simple iterators, default const and default pass-by-move, sane conversions, sane initialization--but they are all low-level conveniences, not anything I am willing to trade away architectura-level capabilities for.

Re:Ask HN: Why do you use Rust, when D is available? by rational_indian on Saturday June 13, 2020 @06:23AM (#23508415)
What architectural level capabilities?
Re:Ask HN: Why do you use Rust, when D is available? by ncmncm on Saturday June 13, 2020 @05:50PM (#23513081)
Template partial specialization, function template overloading, variadic template argument lists, template operator overloading, generic lambdas, the list goes on and on and on. Look up any list of C++20 language features; most are not in Rust. Look up any list of Standard Library components; most are not expressible in Rust.

Rust is going interesting places, is taking full advantage of starting from scratch, and is miles ahead of C, Java, and Go on every axis. But if Rust could get to where C++ was in 2011 by 2025, that would be amazing. Meanwhile, C++ has already shipped C++14, C++17, and C++20, will have done C++23, and will be firming up C++26.

Assume Rust could match C++20, just five years later, in 2030, which would be more amazing. C++29 will be out.

Re:Ask HN: Why do you use Rust, when D is available? by isaiahg on Thursday June 25, 2020 @02:42AM (#23637571)
As a normal person learning and using C++ I'm sorry but I agree with him. If I weren't trying to get a job in the game industry I wouldn't touch it. I'm not a student either, I've been programming in multiple languages for over a decade.

The language is messy and filled with undefined behaviors and unsafe methods by default. Where there are rules you can mostly ignore them whenever you want. People complain about JavaScript being messy but C++ is way worse.

Though the language itself isn't all that bad, I don't understand why there so many build systems? And the top build system CMake isn't so much a build system as it is a build system for build systems that exists because no one can seem to agree on one.

Many of these systems seem bloated and over designed by comparison when I can install libraries or cross compile in one line in go. I couldn't help but think there had to be a better way and it seems like rust is that way. I expect C++ will eventually go the way of Cobol and eventually be used to maintain legacy systems.

p.s. thank God for vcpkg because I had nearly thrown in the towel while trying to integrate simple libraries until I discovered it.

Re:Ask HN: Why do you use Rust, when D is available? by bigjake on Sunday June 21, 2020 @09:05PM (#23596605)
Excellent explanation! Couldn't have said it better myself.
Re:Ask HN: Why do you use Rust, when D is available? by Rochus on Friday June 12, 2020 @05:52AM (#23497633)
Thank you for putting it so aptly.

Unfortunately for many people technology is still an emotional rather than a professional topic.

Re:Ask HN: Why do you use Rust, when D is available? by Aeolun on Friday June 12, 2020 @08:28AM (#23498539)
I think the two go hand in hand. I get emotional over many a professional topic.
Re:Ask HN: Why do you use Rust, when D is available? by Rochus on Monday June 15, 2020 @01:36PM (#23530298)
That's why we do tradeoff studies in systems engineering, to avoid that we take important decisions based on emotions or assumptions. Participants can still get emotional, but at least they have the facts and a process which converges to the optimum solution when followed.
Re:Ask HN: Why do you use Rust, when D is available? by tutfbhuf on Friday June 12, 2020 @03:29AM (#23496935)
> 3. C++ and Rust will coexist for decades.

Nah, I mean maybe in the way that Fortran coexist with C/C++ for decades, but it's not equal coexistence.

I would rather say that new languages arise, replaces old ones for most scenarios and in the cases where they can't, due to various reasons, they push the old language into zombie state like cobol.

Re:Ask HN: Why do you use Rust, when D is available? by nix23 on Friday June 12, 2020 @05:27AM (#23497510)
You don't replace languages but program's, go into physic-space, fortran is alive an well, go into systems programming c is alive an well, go into business java is alive and well.

It's the same BS like NoSql will kill all R-D's.

You just don't invest millions just to rewrite programs that work's perfectly (and that's often the case with old battle-hardened software)

Re:Ask HN: Why do you use Rust, when D is available? by lordlic on Friday June 12, 2020 @08:30AM (#23498552)
The reason that RDMSes aren't dead isn't that they have too much momentum to be displaced by NoSQL. The reason they're not dead is that they're a good data model for lots of applications, and their consistency semantics and tooling provide real boosts to developer productivity.
Re:Ask HN: Why do you use Rust, when D is available? by tutfbhuf on Saturday June 13, 2020 @05:19AM (#23508068)
I think that NoSQL and SQL are so much different that they will equally coexist, in the same way that languages that are used for very different purposes like Java and Javascript can equally coexist. However, it is unlikely that we have 5 different equally popular languages for one specific domain (e.g. systems programming).
Re:Ask HN: Why do you use Rust, when D is available? by nix23 on Friday June 12, 2020 @10:14AM (#23499409)
I know, but around 2009/10 every hipster programmer said RD's are a thing of the past..like C like Java etc...
Re:Ask HN: Why do you use Rust, when D is available? by tutfbhuf on Saturday June 13, 2020 @05:12AM (#23508036)
I agree with you, so by zombie state I mean the languages are still being used, but for historic reasons (e.g. you don't want to rewrite), but no one really wants to start a new project in COBOL.