Bjarne Stroustrup Weighs in on Distributed Systems, Type Safety and Rust
thenewstack.io
thenewstack.io
Does anyone know what these accusations were? Given that C++ has been around for so long, It's incredulous to think that anyone from the Rust community can put forth such a claim.
If you talk about something so undefined as _the Rust community_, I'm pretty sure I can claim that _someone of them_ has said pretty much anything in existence.
Like some of the "why did you not write it in Rust" bros on any forum like Reddit or here might very well have writen some utter bullshit about other languages, would not be surprised.
I wish people wouldn't talk about one or two people with a warped view as "the community".
It really shows Stroustrup's point on how most of these programming concepts have been around for a long time.
At least in the quoted sections, they weren’t talking about the opinions of the rust community, but rather those of someone from the Rust community.
It is not a C++ idea anyway, older languages have had similar facilities.
I think this is exactly the thing: if you come from C++ it's very obvious that they drew a lot of inspiration from there (I won't use a charged term like "copied"). But I get the impression that people who got into rust without learning C++ first are largely unaware of this. Or, even if they had worked with c++ but missed the boat on raii and smart pointers.
You will also see some safety assertions regarding stuff that was already safe when using Ada, or any Modula or Oberon linage of programming languages.
Not everyone on Rust community tends to be like that.
In a few years that will pass, and people will not say extremely silly things like "incredibly honest" anymore. But they will necessarily take up saying other equally silly things.
British newspapers regularly host shrill complaints about language degradation in the Colonies, but in every single case the reviled usage turns out to have started somewhere in England, typically before the colonials went. That shouldn't surprise: there is overwhelmingly more variability in English usage in England than the sum total in all other places.
It would not be at all surprising if "incredibly" went through a similar cycle 200 years ago. For a time, "nice" meant "stupid", before it meant "precise". For a time, "plausible" meant "implausible". Just be glad abuse of "exponentially" has fallen off.
Maybe, or maybe it is an unprecedented recent spike. We're both guessing, I suspect.
[5 minutes research later] Well, there is this measure of the frequency of 'literally' in books in English since 1600. (Although I meant in speech and online comments)
https://books.google.com/ngrams/graph?content=literally&year...
Which does seem to possibly support the 'unprecedented spike' hypothesis! A huge surge since 1990, the largest ever, the word is now used twice as often as in books in 1990.
Looking at examples from 1800-1820, during the 2rd biggest surge, which lasted around 100 years centred on 1840,
https://www.google.com/search?q=%22literally%22&tbm=bks&tbs=...
- none of those on the first few pages of results appear to be the general intensifier kind of 'literally'.
Compare with 2019-2020, where most examples in the first few pages are the kind I've gotten so sick of lately:
https://www.google.com/search?q=%22literally%22&tbm=bks&tbs=...
I eagerly await further research in the field. :-)
A modern confounder is that copy-editing activity has declined along with the cost of publication, so that misuse that previously appeared much less in print than in oral discourse now evades scrutiny. Transcripts of court testimony would give a better sense of how people spoke.
Nonetheless, from your link I find in 1812, "was literally bathed with sweat" and 1810, "it shall bruise thy head, and thou shalt bruise his heel. This between the woman and the Serpent is most literally fulfilled ."
But yeah indeed, rust borrowed more concepts (e.g RAII) from C++ than C++ borrowed from rust
> The inspiration for safe borrowed references comes in two ways from the Cyclone programming language, a joint development effort by AT&T and Cornell University. The notion of a borrowed reference is adapted from Cyclone’s polymorphic restricted alias pointers. Additionally, Cyclone’s safe memory management focused on regions (which are usually arenas). In order to ensure memory safety, Cyclone pointers could be annotated with a named region qualifier preceded with a back-tick (making them look very much like Rust’s apostrophe-based lifetime annotations).
Joking aside, it's funny that Bjarne did not talk about D since it seems that C++ is copying many of D nice features in later of C++ iterations for over a decade now.
And now D is copying the Rust/Cyclone ownership concept, nice!
Modules and contracts have taken something like 30 years combined, and they still aren't prevalent. The tried to borrow static if, but theirs is scoped and misses the point (the static if paper).
All of the aforementioned are maintained in a language that has less maintainers than C++ has committee members, with better solutions and orders of magnitude faster compile time.
I find many of the people on their forums quite nice, but D lacks a profound sense of direction and which market they want to target.
The fact that C++ is only used for performance is due to C++ being a bad language everywhere else rather than being amazing at writing high performance code. How many hours of developer productivity have been lost to slow compiles and bad metaprogramming (traits, contracts, and constexpr are emblematic of the half in half out C++ way)
By the way no one at Remedy is using D nowadays, while the number of studios using C# alongside C++ keeps increasing.
Languages taking inspiration from other languages and that's normal I don't think anyone bm the people I know from the rust community (which e.g. work on the compiler and language) would do so.
That's except if you write something like a paper, in which case it's party of the proper proceeding to mention "priority art" you are aware of *even if you didn't copy it or even had the idea early but just didn't publish it.
I hope it's just some random thing he remembered thought of when causally doing the interview, because the other alternatives wouldn't make him look good.
First Mozilla introduction of Rust states:
> Rust is a language that mostly cribs from past languages. Nothing new.
http://venge.net/graydon/talks/intro-talk-2.pdf (I recommend reading the slides — they're great!)
so whoever is accusing C++ of "stealing" Rust ideas is uninformed about C++ and Rust.
That is both a good and bad thing.
Within both C++ and JavaScript there is a very elegant programming language with powerful semantics.
However, there are also a lot of bad solutions and dangerous hacks accumulated. And most of us programmers don't know how or don't have the self discipline to separate the good parts from the bad parts. And sometimes even with the knowledge and self discipline you can't avoid them (e.g: when using someone else's libraries).
In some languages (e.g: Lua, Python) the designers are ready to break backwards compatibility. C++ chose not too.
Old code will always seem old fashioned. It will not address modern concerns. However, the option to keep using it is very valuable!
Pick any other language survey of your choice and I guarantee you it will generally agree with the TIOBE.
We still have a mumbo jumbo mess of py2 scripts lying around.
Perl 7 is the new opportunity for backwards incompatibility (and probably doesn't even have an entry on Tiobe which would make your argument even stronger!)
Also, Tiobe is about as interesting as a gossip column. There are many reasons to pick one language over another, but ranking on Tiobe will never be one of them.
That's rich. Figuring out how to use C++ on a large project (where you often depend on existing codebases) is always an exercise in figuring out what subsets of what version of the language to use. Presenting C++ like one language that has maintained backwards compatibility is, at best, a gross oversimplification of what is one of the bigger headaches of using C++.
That being said, I can't remember C++ ever doing something directly destructive and unnecessary like redefine how integer division works like I have seen in certain other languages that also result in hostility towards the user.
There are still quite a few Python 2 codebases that will never migrate to Python 3, and quite a few developers who still use Python 2 for new projects.
Anecdotally, several Python developers I know would rather rewrite their Python 2 programs in another language than put in the work to move to Python 3. A lot of them seem to be considering Go and Rust.
The way the Python 2 to 3 change was handled was a huge mistake.
[citation needed], I haven't seen anyone use Python 2 for new projects in the last ~5 years. It reached EOL this year, nobody in their right mind would use Python 2 for new projects today.
But at runtime it's essentially free.
C++ on the other hand added a set of primitives starting in C++11 to be explicit about ownership through std::unique_ptr and such. These have a runtime cost and ultimately mean getting locks. I've seen estimates of this cost in the single digit microseconds. Not exactly super-expensive but not free either.
There are simply some assumptions Rust can make that C++ can't because certain things aren't possible in Rust.
Another example: Rust doesn't have exceptions. Over the years I personally have some to believe that exceptions are largely a false economy (particularly the failed experiment that is/was checked exceptions in Java).
Instead Rust has match expressions and enumerated types (with state!) that force you to deal with return types. This BTW is very much what Google C++ looks like. It's even debated if you can ever write truly exception-safe C++ code.
This is another problem Rust doesn't have by virtue of not having the feature.
Are you starting to see the pattern? C++ has everything in it. That comes at a cost and there's no getting around that.
You're no doubt thinking of shared_ptr (which I guess is what you meant by "and such"). That has a reference count, which does not lock but does use an atomic counter with the usual costs that involves. unique_ptr has no such thing and is essentially free.
https://m.youtube.com/watch?v=rHIkrotSwcc
17:40
I was responding to a comment that claimed that std::unique_ptr used locks to transfer ownership, and my objection to that is not disputed by what your saying.
You're making the point that exception-safe code is less efficient than exception-unsafe code. I do not know enough about that topic to comment on that matter, I was never trying to say anything about it in my previous comment. But I would like to point out that Rust has an analogue of exceptions: panics (although you can change their behaviour to abort() instead of unwind). So it must have something similar to unique_ptr's unwind handler anyway.
What do you mean by "it" in "it doesn't deal with exceptions"? Rust? Or the C++ snippet on the left hand side in the presentation with the shorter assembly output?
Edit: Since I'm still apparently not clear on your main point, this might be irrelevant, but here [1] is a Godbolt link showing that Rust functions have similar panic-safe unwind code to the C++ exception unwind code shown in the presentation. Admittedly the Rust version does seem a bit shorter (comparing just the actual function, at the bottom of the Godbolt output) and I'm afraid I don't know enough assembly to be able to analyse the difference. But I think the principle is similar.
Arthur O’Dwyer - Mastering the C++17 STL,
Jacek Galowicz - C++17 STL Cookbook,
Scott Meyers - Effective Modern C++ books
also https://github.com/isocpp/CppCoreGuidelines/blob/master/CppC...
and https://en.cppreference.com
and the conferences of CppCon in youtube.
That said, I find he only covers a few of the more tricky topics, then after a brief “this is what it is and why its useful”, then spends more time on “these are all the edge cases that are dangerous and confusing”.
Maybe he’s right and it’s important to learn all that. But I tend to finish a chapter and think “Cool feature, but I’ll never remember all those foot-guns so I’ll just avoid it if I can”.
But maybe that’s a fair take on C++ <shrug>.
Most books just explain the language/system design, and add value only by crafting good explanations. But Scott (and others) add an element of experience as well, which is extremely valuable.
I don't think you need to learn all the corner cases, but reading about them at least helps me a lot with understanding the underlying semantics. And when I do run into them, I might get a vague uncomfortable feeling that's enough to make me go back to the book for a reminder.
After that you can try Stroustrup's "Tour of C++", second edition for a more formal introduction to the language (C++20). You will be ready to tackle coding modern c++.
Better concurrency and functional-style pattern matching? Yes please.
What I would like to see in C++ would be green threads and use of io uring and restartable sequences like in project loom.
C++20 added coroutines already.
I dream of C++20. But my nightmares are all pre-C++14.
Don't know about Rust, but for go:
. can't match C++ on speed
. doesn't (yet, AFAIK) have generics.Go was at least originally touted as a C++ replacement, but to be honest, that story hasn’t really panned out in practice.
https://github.com/f-secure-foundry/tamago
If you are not on a green field, stuff gets complicated. If you have a really good Rust programmer on the team, that is willing to take care of the language interop it can work well, if you have a bunch of Rust learners, you might blow up.
There are still areas where C++ is more expressive than both rust and go. AFAIK rust just recently got the capability to work with const generics and compile time evaluation.
Lack of overloading (besides operators) in Rust is a double edged sword. Overloading allows for very expressive C++ code in the expense of awful error messages when it doesn't work out.
C++'s concurrency story is continuously improving, but I'm not qualified to compare here. C++20's coroutines will be quite powerful.
And there is one area where Rust and go can't compete: interacting with existing C++ code, including templates. There is a lot of that already.
Having said that I keep a close eye on rust, it can certainly replace C++ in certain areas, possibly all areas in the future. But it can't replace it overnight, considering that there are millions of lines of _maintained_ C++ code out there.
Not go though, that's like comparing apples to oranges.
I wonder if we could ever get direct Rust to C++ FFI. There are ways around it of course, by dropping down to C FFI in both languages.
https://github.com/dtolnay/cxx/ exists and works well AFAIK. That's what Chromium (https://chromium-review.googlesource.com/q/project:experimen...) and others use.
ISO C++ also does not define how std::thread should be mapped into the host platform.
I think one make a good argument for Rust, but you will also have a harder time sourcing developers and ramping up to speed. It's still novel, despite maturing rapidly.
There are many many many high quality C++ libraries out there, and the modern C++ language is, for me, decently pleasant to work with, once you pick your style and set of constraints.
Also, I really don't want to go around on this argument _again_, but I don't think Go is a serious competitor for C++ for the systems level programming where C++ dominates. Go is not the language for writing OS kernels, drivers, embedded code, etc. Nor do I think a garbage collected system is appropriate for hard real time systems of most kinds.
I think what we have here in this discussion is another classic case of HN having a bit of a blindspot for anything that isn't web / web services or mobile app development. For many embedded systems developers for example it's a challenge just to get them to consider C++ over C, let alone something like Rust.
Except that now there is vcpkg, conan, prefab (on Android) and contrary to cargo,they support binary libraries, meaning I don't have to build the world every time I start a new project.
Doesn't support binary libraries? I don't really care considering everything else I get, I'm sure they'll support that in the future.
Speaking of modern landscape where is a Rust IDE comparable with VS, C++ Builder, QtCreator?
You got a similar response in another thread: https://news.ycombinator.com/item?id=24038376
Even without a package manager adding dependencies manually is quite easy for the vast majority of popular libraries. With a manager it is the same as cargo.
I assume you are talking about old, broken, unsupported, closed source, binary only libraries, but then it is not a meaningful comparison.
This is exemplary of why Rust will win out in the end. The c++ crowd can't acknowledge its shortcomings and fix them in a meaningful way
Usually a single line does it in all of them, either in the shell or in a config file.
I call FUD.
Rust is going to make the C++ community actually look in the mirror for the first time in who knows how long.
C++ doesn't conform to this model.
The issue for you might be ease of configuration, but that's not the issue I was talking about. It's availability of libraries and toolkits, which C++ still dominates in the realms of mathematics, graphics & video, GPU programming, gaming, embedded, networking, etc. And if there's something not available for C++ chances are it's there for C and easily used or wrapped.
Configuration management has indeed been C and C++'s weak point, but in the last 5-10 years things have definitely improved since the world of autotools and the like, and while I appreciate Rust's module and package system for what it is... I can get by with CMake + Hunter or similar systems.
And besides, for my day job (Google) it's either C++ with GN/Ninja or C++ with Blaze/Bazel. And that is also quite excellent for what it is.
At this point my career being able to quickly try out a package or rapidly add a new dependency isn't my measure of quality engineering. In my past life I was a Java developer and a big Maven advocate (when it was pretty new); and the world of bottomless dependency trees that spawned is not something I'm eager to repeat. These days I try to keep my external dependencies ... strategic.
and community is the most important aspect of a language.
Yes c++ still dominates in accelerated computing but it won't for long. All these conversations I've had with c++ devs have just assured me of its demise.
Why would the next generation of developers ever use c++ over Rust?
Don't have a library? Great thats my chance to make my mark.
Although it is a polyglot target environment, CUDA hardware is designed for optimal support of C++ semantics.
C++ is used for device drivers on Apple and Google's OSes.
Swift and Rust depend on LLVM, written in C++.
Unreal, Unity, CryEngine, Godot have C++ at their core.
AUTOSAR safety standard for cars is based on C++14.
UWP and DirectX are heavily based in C++.
Tensorflow and PyTorch depend on C++.
And plenty of other endless examples.
Sure you can try to make do with Rust or Go, but be prepared to code like we used to program in C++ 30 years ago in regards of eco-system, IDE support and wealth of existing libraries.
Additionally, if you work at one of the FAANGs (or many other large established companies) there's good chance you are working on an existing C++ base, with existing C++ build tools, with a good C++ style guide, and with plenty of other competent C++ engineers. Rust is not of the endorsed/established languages at Google. (And no, Go isn't frankly used as much at Google as people seem to think it is, though its use is increasing).
That's a bit of an extreme statement that needs some significant qualifications. This might be true if you are pushing for Rust or Go in one of the domains you mentioned, like professional game development. It would be fairly absurd for a studio to seriously try to switch to Rust in some of these areas.
That said, if you're largely working on greenfield projects that don't rely on an existing C++ ecosystem, the situation almost gets inverted. For instance, C++ still doesn't have any kind of standardized package manager in 2020. There are a thousand little paper cuts in C++ that are hard to justify if you don't have to interface with an existing ecosystem or target a specialized environment that only it is well-suited for.
But TBH, I really don't want to use C++ if the circumstance allows. The language spec is just so overtly complex that feels self-defeating, it is harder and harder to justify use it in the first place.
Looking at some of the solutions for both Go and Rust, its either immature bindings to wrap around C or C++ for the same thing (the best you would get is GTK+) which are unmaintained and less stable / usable to what you would get with Qt5 with C++.
I still keep seeing lots of cross-platform closed and open-source GUI apps still taking the Qt route.
There are 2 levels of comparisons:
- (1) language syntax : the "they're both Turing Complete" so whatever one can do, the other can do and because Rust is newer, it has nicer syntax. E.g. plain Rust syntax already has "ownership pointers" by default so doesn't require typing ugly verbose syntax such as "unique_ptr<T>".
- (2) ecosystem and dependencies : In 2020, C++ and not Rust is still the primary API for things like NVIDIA CUDA, Unreal game engine, Qt GUI, and the ARM Allinea developer tools[1] for compiling code for the new Neoverse chips (e.g. latest AWS Graviton2 ARM servers). Sure, one could write wrappers in Rust for all those things but doing so will be going against the grain and now you're yak shaving your tools instead of building business value.
If I had a brand new startup today, I'd use Rust as much as I could but there'd still be 25% to 50% new C++ code because deep learning (e.g. CUDA) is C++ not Rust.
[1] https://www.arm.com/products/development-tools/server-and-hp...
* Compiler support
* Availability of suitable engineers
Context - I work for the Wireless Division of Cambridge Consultants (Cambridge, UK). We build comms technology for our clients for basically anything you can think of - satphone, telecomms infrastructure, bluetooth headphones etc. This means that a lot of the software we right runs on an embedded target - that might be a microcontroller or it might be Linux. And importantly - often when we've designed something, our clients will carry on the maintenance and ongoing development.
We have to take the long view - if we choose C/C++ we can guarantee that a compiler will exist for whatever hardware target they choose for the next generation of the product (or even the current generation - architecture swaps often happen at the cost reduction stage). Rust support is improving but can I guarantee that there will be a compiler available for some niche processor, or even the Xilinx Zynq target I'm using at the moment?
And then when we hand over the code, we have to explain to the client that it's written in a language that none of their existing software engineers know, and if they advertise for people they may or may not be able to find them.
All that said, we are pushing to use more suitable languages for our work. Using C/C++ for anything where security is important is beginning to look irresponsible, the above issues don't always apply and that combined with improved embedded support, more name recognition for Rust and ever more enlightened clients means that it's going to be an easier sell for more and more projects. But not all of them, not now.
Actually it turns out that it's easier to sell Elixir as an alternative to some of our C development. My current project is a Linux target, microprocessor support is not important and the challenges it has are exactly what Erlang is designed to solve. I'd also suggest it's easier to incrementally teach the client Elixir than Rust. We'll keep pushing Rust though, and we'll get there eventually.
When you turn code over to someone else it matters because who you turn it over to needs to learn the language fast and they won't have a few weeks or someone else to teach them.
I don't think this is true. I say that even though I would be deliriously happy if Rust replaced C++ in most situations it's currently used.
Yes, learning the whole of Rust, including any/all dark corners (no doubt it has a few) is easier than learning the whole of C++ including all its dark corners (it certainly has many!). But getting a basic working knowledge of both is not too different... except for Rust's ownership system. I realise that the ownership system is one of Rust's main benefits, but that doesn't change the reality that it's a significant obstacle for many decent developers.
I actually wish it were possible to use Rust in an "unsafe everywhere" mode where you could ignore the ownership stuff. (Maybe this is already possible with liberal use of the "unsafe" keyword, but it is at least socially unacceptable.) Of course it wouldn't be right for every project but it would still be a huge improvement over C++ while being much more accessible than fully safe Rust.
> (Try to contain your horror! :-) )
Ha! Nah, no horror there. It is interesting to think about, for sure.
(Obviously I'm not a Rust expert, which is why my comments are in the form of questions.)
You can cast them to a reference. The issue is, the tricky UB happens at this exact boundary. If you're only using references, then the compiler has your back. If you're only using raw pointers, then there are no aliasing issues, so you're good. The hardest part is exactly the boundary between the two. Staying in one world or the other is much easier than going back and forth.
As for the rest, there is vcpkg and conan nowadays.
Needed some high performance code last year, wrote it all in c++. This year migrated to Rust, will never look back.
C++ is going to need to break things if they want to fit into the modern landscape.
Speaking of modern landscape where is a Rust IDE comparable with VS, C++ Builder, QtCreator?
I use VScode with rust-analyzer and its been a great experience, had an easier time with it than the c++ vscode extension.
So does any of the main package managers for C++.
> had an easier time with it
That is an empty argument. Not to mention Rust is only now in 2020 starting to get actual IDE support.
For C++ there are at least 8 major production GUI IDEs available, plus a few TUI ones too, plus dozens and dozens of specialized tools around it.
> That is an empty argument. Not to mention Rust is only now in 2020 starting to get actual IDE support.
Actually thats an empty argument, I'm responding to someone saying rust doesn't have IDE support.
It does, I use it every day and it works great. Not saying c++ doesn't just saying it worked better for me than the MS c++ vscode extension.
rust-analyzer is great and we have waiting for it a long, long time. But it is not an IDE. Neither is the MS C++ extension.
I've been using vscode for the last 5 years for all kinds of languages and have never though to myself "I wish I had an IDE"
The Rust and C++ extensions are very far from what an IDE offers. They only handle basic debugging and code completion/browsing. With a few more extensions you can a bit better, but again, you are doing the job that an IDE is supposed to solve for you.
There is an eco-system out there for C and C++ developers where companies only sell binary only libraries.
VSCode is not an IDE, just an text editor with a couple of plugins.
C++ Builder, Visual Studio, XCode, Android Studio, QtCreator, KDevelop, those are proper IDEs.
vscode is one of the most used editors on the market and I seem to be able to produce quality software in a number of languages with it.
As for binary dependencies, I'm certain Rust will have that in the future. I'm fine without it for now, and what I'm not certain of is whether C++ will ever actually fix their problems because they seem to think they don't have any!
So not an IDE, see.
Are there C libraries you want to remain (nearly) source-compatible with while using classes, templates, and other more modern programming features?
If you are working in an embedded environment Rust is still very capable, but the tooling for Rust does not seem at the level of the embedded tooling for C and C++.
You can still use Rust for embedded, and there are success stories to be found in the links below.
[1] https://www.rust-lang.org/what/embedded [2] https://rust-embedded.github.io/book/ [3] https://github.com/rust-embedded/awesome-embedded-rust [4] https://github.com/rust-embedded/cortex-m-quickstart
If you find Visual Studio and CLion to be your desired work environments, both of them have support for Rust code via extensions. No it won't be as perfect as what you're used to, but it will be more than sufficient for most people.
I've also used QtCreator, and hated it because for me it was a resource hog, you had to do things its way, and the Qt APIs were horribly designed.
But these are huge reasons. It is the difference between theory and practice. In theory you can just replace C++ with Rust. In practice, it can be difficult because of those reasons.
Choosing a language isn't just about the language, but about the entire ecosystem and community.
Rust requires references to memory to be visible at compile time. If you use direct DMA for I/O then the silicon holds mutable memory references at runtime that are not visible in code at compile time. In C++ you can make ownership objects (in the vein of unique_ptr) that automagically track the lifetime of DMA references. Exposing most of your address space to DMA is not optional in databases if you care about performance. DMA has other nuances as well e.g. it can modify memory that is not part of the object you care about and which might be "owned" by someone else.
There are safety models wherein it is provably safe, and optimal code-wise, for multiple mutable references to the same object to coexist at runtime. Modern databases often use schedule-based safety, which dynamically reorders operations on references at a fine-grained level, for performance reasons, and which guarantee correctness of the aggregate execution graph without using locks. This wasn't common a decade ago but it is today. A developer can grab all the mutable references they need to objects, knowing that the execution scheduler can see through and arbitrate any potential conflicts. (This is a sophisticated reimagining of the old "deadlock-free" locking structures in databases without the locks, which didn't prevent deadlocks per se but transparently detect and resolve them.)
You can make all of this work in Rust by using a lot of "unsafe" and inelegant data structure workarounds but it voids most of the safety benefits of Rust and requires more complex code.
> In C++ you can make ownership objects (in the vein of unique_ptr) that automagically track the lifetime of DMA references.
does that require os support to make it work? i assume the tracking is handled by some specific inturrupts?
> You can make all of this work in Rust by using a lot of "unsafe" and inelegant data structure workarounds but it voids most of the safety benefits of Rust and requires more complex code.
i see... so i guess rust would have to take one small step out of static, and into dynamic territory with a smart pointer "trait"?
There is a lot of implementation detail, but you need object references that are aware when a DMA operation is outstanding on address space they “own”, the type of DMA operation, and rules about when new DMA operations can be scheduled with respect to object reference lifecycles. There are no fixed set of rules but there are a common set of design patterns. The scheduler design does a lot of the heavy lifting.
[1] https://blog.japaric.io/safe-dma/#:~:text=DMA%20stands%20for...
The question is the opposite: you have to prove to managers the benefit overcomes the risk of using a new language. Rust is still not nearly stable nor popular enough for many fields.
Go is a very different language with different goals and constraints, so the question does not really fit.
> Rust and Go are much simpler to learn
Go is a simple language, yes. Rust is a different beast with the same intrinsic complexity as C++.
> can do everything that C++
Not exactly true (for the moment). Rust is lacking on const generics, HKTs and other details.
> sane, simple and clean build systems/package managers
That is not a big argument for the kind of projects is used for.
And it is not true either, since nowadays there are several competing, modern package managers for C++ too (build2, Meson, Conan, modern CMake...).
> not to mention async/await concurrency
The async IO model has been available in many languages for many years, including C++. In the recent years several languages (including Rust and C++) are bringing syntax sugar to let the compiler create the state machines. But it is not the only way of doing async.
https://news.ycombinator.com/item?id=24032305
Tl;dr: C++ is now and will remain the near-exclusive choice for essentially all of the highest-paid, most demanding work in medtech, fintech, CAE, HPC, telecom, and aerospace, for decades to come. Rust code will never be able to call into the very powerful libraries these applications depend on, because they are based on language features Rust will never have. No language other than C++ and Rust targets these applications.
Very noisy Rust advocates here are inaudible elsewhere; many more people start using C++ in every week than the total who touch Rust in that week. That will not change soon.
Rust is a much better language than C, Go, Java, C#, Visual Basic, Delphi, COBOL, Nim, and Dart, and much faster than Python, Ruby, and Perl. Advocates would better focus recruiting there than tilting at C++.
I'm not sure what you're saying. Rust 1.0 code compiles just fine in the most recent rust compiler. It's been stable since that 1.0 point and promises to continue being stable. C++ doesn't have a a stable ABI either.
Even if exist, is better to let it die. C/C++ is a costly mistake. VERY costly.
Apart of interact with legacy code, both C/C++ have much better replacements (like pascal).
Is only the stubborn "but what if I need to replace my heavily bug-ridding, unsafe, crash-prone, hard-to-mantain, harder-to-prove is good; source code, and need to retrain my developers that spend a lot of mental energy in workaround them in something, better?????"
Our industry is weird.
In any other, if the "engineers" insist in use a well-know unsafe tooling and refuse to learn safer tooling/practiques you will fire them as incompetents.
By the way, I learn mechanical engineering (at trade level).
Not sure what you are basing this on but it's probably not an exaggeration to say that C/C++ has generated hundreds of billions of dollars in revenue over decades, not mentioning employment, advancement in programming language theory, learning lessons, etc...
I am really not a fan of C++ overall but its achievements cannot be understated. Saying it's a "VERY costly mistake" is baffling.
And PHP, Cobol, Perl, etc. Just because a tool is useful is not a reason to avoid point their problems.
And C/C++ have very well know problems, since decades ago.
> Saying it's a "VERY costly mistake" is baffling.
Maybe if MS say it?
https://www.zdnet.com/article/microsoft-70-percent-of-all-se...
https://www.zdnet.com/article/microsoft-heres-why-we-love-pr...
Just to point a recent one...
That said, I do think that for a certain category of greenfield projects that can avoid needing certain types of dependencies on and interactions with other existing software or codebases, Rust and Go will completely dominate C++ going forward. For new work that doesn't need the C++ ecosystem and doesn't rely on dependencies not available for Go/Rust, it really is hard to imagine how one of Go/Rust would not be a significantly better choice in 2020 and beyond.
Some companies will be entirely based on such greenfield projects. Others will be entirely based on problems that rely on some of that existing C++ ecosystem. Yet others will be mixed and may be able to use C++, Go, and Rust as it makes sense. So I think it's going to be a complicated situation where some folks will be able to completely move ahead of C++ and others will be tied to it for a long time yet.
One of the larges codebases I know about, Chromium, seems to use only a minimum of C++ features. It's mostly limited to 1980s "C with objects" paradigm, plus smart pointers.
The point of a language is not to use all the bells and whistles just for the sake of playing language feature bingo. The point of a language is to offer developers the tools they need to use to achieve their goals. Some C++ standards offer stuff that are must-haves, nice-to-haves, and meh. Just because you want to use std::make_unique that doesn't mean you should rewrite your code to get all your lambdas to do return type deduction.
That's precisely the answer, because the question, as you framed it, is absurd.
The point of using a language is to benefit from the features it provides. It makes absolutely no sense to argue that a language is not used "to its fullest" if you don't play feature bingo in your projects. That's silly. I'm using C++14 to its fullest if I use std::make_unique even if I use no template metaprogramming or lambdas or even throw exceptions. It makes no sense to argue otherwise.
As an counter-example, it's possible to write conformant C++ without using any features that aren't also in C: I am, objectively, not using C++ to the fullest if I'm restricting myself to functions instead of methods, char pointers instead of std::string, statically allocated arrays or pointers instead of vectors, and so on, thereby ignoring 90% of the spec.
If I'm not using constexpr, for example, then I'm using one of less feature provided by the language. Constexpr, like all other modern C++ features not present in "old" C++, was invented to serve a purpose, and without it, you have to reach for more blunt, possibly more verbose and less expressive tools. In other words, many new features (such as ranges) increase expressiveness in a quantifiable manner. I may not need, for the specific program that I'm writing, the full range of features, and may not need constexpr. But that wasn't the question.
Again, I'm not asking about egregious use of features of features' sake. I'm asking about examples of projects that use in a positive and not superfluous terms modern features of C++.
It's not an absurd question, and your response is just obtuse (and unhelpful!).
Same thing applies to SYCL, CUDA and Metal Shaders (MSL uses C++14 though).
Absolutely agree and wish more people did.
While likely accurate, this thinking is likely not conducive to UX innovation.
Sorry if my assumption is incorrect.
I think Bjarne isn't getting the issue with C++. Yes they're Turing-complete, yes they can both solve the same set of problems.
The issue is that C++ can do everything that every other language can do, which means it's not a language, it's a universe of features. You make the language by picking which features, patterns, philosophies, architectures you want. It's like if a language dictionary included English, simplified Chinese and Korean.
The problem IMO is there's no such thing as C++. Each company, each team, each person has their own. Many of these C++'s are incompatible with each other.
Worse, many of the new language features can't be properly implemented because they would break someone else's C++.
The problem is it tries to be everything to everyone, and that makes it (and futures standardization efforts) full-on Quixotic efforts. I mean, by all means, have at those windmills tho.
Bjarne points out how much he hates templates, and has some great new ideas for generic programming. Lovely, but he's never gonna get rid of templates, so now we have 2 problems.
There's another "truth" of PLs: Curry-Howard. So a language with a richer type system can express more propositions than a lesser one. Just because two languages are Turing equivalent doesn't mean they are Curry-Howard-equivalent.
So the things some languages can do that others can't happen at compile time.
And tbh, you'd probably be better served by a language that isn't Turing complete but allows you to express rich types than a Turing complete language with a bad type system. Very little of people's code needs Turing completeness.
The Wikipedia page on Total Functional Programming [1] has a nice (even if contrived) example of this with Quicksort. I feel like my undergrad complexity class did me a disservice by emphasizing Turing Completeness so much without discussing any other aspects of abstract computation, like lambda calculus, type systems, etc..
[1]: https://en.wikipedia.org/wiki/Total_functional_programming
This is a very myopic view, and misses the point entirely. The entire notion of a "Turing machine" is that any Turing-complete machine can compute any result that another Turing-complete machine can compute. No mention is made of how the results are computed or how the programmer approaches the problem on each machine.
Any Turing Complete language can be used to do the same work as any other Turing complete language or mechanism.
The expressiveness of any particular language does not factor into the equation at all, and does not matter at all when speaking of what is computable and what is not.
You are talking about language features, which is an entirely different topic. All Turing-complete languages are equivalent in terms of their abilities; that is to say that they can all compute the entire set of computable results.
But yes, you are completely right: teams developing ultra complex languages (e.g. C++, Scala, Ada) usually fail to understand that the fact their language can do everything all the other languages can do is exactly the problem.
The value of these other languages is precisely choosing not to have certain features.
> Worse, many of the new language features can't be properly implemented because they would break someone else's C++.
Could you give an example?
> I think Bjarne isn't getting the issue with C++.
In my opinion, put succinctly, the issue with C++ is that it can do things that Rust can't. And, as it turns out, most of the things that it can do over Rust aren't important for solving problems (one of those things is explicit memory management).
> Rust people [...] accuse [...] stolen
There is something that many developers struggle with, and it seems to be cropping up here. You are not your work, folks. Go back and honestly look at your very old code, it's probably not good, it's probably not good at all. There's no reason to be ashamed of that, because your work is not your identity.
If your work becomes your identity, you lose the ability to critique your own work objectively (biologically/psychologically), which really impedes your ability to improve your work.
Because that was his point, the whole argument about developers identifying with their work seems to sidetrack the original discussion.
> the whole argument about developers identifying
Taking inspiration from C++ is inseparable from developing a language today. Arguing about who "stole" ideas is sidetracking the overall discussion, in the first place. The development of C++ is being hampered by the perception of a threat/enemy who "steals" ideas - which is a very human and normal way to act. If the discussion is "them/Rust" vs. "us/C++", then the reasoning behind that counterproductive mindset is worth talking about.
None of statement are true...
C++ cannot do everything. C++ can do most every other "system programming languages" do, but that's by design that they are all system programming languages.
Even if C++ can do everything as other languages, that does not make it beyond a language. C++'s system is coherent. It is complicated, but no where it contradicts itself in any major fashion.
That generally does not happen with other languages.
I don't think he's saying he hates templates in general:
> “I’m not a great fan of template meta-programming"
He's not a great fan of template meta-programming which is a specific use (or abuse depending on your point of view) of templates. Though it is a fairly popular use of templates now.
If I interpret this sentence with English understatement, then indeed, he hates templates.
(I interpreted his British-rooted understatement in the same way as the parent comment.)
And yet, I understand where the baggage comes from. My favorite language when I was young, Python, went through a decade of stagnation because programmers couldn't be hassled to write print('hello') instead of print 'hello'. It's frustrating, but almost all languages gather baggage over time.
> “But besides adding object orientation to C, he also remembered his earliest design goals for C++. “I wanted very great freedom of expression, very great generality. [...]”
I can only speak from my own experience here, so it's anecdotal, but the main reason I love using C++ is precisely this "great freedom of expression", which is most likely, but at least in part, a direct consequence of the fact that it "tries to be everything to everyone". When writing C++, my mind often wanders and comes up with code and designs that would either be actively discouraged in the majority of other (opinionated) programming languages, or straight up impossible to implement. It's a great and highly valuable (possibly creative) experience that I haven't, to this extent, experienced in any of the other (numerous) languages I've been using. I also feel it makes me a better software engineer as a whole, even when I'm not working with C++ (which is actually most of the time). Beyond that, I also feel it's one of the reasons why C++ is so successful.
Obviously it also leads to the fragmentation you described, and it's perfectly valid to criticize, but I wish people would, more often, at least acknowledge that this kind of programming language is still valuable in certain ways and situations.
Yes, if you are mainly focused on getting a job done with minimum friction (and maybe maximum speed), there is a high chance that there is a language better suited for the task than C++ in today's age. That does not make C++ obsolete, quite the opposite in my opinion. I believe the fact that C++ isn't as opinionated or streamlined as other languages shouldn't be considered an "issue" or a "problem", but a feature.
Generic wise phrase: Perfection is not reached by adding more and more things, but by taking things away, until only the true core ideas remain, on top of which one builds the rest.
This is something C++ is very far away from attaining. What one wants for maintainabIlity, simplicity and understandability is the core concepts, not 120 keywords and different meanings of keywords depending on where they appear.
I agree.
I'm not sure why C++ needs to attain perfection of this specific kind - or any kind, for that matter. You could also argue that the great freedom and flexiblity were preconditions for (or at least greatly aided in) the creation of languages like Rust. Through them, people learned what to be aware of; and were thus capable of "distilling" this knowledge into such languages.
My point is: there is nothing inherently wrong with a language choosing to be liberal/maximum generality, allowing for a playground on which new ideas and learnings can happen. I consider C++ to be of that kind, it has served this purpose for a long time in my opinion.
Don't get me wrong though, I'm perfectly aware of all the issues that come with it, and I'd not advocate C++ as the language of choice for the majority of software nowadays. I reject the idea though that C++ should now be considered obsolete, redundant, or anything that goes into that direction just because some people now believe to have found some kind of (final) "perfection" in new languages.
Features can’t really be removed from C++ because a major advantage of the language is compatibility with existing code. However, within that constraint, C++ is driving toward a simpler, cleaner, safer dialect. It’s a hard problem.
The first thing that comes to mind is things like gRPC or the actor model but I can’t imagine he has either of those in mind.
That was the only connection it had to something "distributed". In a literal meaning of the word, not distributed systems.
The problems distributed systems actually face were never addressed by C++ in any way. Something like meta facilities for implementing actor runtimes and using an actor model could be the first step, but who knows what Stroustrup was talking about, maybe it's all just marketing buzzwords useless for distributed systems, like in most languages that claim distributed systems support.
You're going to need to break c++ then. It is so much harder to use than Rust today, I have no idea why anyone would choose c++. The libraries argument is mute because its such a pain to use external libraries.