Hacker News new | ask | show | jobs
by cng100 1840 days ago
The average C++ code base has as many segfaults than the average C code base.

Windows has more exploits than Linux. But you know all that, so I wonder why you keep making these statements, which are then upvoted by the "memory-safe" crowd.

3 comments

I’m glad this doesn’t go unnoticed, and share the observation. There seem to be quite some effort going into creating illusions of truth about C. Just a personal observation.
If you want to play that game, https://www.cvedetails.com/product/32238/Microsoft-Windows-1... shows Windows, indeed, having more CVEs, in spite of, AFAIK, not using C (substantially, at least). Of course, the real problem is that CVE counts may or may not mean anything when comparing systems with wildly different development models (FOSS/proprietary) used mostly in different areas (desktop / everything else).
> The average C++ code base has as many segfaults than the average C code base.

any source for that ? I find segfaults utterly rare in C++ >= 11

You were using C++ >= 11 in 90s/00s?
I can't speak for the parent, but I've been using RAII and smart pointers in the 00s and it provided a lot of the benefits that got standardised with C++11.
None of that was a thing in 90s and early 00s.
RAII and smart pointers definitely were a thing in the 90s. I wrote lots of COM code using these techniques. According to wikipedia, RAII was invented in 1984-89.
The average C++ codebase isn't from the 90s. On all the recent c++ polls the average language revision used is between c++14 and 17.

Besides I'm pretty confident that there are more new c++ projects created daily in 2021 than monthly at the peak of the 90s c++ craze - just on GitHub, 6/7% of C++ repos means a few million recent C++ repos.

I've worked on several code bases that nominally are C++11 or 14. However they still contain a lot of code written by people still coding like it's the 90s.
What does it have to do with what we are discussing?
> On all the recent c++ polls the average language revision used is between c++14 and 17.

Polls of hobbyist coders, or software houses? I would be surprised if most software houses migrated to C++17 yet. Tensorflow is stuck on C++03 I think.

Sure it was, Borland and Microsoft compilers already had smart pointers for COM libraries.

Besides even on MS-DOS with frameworks like Turbo Vision, RAII was a common pattern.

auto_ptr (precursor to unique_ptr) was first proposed for standardisation in 1994 [0], and there was probably non standard versions of it before 94.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1994/N055...

You ever used auto_ptr?

In 1992, I was working on the Taligent project, probably the first major C++ operating system. (It failed.) I remember when the ARM came out---none of the compilers we had available could really do templates. Or namespaces.

ok then, nobody was using auto_ptr in the 90s.