"The problem isn't C, it's that they weren't using C properly..."
Re:GOTOphobia Considered Harmful (In C)
by lolcatuser on Sunday February 26, 2023 @02:34PM
(#34948585)
But that is a legitimate problem.
Using a language feature that is a known footgun (`if ...` instead of `if {...}`) without being cautious enough to avoid shooting yourself in the foot is not the fault of the footgun, it's the fault of the programmer.
Additionally, in the above linked case, the problem isn't a misused `goto`, it's a misused `if ...`. It would be just as problematic if they typed `cleanup_context();` instead of `goto fail;`, but nobody complains about cleaning up state, do they?
Re:GOTOphobia Considered Harmful (In C)
by preseinger on Sunday February 26, 2023 @05:21PM
(#34950199)
Once a footgun shoots the feet of enough people, the problem is no longer with the people, it is with the thing that enables the footgun.
Re:GOTOphobia Considered Harmful (In C)
by Karellen on Sunday February 26, 2023 @02:23PM
(#34948485)
That's not really a fair complaint against C, when many safer languages whose syntax derives from C (e.g. javascript) would have the same problem.
It's a fair complaint against C and JavaScript.
Pyhon would have prevented this bug, but so would a formatter. Rust also requires braces for if-blocks to prevent this kind of error.