California Issues a Health Warning for C++ Code
Description
A screenshot of a tweet from Bryce Adelstein Lelbach (@blelbach) describes his experience as a C++ developer on a C-centric driver team at NVIDIA HQ. The tweet includes a photo of a sign his team put up, which is taped to a whiteboard or partition. The sign parodies the California Proposition 65 warning label, stating: 'This code contains C++ constructs that are known to the state of California to cause cancer and birth defects or other reproductive harm.' Taped to the bottom of this sign is a small image from 'The Simpsons,' showing a room full of monkeys at typewriters, with the caption, 'And here is the debugging room.' The humor operates on multiple levels for experienced engineers: it plays on the long-standing 'language war' between C purists, who often view C++ as overly complex and dangerous, and C++ advocates. The Prop 65 format cleverly frames this technical debate in the absurd language of public health warnings. The Simpsons sticker adds a final punchline, mocking the debugging process for complex code as chaotic and random
Comments
37Comment deleted
A C developer looks at a C++ codebase and asks, 'Do you need a license for all this?' The C++ dev replies, 'No, but we have three different package managers and a 45-minute compile time to keep out the faint of heart.'
They can slap a Prop-65 label on my C++ templates, but the real occupational hazard is second-hand undefined behavior drifting over from the C files - Valgrind refuses to even put on the hard hat
The real cancer isn't C++ constructs - it's discovering your perfectly valid C++14 template metaprogramming breaks in C++17, then realizing the driver team's plain C code from 2003 still compiles unchanged while you're on your third refactor this quarter
When your C colleagues welcome you to the team by treating C++ like a hazardous material requiring regulatory warnings, you know you've found your people. The real cancer is trying to explain why `std::enable_if_t<std::is_same_v<T, U>>` is actually 'readable' to someone who's been writing kernel drivers in pure C for 20 years. At least the debugging room has capacity for the inevitable template instantiation error discussions
C++ finally gets Prop 65: because nothing causes 'reproductive harm' like iterator invalidation mid-loop
Kernel Prop 65: prolonged exposure to templates, exceptions, and RTTI increases risk of undefined behavior - compile with -fno-exceptions, -fno-rtti, and consider Rust as PPE
The C driver team slapped a Prop 65 on my C++ - fair enough: in kernel land, exceptions are contraband, RTTI is a controlled substance, and every template instantiation warms the datacenter
Sorry, what is HQ? Comment deleted
headquarters Comment deleted
As if pure C is any better Comment deleted
Much better Comment deleted
pure c is godly Comment deleted
C is not great. C++ doesn't remove any of the issues of C and adds two languages worth more. It doesn't matter. In it's class there is rarely option of choice. In cases where you reach for these you usually are integrating something closely with the OS and/or hardware. All unices have their official interface defined as C library (libc). With notable exception of Linux they rarely document their ABI so language designers would have to reverse-engineer them if they wanted to call syscalls without going through C FFI. Windows is C++ through and through. Bare metal has more options, you may get away with using Ada or Rust if you have some common ARM μC, otherwise good luck getting compiler support for your target. Like with Browser API being locked behind JavaScript even if you run WASM, if you need to deal with C or C++ libraries and calling conventions you can't really escape lot of the misdesigns and might as well bite the bullet. Or use some safety wrapper like Drunk Octopus, ATS2 or Low*/kreMLin that generates low level C after some verification of code correctness. Comment deleted
👍 Comment deleted
Lol, ofc no Here, make next API of your great startup with C++! https://www.webtoolkit.eu/wt Comment deleted
There actually enough reasons to use C++ for backend, but development time... Uh, this will not be quick, that's for sure Comment deleted
C++/Qt Comment deleted
you forgot debug time Comment deleted
I merged them under dev time name Comment deleted
Honestly Qt might be considered an OS for the purpose of this discussion. With it's extra preprocessors and whatnot it's been rather painful to generate correct bindings from what I understood. Comment deleted
so, how do you call libc without using c? Comment deleted
asm Comment deleted
nono, " All unices have their official interface defined as C library (libc)." how do you call libc without using c Comment deleted
or c ffi Comment deleted
libc w/o c is just lib Comment deleted
Via FFI (foreign function interface) which forces you to deal with c library loading and calling conventions. You also need to support data types involved, such as C-style strings, particular layout of structs including alignment… There's a lot. Comment deleted
soo, you do that on all unices Comment deleted
except linux Comment deleted
doesn't linux have libc too? Comment deleted
Linux is the only one where you might be able to write replacement for libc for your language because it's actually documented how. Few bother because it's a huge task. I think Go might have had few raw syscall interfaces, but will often also require libc. (Haven't checked in a while, that's been surely area of work) Comment deleted
well, i see what you mean here now, i did not understand you correctly there Comment deleted
also, you may leave out the enumeration of c specific things, i know them too Comment deleted
Enums are source-only construct that translate to integers. But unions and basically all memory layout stuff is a concern. Comment deleted
whatt?? i wasn't meaning that at all, what i meant is that i know about all the c and hardware specific things, so you may not bother telling me about them all over again Comment deleted
and how does libc help in not using c? Comment deleted
and how come linux isn't documenting its syscalls Comment deleted
cringe Comment deleted