News for hackers. Stuff that matters.
Re:Ask HN: Why do you use Rust, when D is available? by dpc_pw on Thursday June 11, 2020 @11:39PM (#23495794)
Personally, at some point Rust was just clearly better and after a while - I lost interest in D. I don't have time to keep track of D catching up, when I'm so happy with Rust, and ecosystem is growing so fast. Maybe D got much better in last few years... but I kind of don't care anymore. It's hard enough to introduce a raising star like Rust to your coworkers and D just don't have traction anymore.

I've been following D since early 2000s. 2 decades. It took it a long time to get good: make it open source, make it community driven instead of one-man show, add some really important features and focus on important things (ownership, memory-safety), get the tools to be good.

It just missed the boat, and never really had a right niche for itself. It was kind Java/C++ mix, and it wasn't all that better to dethrone anyone in that space.

Rust swooped in and executed everything perfectly in a really short time. It's a C++-killer: same strengths, none of the weaknesses. 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. Industry really, really needed C-like language that was memory safe, and all-round good: both low and high level. And Rust quickly delivered that, borrowing all the great aspects of other languages and addressing a lot of problems.

D is great, and I like it far more than e.g. Go, but it was an ambitious project by one individual for a long time, while Go had a whole Google behind it. There's no shame that it didn't "took over the world". Rust would possibly not do so well if it wasn't for Mozilla support. The marketing, credibility and traction a big backing company like this gives a new language is probably the single bigger reason for different outcomes.

Re:Ask HN: Why do you use Rust, when D is available? by tluyben2 on Friday June 12, 2020 @09:31AM (#23499026)
> It's a C++-killer: same strengths, none of the weaknesses

Not used Rust yet, used a lot of C++; isn't a weakness that it also is extremely slow in compiling? Not sure about others but to me that's a big weakness (if it still applies, but as far as I can find on Google it does).

Re:Ask HN: Why do you use Rust, when D is available? by Kaze404 on Friday June 12, 2020 @10:34AM (#23499609)
From my experience building (not writing) relatively complex Rust applications like Alacritty, it's really not that bad. Building for release is definitely slower than C++, but development builds are almost always instant for me, as they're done incrementally.
Re:Ask HN: Why do you use Rust, when D is available? by adamnemecek on Friday June 12, 2020 @11:39AM (#23500317)
Rust is much better at caching the intermediate results of compilation. First time compilation might take some time, recompilation will be faster though.
Re:Ask HN: Why do you use Rust, when D is available? by sivizius on Friday June 12, 2020 @01:29PM (#23501560)
Most of the time, I let my IDE check the code with rls, rust-analyzer or cargo check which invokes the rust-compiler without doing the costly code generation part with LLVM, so it is usually fast enough checking huge projects while writing or at least when saving.
Re:Ask HN: Why do you use Rust, when D is available? by vmchale on Friday June 12, 2020 @01:50PM (#23501766)
cargo doesn't do a terribly good job of caching dependencies.

Might be better than whatever C++ does though.

Re:Ask HN: Why do you use Rust, when D is available? by pjmlp on Saturday June 13, 2020 @11:39AM (#23510184)
Currently C++ is still a better experience, because using binary dependencies is quite common, so you don't compile the whole world, rather just your own application.

Then most organizations have staging areas where you can share binaries across the company.

And the two package managers that have been growing community support, conan and vcpkg, support caching and distribution of binary dependencies.

No doubt cargo will eventually get something similar, it just isn't there today.

Re:Ask HN: Why do you use Rust, when D is available? by adamnemecek on Saturday June 13, 2020 @02:20PM (#23511441)
You can do this with a build script.
Re:Ask HN: Why do you use Rust, when D is available? by pjmlp on Saturday June 13, 2020 @02:29PM (#23511497)
So goodbye declarative builds.
Re:Ask HN: Why do you use Rust, when D is available? by adamnemecek on Saturday June 13, 2020 @07:22PM (#23513716)
I thought I cared about declarativeness, turns out I don't.
Re:Ask HN: Why do you use Rust, when D is available? by pjmlp on Sunday June 14, 2020 @03:51AM (#23515864)
Experience has taught me to always care about it, except when working on throw away hobby projects with teams of one, turns out not using it doesn't scale across organisations and makes for very unhappy DevOps teams.
Re:Ask HN: Why do you use Rust, when D is available? by bigjake on Sunday June 21, 2020 @09:21PM (#23596669)
Slow is relative. On my machine I can compile all of Chromium in ~15 minutes. I am one hugely impatient person when it comes to compile times, so I watch things closely.

But just like anything else given enough time, money and harddisk space anything is possible :)

Re:Ask HN: Why do you use Rust, when D is available? by asdkhadsj on Sunday June 14, 2020 @04:04PM (#23520846)
I'm not sure what fast or slow is. I think on average I spend 1-10s compiling. Eg when I run my tests, or run a server. However that is during my normal workflow. Ie the thing I do 500x a day.

If I was to nuke my target directory _(the compile cache)_, it would take minutes. Not sure how many honestly, because when I do it, I rarely wait for it.

So the compiles are definitely slow, but for me it's only bad when dependencies are needing to be compiled. Which is rare.

If you don't cache your dependencies well, like in a poorly written CI pipeline, things will suck though. 20 minute builds at work (slow build machines) are common for us due to some poorly done caching.

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.
Re:Ask HN: Why do you use Rust, when D is available? by peterkos on Friday June 12, 2020 @02:03PM (#23501897)
> Rust would possibly not do so well if it wasn't for Mozilla support.

And especially Mozilla's intense passion for open-sourcing everything. I think it was a good catalyst to get it into the hands of as many people as possible.

Re:Ask HN: Why do you use Rust, when D is available? by billconan on Friday June 12, 2020 @10:03AM (#23499315)
I got scared away by rust's syntax.

I feel that people can learn rust faster if they know c++ beforehand.

c++'s syntax is scary too. But there are different levels of c++. You don't need to use the scary part to make things work.

Re:Ask HN: Why do you use Rust, when D is available? by cyberprunes on Friday June 12, 2020 @10:46AM (#23499737)
Disagree. Sure rust has a notable syntax tax (not what it used to be) but that's the easy part! It's the concepts and mindset that are the biggest hurdle in Rust. Going to C++ first won't help you there. If you already know it, great but Rust is a different language and you'll spend a lot time trying to transfer C++isms over until you realize writing effective Rust is not like writing effective C++ and you go through a process of unlearning. In my view, learning C++ for the purpose of learning Rust is massive waste of time.
Re:Ask HN: Why do you use Rust, when D is available? by peterkos on Friday June 12, 2020 @02:12PM (#23501986)
> Rust is a different language and you'll spend a lot time trying to transfer C++isms over until you realize writing effective Rust is not like writing effective C++ and you go through a process of unlearning

Ding ding ding! However I do think that the combination of syntax with the brand new concepts just adds that extra layer of complexity. A similar thing is Optionals in Swift -- the syntax is so baked into the language that even if you really understand how optionals work, the syntactic sugar keeps piling up in different situations. (i.e., first the ? operator, then implicitly unwrapped optionals, then if lets, guards, guard lets...)

Re:Ask HN: Why do you use Rust, when D is available? by kd5bjo on Friday June 12, 2020 @10:49AM (#23499763)
> I got scared away by rust’s syntax.

I’m curious about what you find scary about Rust’s syntax. I always found it to be a fairly natural extension of the syntax from C and other ALGOL-derived languages.

Its semantics, on the other hand, took quite a while to wrap my head around. I am reasonably productive in Rust these days, and I still sometimes can’t predict whether or not the compiler will allow something.

Re:Ask HN: Why do you use Rust, when D is available? by peterkos on Friday June 12, 2020 @02:10PM (#23501968)
As a Rust newbie: macros, lifetimes, and (when I really first started), closures. All of that syntax just seemed so messy to me.

The borrowing model was actually my favorite part because it not only was interesting, but made sense! And the syntax was relatively clean :)

Re:Ask HN: Why do you use Rust, when D is available? by Avamander on Friday June 12, 2020 @10:01PM (#23506059)
No, knowing C++ probably confuses you for a while, it has confused me.
Re:Ask HN: Why do you use Rust, when D is available? by vmchale on Friday June 12, 2020 @01:49PM (#23501761)
> Industry really, really needed C-like language that was memory safe, and all-round good: both low and high level. And Rust quickly delivered that

Well, almost. I'm not sure I like unsafe FFI and other bits.

> Personally, at some point Rust was just clearly better and after a while - I lost interest in D. I don't have time to keep track of D catching up

Yup. Better to use Rust if it's the one introducing the features.

Re:Ask HN: Why do you use Rust, when D is available? by bigjake on Sunday June 21, 2020 @09:26PM (#23596691)
Support for unsafe constructs is almost critical to a languages success. There are certain things that just cannot be done safely, and any language that wants to be considered a systems language needs some method of providing that functionality. Usually native unsafe support is the cleanest way to go.
Re:Ask HN: Why do you use Rust, when D is available? by pjmlp on Saturday June 13, 2020 @04:02AM (#23507740)
> Industry really, really needed C-like language that was memory safe, and all-round good: both low and high level. And Rust quickly delivered that, borrowing all the great aspects of other languages and addressing a lot of problems.

Industry has had Ada since 1983, Modula-2 since 1980, Object Pascal since 1990, and a couple of other ones, not counting all those Algol and PL/I variants that precede C for about 10 years.

Unfortunely the industry will only take security seriouly when security exploits are severly punishable by law.

Re:Ask HN: Why do you use Rust, when D is available? by mrfusion on Friday June 12, 2020 @12:14AM (#23495960)
I’m currently trying to get into robotics. But why does everyone want c++? Surely robots can be programmed in other languages.
Re:Ask HN: Why do you use Rust, when D is available? by blub on Friday June 12, 2020 @04:57AM (#23497366)
Because the real world doesn't really match the expectations and statements of the HN community. It's really rare that I see here anything pragmatic regarding what programming languages to learn/use.

The community lives in a bubble and is out of touch with mainstream software development.

Re:Ask HN: Why do you use Rust, when D is available? by Recurecur on Friday June 12, 2020 @09:48AM (#23499191)
I'm a very senior engineer. I've had a strong desire to find a better alternative to C++ since the 90s when I was first exposed to it (I worked with it for about a decade, after a few years with C). Now, decades later, enough bandaids have been applied that it's somewhat tolerable. Congratulations...?

The industry has needed good alternatives for a long time. Finally, they're coming, and not nearly soon enough to suit me! :-)

Re:Ask HN: Why do you use Rust, when D is available? by blub on Sunday June 14, 2020 @06:52AM (#23516682)
I believe you're right about those alternatives not coming soon enough. If all things go right, by the time Rust will be (sort of) mainstream you'll be able to set up the "Rusty Grampas League" :-)
Re:Ask HN: Why do you use Rust, when D is available? by MacSystem on Wednesday June 17, 2020 @02:50PM (#23555183)
What are thoughts on D?
Re:Ask HN: Why do you use Rust, when D is available? by vardump on Friday June 12, 2020 @07:00AM (#23498007)
"pragmatic /praɡˈmatɪk/ adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical considerations."

I consider Rust more pragmatic at this point. Perhaps it's because I code in C++ as my dayjob and have to deal with the consequences.

In theory, C++ is perfect given perfect developers. In practice, it's more sensible and realistic to write tricky, like multithreaded, code in Rust.

One rarely mentioned important factor: fear. It's much less scary to modify something written in Rust than in C++. Doubly so for less experienced developers.

Re:Ask HN: Why do you use Rust, when D is available? by danielscrubs on Friday June 12, 2020 @05:59AM (#23497671)
I'd wager we actually have a lot of clever teenagers here at HN. Well-meaning, but has never worked in a team nor has any experience of what the market rewards.
Re:Ask HN: Why do you use Rust, when D is available? by mratsim on Friday June 12, 2020 @05:12AM (#23497440)
Technically robotics isn't mainstream, Javascript/PHP/Java/C# are, at least in terms of developers. Now in terms of code deployed, C on the billions of embedded devices may be able to compete with servers?
Re:Ask HN: Why do you use Rust, when D is available? by _bxg1 on Friday June 12, 2020 @12:30AM (#23496038)
A language is more than just a technology: it's an ecosystem of libraries, platform APIs, developer mindshare and experience, familiarity, legacy codebases, product support. Don't discount the weight of all of those auxiliary, human factors.

Rust, culturally, comes from the web. That's why it has the most traction in the web server/WASM space for now. It's starting to poke its head into Systems use-cases because of the sheer weight of its memory safety benefits there. Maybe in a few years it'll get some real use in the games industry (real industry; not just enthusiasts), though Unreal remains a bastion of C++ that isn't going anywhere anytime soon. But then there are some dark corners of C/C++'s territory that move even more slowly, and where the cultural shift will take a long time. I think to a great extent, embedded falls into that category.

Re:Ask HN: Why do you use Rust, when D is available? by timw4mail on Friday June 12, 2020 @09:11AM (#23498848)
Not really. While there is a growing set of web-based application for Rust, it's not like PHP, where the very purpose of the language is the web. Rust is a system language before it is a web language.

WASM as a target is actually a great indication that it's a system language -- performance is a primary consideration.

Re:Ask HN: Why do you use Rust, when D is available? by _bxg1 on Friday June 12, 2020 @10:35AM (#23499614)
You're missing the point. The point is that Rust came from Mozilla. Its mind-share started with web people and is expanding from there. What I'm trying to get across is that those social forces can matter more for adoption than just the tech's appropriateness, considered in a vacuum.
Re:Ask HN: Why do you use Rust, when D is available? by setr on Friday June 12, 2020 @12:41PM (#23500979)
In that case, it came from Mozilla for working on a web browser, with primary goals of security, building sandboxes & language runtimes (js), and replacing an application-level cross-platform C++ core.

Which is very different than "web people", which in my mind implies webdev -- html/css/js + API server/db/caching backend.

Which also further explains why WASM is so far along (sandbox, security), much better than any association with webdev itself; but not kernel-level system development. (But if the web browser is an userspace OS... then it's probably not that far from it)

Re:Ask HN: Why do you use Rust, when D is available? by type0 on Friday June 12, 2020 @06:37PM (#23504593)
Off course it's a system language, there are even some that try to build an OS in Rust

https://www.redox-os.org/

Re:Ask HN: Why do you use Rust, when D is available? by pjmlp on Saturday June 13, 2020 @11:40AM (#23510197)
Everyone is targeting WASM nowadays.
Re:Ask HN: Why do you use Rust, when D is available? by Recurecur on Friday June 12, 2020 @09:44AM (#23499152)
> But why does everyone want c++?

Few "want" C++, but for robotics a non garbage-collected language is necessary so latency is predictable. There are few mature languages besides C/C++ in that category.

Rust is an improvement, but I'm hopeful something like Julia (Julia Robotics, https://juliarobotics.org/) or Scala Native (https://scala-native.readthedocs.io/en/v0.3.9-docs/) becomes mainstream, the productivity gains would be substantial.

Re:Ask HN: Why do you use Rust, when D is available? by WorldMaker on Friday June 12, 2020 @08:03PM (#23505260)
Garbage-collected languages can have (and some have had) latency-predictable GCs. It's not entirely an either/or, it's something of a false dichotomy. "Non-garbage collecting" languages blur the line anyway because even basic things like reference-counting are still a garbage collection technique. The trade-offs are in how many control knobs and where those knobs are/how you turn them, and a lot of developers still seem to feel much more "comfortable" manually writing all the knobs by hand than trusting a more algorithmic GC's shiny chrome knobs on the outside of (what they presume to be) a black box.

But perceived "comfort" isn't entirely reality. (The comfort of smart GC languages is immense in a different way.)

Re:Ask HN: Why do you use Rust, when D is available? by Recurecur on Saturday June 13, 2020 @10:01AM (#23509399)
Something of a false dichotomy - perhaps. The fact is that allocating at all during realtime operation is frowned upon. Given that the best approach is pre-allocation and then turning off the GC, why carry the overhead of the GC at all?

For 99% of realtime work, the Rust or Scala Native approach is just fine. No GC required. Julia users can just use the pre-allocation approach.

The important thing is avoiding language patterns that encourage needless allocation.

Re:Ask HN: Why do you use Rust, when D is available? by WorldMaker on Monday June 15, 2020 @12:46PM (#23529435)
> Given that the best approach is pre-allocation

GC languages still support stack allocation, you don't have to pre-allocate anything you can stack allocate. (That's where .NET Core has been especially burning rubber in recent releases. Span<T> is a stack allocated, GC-safe "pointer", for instance, that is doing all sorts of heavy lifting in .NET Core performance-critical work these days. It's still early too, as not everything has moved to Span<T> that can move to Span<T> and family.)

But also, not everything needs to be pre-allocated for the "best approach". There's some work to get used to the feel of any specific GC, but most modern "VM" GCs (.NET and today's Java, not yesterday's) are multi-generational and there's a lot you can do in strategies such as "focus on the nursery and the LOH" (using only [potentially many] small short-lived objects and a few, mostly stable "very large" objects, avoiding the intermediate generations).

> why carry the overhead of the GC at all?

Safety. (Why wear seatbelts?) Rust's borrow checker is great but it still requires a lot of manual adjustment and it's still possible to miss something (it's not easy, certainly, but it is possible); a GC gives you safety by default, with no manual intervention required to guarantee safety, and requires manual effort to write unsafe code.

> The important thing is avoiding language patterns that encourage needless allocation.

That's where we agree and why I'm very adamant that though some of the tools ("knobs") look scarily different in performance optimization for GC versus non-GC languages, the vast majority of the tools are the same: know the O(memory) of your algorithms, and make smart trade-offs regarding that O(memory), avoid allocating what you don't need, know your trade-offs between pre-allocation and allocation only when necessary, etc.

Re:Ask HN: Why do you use Rust, when D is available? by danielscrubs on Wednesday June 17, 2020 @04:49AM (#23549268)
> it's still possible to miss something

Could you elaborate?

Re:Ask HN: Why do you use Rust, when D is available? by WorldMaker on Wednesday June 17, 2020 @01:25PM (#23554073)
Tbf, I've not directly worked in Rust so my understanding is mostly academic of a sort. The issues I'm directly aware of are primarily in boundary conditions between unsafe and borrow-checked code, which isn't entirely fair to Rust as GC-languages of course have the same boundary conditions. My impression however is that because the borrow checker is a lot of work, there's a lot more Rust libraries in the wild with unsafe code sections than strictly need to be (as compared to similar libraries in GC-languages, and especially with modern tools like Span<T> in .NET nearly shrinking GC-unsafe blocks to non-existent in modern code).
Re:Ask HN: Why do you use Rust, when D is available? by pjmlp on Saturday June 13, 2020 @03:48AM (#23507678)
PTC and Aicas sell real time Java implementations for robotics, among other similar deployment scenarios, lack of customers is something that they don't suffer from.
Re:Ask HN: Why do you use Rust, when D is available? by rozab on Friday June 12, 2020 @11:01AM (#23499910)
For some reason Python seems to be very popular in academic robotics right now. Not a great choice
Re:Ask HN: Why do you use Rust, when D is available? by Recurecur on Friday June 12, 2020 @12:54PM (#23501153)
Being a "better, stronger, faster" Python is fairly near Julia's sweet spot... :-)
Re:Ask HN: Why do you use Rust, when D is available? by type0 on Friday June 12, 2020 @06:32PM (#23504558)
> Not a great choice

It is a great choice to prototype the ideas

Re:Ask HN: Why do you use Rust, when D is available? by DarmokJalad1701 on Friday June 12, 2020 @11:10AM (#23500020)
As a datapoint/anecdote, I work in an autonomous vehicle company and we have adopted Rust extensively in our codebase in the last six months or so.

Previously, the code base was primarily Python with some C++. Now there is a significant chunk of code, particularly related to safety, written in Rust.

Re:Ask HN: Why do you use Rust, when D is available? by MacSystem on Wednesday June 17, 2020 @03:02PM (#23555325)
That's interesting. But did your company consider using D? if so, why did chose Rust?
Re:Ask HN: Why do you use Rust, when D is available? by calaphos on Friday June 12, 2020 @07:08AM (#23498053)
Rust is very very new compared to Cpp. People have decades of experience with cpp, learned in in University. Why would you throw all of that overboard just to learn a fancy new language with a weird ownership system? Keep in mind that people often still write cpp98 and have a rely hard time getting used to newer cpp concepts and programming styles. And all of that is backwards compatible with their existing codebase.
Re:Ask HN: Why do you use Rust, when D is available? by Aeolun on Friday June 12, 2020 @07:43AM (#23498246)
> Why would you throw all of that overboard

Firstly, because 75% of all that knowledge is easily transferrable.

Secondly, because you want to take 50% of your bug count.

Re:Ask HN: Why do you use Rust, when D is available? by zucker42 on Friday June 12, 2020 @11:03AM (#23499947)
He was saying this in the context of "why do people still use C++ at all".
Re:Ask HN: Why do you use Rust, when D is available? by bjourne on Friday June 12, 2020 @09:11AM (#23498846)
But why not program in Python and take 100% of your bug count?
Re:Ask HN: Why do you use Rust, when D is available? by UncleMeat on Friday June 12, 2020 @10:44AM (#23499709)
It is slow.

It doesn’t work well for embedded programming.

It very much does not fix all bugs, especially given lack of static type checking.

Re:Ask HN: Why do you use Rust, when D is available? by dpc_pw on Friday June 12, 2020 @05:08PM (#23503942)
It will sound harsh, but people who can't up their game from C++98 to C++11, are probably not a people that I would consider hiring anyway. Generally, personally I would not hire anyone that knows just one programming language that they've learned in University and for years didn't manage to practice anything else, but that's just me.

I actually worked in Automotive, and the software higher level up the stack there is usually god damn awful piece of s*, often done by people who have almost no clue what they are doing, with plenty of misconceptions about how C/C++ even really works (using `volatile` for concurrency/atomicity and stuff like that). They are just beating their spaghetti code from segfault to segfault for decades.

This and slow delivery process easily explains why entertainment, navigation and other software-driven part of mainstream cars are so buggy, slow and generally terrible, and why Tesla could have so easily deliver way better experience.

So it doesn't matter that some people can't "get into Rust". The business that hire them will be replaced if they can't up their game, that's all.

Re:Ask HN: Why do you use Rust, when D is available? by MacSystem on Wednesday June 17, 2020 @03:07PM (#23555412)
If D have had a proper tooling, like C# and VS, do you think companies in the automative would consider to use D instead of C++?
Re:Ask HN: Why do you use Rust, when D is available? by PopeDotNinja on Friday June 12, 2020 @04:02AM (#23497093)
Probably the same reason Python is big in scientific computing. A lot of stuff has already been written for it. If scientists needed to bootstrap scientific computing from scratch, Python wouldn’t be any more established than Rust, Java, PHP, or VB6.
Re:Ask HN: Why do you use Rust, when D is available? by calaphos on Friday June 12, 2020 @07:13AM (#23498080)
Afaik pythons success in that field is relatively recent, only really taking of ~2010. The language was already 20 years old by then. Compare that to rusts first stable release in 2015.

Building ecosystem just takes time.

Re:Ask HN: Why do you use Rust, when D is available? by MacSystem on Wednesday June 17, 2020 @03:08PM (#23555428)
Python is easy to just start writing then the network effect made others use it
Re:Ask HN: Why do you use Rust, when D is available? by flor1s on Friday June 12, 2020 @04:16AM (#23497161)
Check out https://www.ros.org - it allows you to program in either C++ or Python (with some other languages being supported by the community)
Re:Ask HN: Why do you use Rust, when D is available? by jki275 on Saturday June 13, 2020 @09:12AM (#23509128)
The problem is that whIle C++ has problems, all languages have problems and C++ has the most going for it in terms of being fast and easy to write.

C++11 is a really good language. Also there are tons of libraries and things people have already built in it that you can leverage to reduce development time.

Re:Ask HN: Why do you use Rust, when D is available? by westicecoast32 on Friday June 12, 2020 @10:50AM (#23499774)
Really? I find that rust is worse than C++ thanks to clang

For example, is there a way in rust to get a runtime error when there's an int overflow?

Re:Ask HN: Why do you use Rust, when D is available? by zRedShift on Friday June 12, 2020 @11:05AM (#23499967)
Of course. rustc has the "-C overflow-checks" flag. Cargo turns it on by default for debug builds. To turn it on for release builds, just put "overflow-checks = true" in the [profile.release] section of your Cargo.toml.

Or better yet, the Rust standard library exposes all the relevant LLVM intrinsics for the primitives, so you have the {Integer}::checked_, {Integer}::saturating_, {Integer}::wrapping_, {Integer}::overflowing_ (inlined) functions to do all your integer math in an error-free fashion.

Re:Ask HN: Why do you use Rust, when D is available? by zucker42 on Friday June 12, 2020 @11:00AM (#23499902)
Yes there is. Overflow panics by default in debug mode, and you can turn that in in release mode with the overflow-checks compiler option. There's also checked_add.
Re:Ask HN: Why do you use Rust, when D is available? by danielscrubs on Friday June 12, 2020 @05:54AM (#23497649)
Are you saying AAA-game/kernel/embedded developers are not normal? Pretty uncalled for if you ask me.
Re:Ask HN: Why do you use Rust, when D is available? by dpc_pw on Friday June 12, 2020 @05:49PM (#23504277)
Depends on how you define normal. :D I offended a lot of C++ fans, I guess.

I guess what I meant is "vast-majority of devs out there".

I did ~10 years of kernel/embedded myself. Generally people use C++ only when they really have to (like: they work in one of this niches, or want to get a job there). I've experienced myself many times when people would go with anything but C++ because of all it's faults, weaknesses and general infamy. And I also have seen some people that gave Rust a try and it went smoothly. They deliver a proper C++-level performance and resource control, without any of the problems and were happy about the experience.

AAA-game/kernel/embedded are all lucrative (except games, lol), important and not tiny but they are still niche.

Re:Ask HN: Why do you use Rust, when D is available? by MacSystem on Wednesday June 17, 2020 @03:11PM (#23555454)
How aren't games so lucrative? did you any of your guys did try D before rust?
Re:Ask HN: Why do you use Rust, when D is available? by bigjake on Sunday June 21, 2020 @04:42PM (#23595246)
Normal people? Exactly what is a normal person there, Einstein.