4 ms·
Yea, cause everyone who is already writing C++ is really good at it and good at not writing bugs.
by bmitc 2y ago
Yea, cause everyone who is already writing C++ is really good at it and good at not writing bugs.
- linotype 2y agoEven great C++ developers write shitty C++ code. It’s truly a “let’s take all the warning labels off” language.
- shrimp_emoji 2y agoNothing compared to C.
- Jensson 2y agoC++ has all the footguns of C, but add in tons of implicit function calls that creates bugs for half of the things you'd think they can be used for, and because you don't see that implicit code it is really hard to debug why an implicit call was made or not made when you thought it would or wouldn't. So no, C isn't even close to the danger of C++, in C every copy, every destructor, every alloc, is explicitly declared everywhere. Explicit is much safer than implicit, unless the implicit behavior is rock solid like in garbage collected languages, or very strict languages like Rust.
- protomolecule 2y ago>in C every copy, every destructor, every alloc, is explicitly declared everywhere. Explicit is much safer than implicit Unless a programmer forgets to call a 'destructor' on some code path in C's explicit error handling maze.
- d110af5ccf 2y agoAgreed. Explicit is only better than implicit when you have a mechanism that can reliably identify instances where you forgot to do something. Actually for resource management I'd go so far as to say that implicit is better than explicit in the vast majority of cases. Now if only the rules that determine what happens during initialization in C++ weren't so horribly convoluted.
- advael 2y agoNah. Many people who have been writing C++ poorly for decades never learn to do it better. This is less about "even people who are great are bad" and more about "no amount of experience guarantees that you get great". There are plenty of ways to write the language that aren't as error-prone, and most development of new features in the language since at least 2011 have been creating new ways to do that more. The "problem" is that they value backwards-compatibility, and most pedagogy for the language both in academia and industry is at best outdated and often just teaching bad ideas outright, often both, so while there are whole enormous and robust codebases out there that don't use them at all, the idioms that contain footguns still exist in the language and are valid code and some old dude who's been doing this for 30 years will still sit in a meeting and tell me that he's been writing pointer arithmetic in deep nested loops for 20 years and it should work fine after insisting on being in part of a review process that is for the most part not adding any new information halfway through a rewrite process to fix some show-stopper bugs in a legacy codebase, which ended up making said process about 10x more annoying and take at least twice as long
- Jensson 2y ago> some old dude who's been doing this for 30 years will still sit in a meeting and tell me that he's been writing pointer arithmetic in deep nested loops for 20 years and it should work fine Pointer arithmetics in nested loops is just regular C code though, that is perfectly fine. The problem comes when you start to mix C++ datatypes and templates with pointer arithmetics, that is when the footguns becomes completely unmanageable. However if your team doesn't have other people with experience writing such code then it is best to avoid it anyway, if you decided to not write C style code in C++ then he should respect that. But he is right that it is perfectly fine thing to do, writing C in C++ is basically just C with namespaces and scoping.
- advael 2y agoSure, it's doable, but it was in this case the source of the issue, along with some obfuscation of where and when those particular sections of code were being executed through shenanigans with encapsulation and inheritance (I respect people who can manage their pointers well, but I genuinely dislike a lot of OO practices even aside from if they're done "well"). People write exceptional code in C despite and sometimes because of it not protecting you from writing it wrong. I respect the view that some people don't need their programming languages to protect them from these problems. In this case, it helped quite a lot, especially since the application was essentially reimplementing vector processing, getting the memory management wrong, and not doing anything to justify not taking advantage of the insane degree of optimization that's gone into std::vector
- hawski 2y agoC++ experience is like bash or Perl experience. You can write something, often not even that bad, but you will be much slower and there will be a lot of cliffs from which you will fall. It is not to boast or sanctify the language. After 15 years of commercial experience with it I just hate it and feel like it is a lot of useless knowledge, which I regret. It can be useful and there are always trade-offs, but I still hate it.
- Jensson 2y agoNo, but a person who hasn't written C++ will write way more bugs, because so many of the stuff they learned in other languages creates extremely severe bugs in C++ rather than compiler errors. I can understand anyone who wants to avoid having to deal with those learning mistakes that every new C++ programmer has to go through. In C++ code that looks right and clean to a non-C++ developer and that passes tests can still crash the entire program in production with no stack trace available. Or you can accidentally make copies of a big collection every function call (since C++ is pass by copy value by default even for large collections) in a hot path which would also bring down production, or massively inflate your bills if you dynamically scale up. The same doesn't apply to most other languages, there experience transfers much better and its unlikely for experienced programmers to add novice bugs in those even if he has never programmed in it before.
- protomolecule 2y agoNo, it's because your experience with 'dozen plus languages' is mostly not transferable to C++.
- anonymousDan 2y agoThe way I see it is that what most companies hiring c++ programmers really need are good systems programmers. However, being an expert in advanced and/or esoteric features of the shitshow that is the C++ language is neither necessary nor sufficient to be a good systems programmer.