3 ms·
C is sometimes called "portable assembly" because it allows you to use all of the features of a CPU's ISA (but it abstracts over the differences in opcodes). Th
by phendrenad2 5y ago
C is sometimes called "portable assembly" because it allows you to use all of the features of a CPU's ISA (but it abstracts over the differences in opcodes). This includes GOTO, which is analogous to "JMP", which is the cornerstone of digital computing. In other words, FOR and WHILE are compiled to GOTO by your compiler anyway.
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.pdf 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.
- retrac 5y ago> and likely has never talked to anyone who was writing an OS kernel or driver https://en.wikipedia.org/wiki/THE_multiprogramming_system 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 :)