[TUHS] I can't drive 55: "GOTO considered harmful" 55th anniversary

josh joshnatis0 at gmail.com
Fri Mar 10 09:44:13 AEST 2023


This blog post compares the clarity of a number of programs written
with goto vs. with other control flow methods:
https://blog.joren.ga/gotophobia-harmful

Knuth’s “Structured Programming with go to Statements” argues that we
eventually missed the main point of structured programming by focusing too
much on goto. https://pic.plover.com/knuth-GOTO.pdf

Error handling (especially in loops or when releasing resources in non-RAII
languages) and implementing state machines are commonly brought up as cases
where goto is more fitting than common “structured” control flow
statements. I think some newer languages like Zig extend the “break”
mechanism to let you break to a label, so that sort of covers the first
case.

Josh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.tuhs.org/pipermail/tuhs/attachments/20230309/71b31bc8/attachment.htm>


More information about the TUHS mailing list