Re:Ask HN: Why does Linux Kernel use goto statements?
by retrac on Thursday December 09, 2021 @05:25AM
(#29495799)
> and likely has never talked to anyone who was writing an OS kernel or driver
https://en.wikipedia.org/wiki/THE_multiprogramming_system
I think you have to appreciate Dijkstra's comment on goto by the standards of the era he said it. FORTRAN/COBOL/assembly spaghetti code was the norm then. At the time, software problems were scaling extremely quickly. He (and many others) felt that managing complexity was the issue for future development. Modularity and code reuse were barely known. (FORTRAN at the time had an infamous "if less than goto 1, if equal goto 2, if greater goto 3" control flow construct -- and no other conditional control flow!)
The UNIX inventors cited Dijkstra's views on structured programming as crucial to the development of a large system like UNIX... even though they did add goto to C :)
The idea that using GOTO is an indication of bad design was started by Edsger Dijkstra, and I've always found it to be a black spot on his reputation. Read it for yourself, and I think you'll come to the conclusion that he has no idea what he's talking about: https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.p... He has certainly no idea in what cases GOTO might be useful, and likely has never talked to anyone who was writing an OS kernel or driver. Remember, he was primarily an algorithms researcher turned educator, so his experience of the "Go To Statement" is entirely from students turning in programs for him to grade.