2 ms·
I see this "if you're good then you don't need safety" mentality in a lot of conversations with C programmers about programming languages. Maybe it's some kind
by jeroenhd 4y ago
I see this "if you're good then you don't need safety" mentality in a lot of conversations with C programmers about programming languages.
Maybe it's some kind of defencive response against newer programing languages slowly eating up spaces C used to be dominant in (like command line tools and system daemons), maybe it's just the programmer saying this thinking they're that special. Either way, most people saying this are setting themselves up for failure.
I wouldn't start a new project in C unless I absolutely have to but if you disagree, you can at least admit that there are dangers in C that you need help with if you want to be sure you're doing everything right. With most warnings treated as errors, extended warnings enabled, linting to make things like missing brackets obvious, static analysis of all code to spot difficult bugs, automated dynamic analysis of test cases and a proper testing pipeline I believe you can write C code that's safe enough.
In this case, I'm willing to give the authors the benefit of the doubt because goto hatred is worse than the risk posed by goto in most settings. Gotos used right are fancy if/switch statements and avoiding them in C can lead to a mess that doesn't add much safety. Most examples given are better in my opinion, because using goto can replicate the code flow modern languages provide with things like when/match/defer keywords.
- pjmlp 4y agoNah, it is like that since C exists, they used to call those of us that rather use languages from ALGOL systems programming linage as coding with straighjacket, or nany languages. I learned to appreciate C++ RAII already on Turbo C++ for MS-DOS around 1993, and using raw C has always been because I was required to deliver C code for some university projects or work.