Live data from Hacker News

C++ creator rebuts White House warning

infoworld.com

61–70 of 141 posts

Re: C++ creator rebuts White House warning

#61
post #5

> Improving safety has been an aim of C++ from day one and throughout its evolution. Just compare the K&R C language with the earliest C++, and the early C++ with contemporary C++. My CppCon 2023 keynote outlines that evolution, C++ safety may have improved a lot, but it’s still far, far behind most other languages we use. It’s not even a close comparison. You throw a bunch of programmers at a problem and you will ge…

I admit I mostly don’t understand the “modern C++ is safe” argument. I maintain a decent size C++ code base, I try to use modern features in good taste, and I do think that C++ has added a lot of nice things. But nice != safe.

basic_string_view is new in C++17. It sure beats pointers, but it’s a far cry from the kind of safety that you get in essentially any other language (except C): it is a reference with unknown lifetime, and the toolchain does not help track that lifetime.

I think that Stroustrup would say that the C++ Core Guidelines fix this, and I think he’s referring to this:

https://github.com/isocpp/CppCoreGuidelines/blob/master/docs...

which seems like it’s maybe partly implemented in some version of Visual Studio and was maybe prototyped in clang. But it does not seem to be a well-specified language or a fully-implemented language, and I can’t use it now.

So, as far as I’m concerned, I can use Rust or Python or Perl or Go or Swift or bash or Java or JavaScript or Haskell or Lisp or Scheme or O’Caml or Tcl and I can manipulate strings without worrying about undefined behavior. Or I can use C++ and worry. Or I can dream about using “Modern C++?”

Re: C++ creator rebuts White House warning

#62
post #9

Stroustrup as always fails to recognize the vast surface area of C++ features, foot cannons, and the heavy weight of C compatibility around C++ neck. C++ barely made sense in 1995. It makes absolutely no sense today.

I think the funny thing is you no longer even get peak performance from C++. In many ways Java is running rings around C++ performance. Partly, it's because you get state-of-the-art peak optimizations for free from Java, and you'll need a team of 20 full-time build engineers to get a peak C++ artifact with PGO, LTO, and post-link optimizations. Partly it's because the speed of C++ is illusory, with the superficial su…

> you'll need a team of 20 full-time build engineers to get a peak C++ artifact with PGO, LTO, and post-link optimizations.

As someone working in a team of 3 with a c++ code base this statement is hilarious hyperbole.

Re: C++ creator rebuts White House warning

#63
post #28

Even such basics as initialization is full of traps in C++, its truly language thats awful to produce anything safe with. C on the other hand isnt a bad language, but C's problem comes from the horrible standard library and bad standard. You can create much better C by passing -fno-strict-aliasing -ftrapv -fsigned-char to the compiler even now. Heck rust's unsafe is more unsafe than C. "C" could be improved with a be…

IMO the problem with C isn’t just the horrible standard library. It’s that you can’t make a better standard library — the language constructs needed to abstract almost anything don’t really exist.

Re: C++ creator rebuts White House warning

#64
post #8

Yeah. The language you pick doesn't magically make you Fort Knox regardless of "memory safety". Rewind in time and the White House would be berating all of us to write in Java... you know... a "memory safe" language, only for the worst security fail to come along Log4Shell.

That was a library bug, not a language bug. Allowing external logging configuration by default is not like having a buffer overflow issue.

Re: C++ creator rebuts White House warning

#65
post #61
post #5

> Improving safety has been an aim of C++ from day one and throughout its evolution. Just compare the K&R C language with the earliest C++, and the early C++ with contemporary C++. My CppCon 2023 keynote outlines that evolution, C++ safety may have improved a lot, but it’s still far, far behind most other languages we use. It’s not even a close comparison. You throw a bunch of programmers at a problem and you will ge…

I admit I mostly don’t understand the “modern C++ is safe” argument. I maintain a decent size C++ code base, I try to use modern features in good taste, and I do think that C++ has added a lot of nice things. But nice != safe. basic_string_view is new in C++17. It sure beats pointers, but it’s a far cry from the kind of safety that you get in essentially any other language (except C): it is a reference with unknown l…

C++ is safe if you ignore most of its libraries and write everything from scratch, making safety your #1 priority, ahead of performance and everything else, and then doggedly stick to using nothing but the safe primitives you have created.

Re: C++ creator rebuts White House warning

#66

> Of the billions of lines of C++, few completely follow modern guidelines, and peoples’ notions of which aspects of safety are important differ. I and the C++ standard committee are trying to deal with that If only people were perfect, then things would be perfect. There’s, what, 40 years of evidence to suggest that most people, most of the time, simply cannot write memory-safe C++ code (50 years if you count C.) Ma…

Have we tried genetically engineering perfect C++ programmers? I feel like that might be possible in another 50 years.

Re: C++ creator rebuts White House warning

#67
post #22

He seems to be in denial. I watched Stroustrup's CppCon 2023 talk about safety[0] a few months back. He spends about an hour talking about how important safety is and all the new things C++ offers to write safe code. Why did he suddenly start caring about safety now ? C++ is like a mad hatter's bad acid trip and somehow people are convinced it's still a great language to use in 2024. [0]: https://www.youtube.com/watc…

I’m going off old memory here, but I happened to have his C++ book in late 90s. I read that before I learn C. In intro he claimed strongly no need to learn C. Just learn C++. I was young and just followed his wisdom. Obviously there’s zero replacement for learning C before C++. I can at best say I lost a lot of time confused about basic stuff. Until I gave up, ignored him and learnt C like I should have. I was in school, I did not expect to come across faith based software development. That’s a different course.

Re: C++ creator rebuts White House warning

#68
post #9

Earlier quoted context omitted.

I think the funny thing is you no longer even get peak performance from C++. In many ways Java is running rings around C++ performance. Partly, it's because you get state-of-the-art peak optimizations for free from Java, and you'll need a team of 20 full-time build engineers to get a peak C++ artifact with PGO, LTO, and post-link optimizations. Partly it's because the speed of C++ is illusory, with the superficial su…

I acknowledge C++'s safety concerns, but no, Java is definitely NOT running rings around C++ perf. Not a single AI/ML model is implemented in Java. The core of AI/ML runs on C++ only. You may see a lot of Python, but the core engine that Python is wrapping is written in C++. Sorry to break it to you but Java cannot even come close here.

"Multiply an insane amount of stuff" is not an interesting point in complexity-safety-performance space.

Re: C++ creator rebuts White House warning

#69
post #9

Earlier quoted context omitted.

I think the funny thing is you no longer even get peak performance from C++. In many ways Java is running rings around C++ performance. Partly, it's because you get state-of-the-art peak optimizations for free from Java, and you'll need a team of 20 full-time build engineers to get a peak C++ artifact with PGO, LTO, and post-link optimizations. Partly it's because the speed of C++ is illusory, with the superficial su…

> you'll need a team of 20 full-time build engineers to get a peak C++ artifact with PGO, LTO, and post-link optimizations. As someone working in a team of 3 with a c++ code base this statement is hilarious hyperbole.

How do you explain the almost complete absence of peak-optimized software in the real world? Percona, an entire company dedicated to supporting one stupid program, does not offer a PGO MySQL, much less a BOLTed one. "Try to enable PGO" is still an open issue for Envoy, an 8-year-old project with multiple gigantic companies contributing.

Re: C++ creator rebuts White House warning

#70

The amount of iconoclastic knee jerking in this thread is kinda nuts. Equating this rebuttal to an old man yelling at clouds? Saying Cpp never made sense? The first step to solving a problem is accepting reality. Cpp has been foundational, like C, to our computing world. If the rich legacy of libraries that underpin our "better" language choices is offensive to us, or if we really believe we are powerless to improve…

> The first step to solving a problem is accepting reality. Ok, the first thing I’d like to accept is that C++ is just not safe enough for most applications. And yes—you also can’t throw C++ in the garbage. Both of those statement are part of our reality—C++ is unsafe, and we will use it anyway. That’s why we solve this problem on two fronts. First, we advise programmers to ditch C++ for safer languages, when reasona…

I've yet to see a valid scenario where C++ is superior to Rust, Python and Go.

Use Python. If you need concurrency, then use Go. If you need even more performance, use Rust (using unsafe Rust only for the parts that need it). For the highest performance stuff, maybe consider C for critical parts only.

C++ is not safe. It's a minefield of things that compile but are memory management mistakes. And then you're like "Look, I have a map of the minefield. If we just make sure we don't step on any mines, we are completely fine."

Post reply on HN