Live data from Hacker News

Writing New System Software

borud.no

111–120 of 158 posts

Re: Writing New System Software

#111

Is it me or is this essay really an incoherent mess? As much as I would like to agree with the author's stern verdict (and I am saying this as a systems programmer with more than 20 years experience) I cannot make out the central argument.

It reads like the notes for an article. It says everything the author is thinking but doesn’t give the context necessary to understand their thinking.

Anywhere somebody says "C/C++" in the context of system programming, you can stop reading right there without missing out on anything.

tl;dr: C and C++ have cooties, use literally anything else.

Nothing to see here.

Re: Writing New System Software

#112

Earlier quoted context omitted.

The central argument is that C/C++ is not worth the trouble for new code and that using it "correctly" is a theoretical thing that even experts struggle with. C/C++ programmers keep on insisting that they've found ways to do it right, finally. Some C/C++ programmers seem to believe that, unlike everybody else, they actually have the combination of wisdom, skills, and discipline to not fall into this trap. At this poi…

> unlike everybody else, they actually have the combination of wisdom, skills, and discipline to not fall into this trap I'm constantly reminded of the NPC in Half Life 1 who says something like "Take me with you, I'm the one man who knows everything!" I know many programmers who think their one way of writing C++ will not cause any issues. None of them are 100% correct as I can always find a bug that a higher level…

And, you only know programmers who know no more than you.

Re: Writing New System Software

#113

Earlier quoted context omitted.

I think it depends a lot on experience and wether the code base is post C++ 11. Modern codebases like clang or chrome do not seem to have any more memory management issues than something like Intellij. Personally I wrote system software in C++ for 10 years and memory management was a problem maybe once or twice.

> chrome See https://www.cvedetails.com/vulnerability-list/vendor_id-1224... for a list of RCE vulnerabilities. I see a bunch of memory management problems there. Also note that chrome is likely much better tested than some other C++ project, and lots of tools are used to search for potential vulnerabilities or invalid memory use as well as fuzzing and crash reports from a large install base. I don’t know how this co…

Chrome is not coded in anything even slightly resembling modern C++. So, no conclusions about modern C++ can be drawn from it.

Except, maybe, that it takes a long time to modernize old code.

Re: Writing New System Software

#116

Earlier quoted context omitted.

Smart pointers has some overhead though, even unique_ptr. I like to use raii to handle normal pointers. For many programs memory leaks can just be handled by exit, too.

unique_ptr has zero overhead

unique_ptr has zero overhead except when passing or returning by move. But I don't find myself doing that anywhere performance matters.

The overhead is not inherent, but is rather a consequence of C ABI choices inherited into C++ calling conventions. It is, though, real, and not easily fixed. E.g., RISC-V's ABI binding peobably suffers from the same overhead, not for any good reason, but just because the RISC-V crowd couldn't spare the attention to fix it.

Re: Writing New System Software

#117
post #44

Earlier quoted context omitted.

unique_ptr has zero overhead

Not when stepping through code in gdb/lldb in my experience in debug builds: they very often end up stepping in to the -> operator implementation for functions, which then requires me to step in again to get to the actual function call I wanted.

Measuring overhead of debug builds is a rookie mistake.

Re: Writing New System Software

#118
post #109

Earlier quoted context omitted.

> Contrary to some other languages it gives the developer maximal freedom and does not impose a particular way of doing things on the developer You seem to be implying that's a good thing. It's literally not. Imagine if I created a programming language where every random string of characters was a valid program (cue the Perl jokes). Clearly this language permits even more freedom than C++, but this would be a nightma…

>"You seem to be implying that's a good thing. It's literally not." I think it is.

No post body was provided.

Re: Writing New System Software

#119
post #67
post #36

Earlier quoted context omitted.

> (...) such as Google's famous "no exceptions". If I recall correctly, Google's rationale regarding exceptions is that their legacy code is not exception-safe, and so they were faced with the choice of either rewriting critical parts of their legacy code to handle exceptions, or don't use them. Also, their "no exceptions" rule only applied to work involving their legacy code. I'm too lazy to find the source, but tha…

I guess we can consider AOSP legacy code then, given how they use C++.

Yes. Legacy in every sense, including "abandonware".

Re: Writing New System Software

#120

> You may like STL, but that doesn’t change the fact that a huge number of companies have policies against using it. Sources? I haven't heard of any company disallowing it, on the contrary, have heard of companies promoting its use. edit: fixed formatting

A lot of game companies don't use STL. I assume theremust be plenty of system software companies doing the same.

Certain game companies decades ago had a house STL.
Post reply on HN