5 ms·
I feel like this actually explains a surprising amount of things that look silly at face value. Another example I've talked a lot with my colleagues is company
by shandor 9y ago
I feel like this actually explains a surprising amount of things that look silly at face value.
Another example I've talked a lot with my colleagues is company wide coding style definitions. They usually have stuff like "never ever use goto", but then you have Linux kernel code using goto, and it seems all weird. But here too the coding convention that feels "stupid" to the rockstar coder is in place to make the code of the summer intern even remotely usable after they are gone.
- Clubber 9y agoGoto is often used in assembler and low level C code that essentially mocks assembler, but spaghetti for procedural and OOP styles. I actually found a goto in a C# project I took over this year and one of the first things I did was change it to a while loop with a break.
- IWeldMelons 9y agogoto is used in pure c code as a substitute to exceptions, to prevent unnecessary repetition of the resource deallocation code. Even in C++ code, it is often way faster than exceptions. Goto is not scary.
- stochastic_monk 9y agoThe point is that exceptions should be used for exceptional cases only. Most situations (e.g., early returns) for which resource management would be handled by a goto are already addressed by RAII.
- cakes 9y agoNot that it is implied but it isn't just the "summer intern" that needs some coding convention guidance sometimes. It can be as useful as coming onto a project and at least you have some chance at (mentally) parsing the code/project without a huge melting pot of styles across all parts of the project (you'll obviously still get some but with convention you at least start from a slightly better place).