LearnDay@Xoxzo is a monthly online seminar initiated by the Xoxzo team. We will have speakers from the team or guest speakers which will talk for 20 minutes each, on a subject of their choosing.
"Goto statement considered harmful" by Akira, Xoxzo Engineering.
XOXZO Learn day #17
2020/02/28
======================
We have recorded sessions of our previous LearnDay here: https://www.youtube.com/channel/UCiV-bQprArQxKBSzaKY1vQg
For updates and news on our future LearnDays, follow us on Twitter (https://twitter.com/xoxzocom/) or sign up for our Exchange Newsletter (https://info.xoxzo.com/en/exchange-mailing-list/)
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Goto statement considered harmful - LearnDay@Xoxzo #17
1. Go To Statement Considered
Harmful
By Edsger W. Dijkstra
LearnDay@Xoxzo #17
Akira Nonaka
Feb. 28 2020
2. Go To Statement Considered Harmful
Edsger W. Dijkstra
1. Communications of the ACM, Vol. 11, No. 3, March
1968
2. https://web.archive.org/web/20060613021431/
http://www.acm.org/classics/oct95/
3. Who is Edsger W. Dijkstra?
1. 11 May 1930 – 6 August 2002) was a Dutch systems
scientist, programmer, software engineer, science
essayist, and pioneer in computing science.
2. Dijkstra's algorithm
3. Semaphore
4. Structured programming
9. 1968 (Computer)
1. Intel Corporation was founded
2. UCLA is selected to be the first node on the Internet
as we know it today.
3. The term "software crisis" was coined by some
attendees at the first NATO Software Engineering
Conference in 1968 at Garmisch, Germany
10. In this letter he wrote
1. the quality of programmers is a decreasing function
of the density of go to statements in the programs
they produce.
2. the go to statement should be abolished from all
"higher level" programming languages
11. Consequence
1. The letter itself sparked a debate, including a "'GOTO
Considered Harmful' Considered Harmful”
2. I think every one can agree unrestricted use of goto
ends up unmaintainable spaghetti code.
3. Alternatives are invented as the restricted version of
goto.
12. Alternatives
1. break
2. continue
3. Exception handling, try and catch
4. C did not have exception handling as language
constructs. Instead , implemented as macro/library.
13. static jmp_buf buf;
void second() {
printf("secondn"); // prints
longjmp(buf,1); // jumps back to where setjmp
// was called - making setjmp
// now return 1
}
void first() {
second();
printf("firstn"); // does not print
}
int main() {
if (!setjmp(buf))
first(); // when executed, setjmp returned 0
else // when longjmp jumps back, setjmp
// returns 1
printf("mainn"); // prints
return 0;
}
14. 1. There is no conclusion for this talk.
2. I think it is interesting that readability, quality of the
source code (and delay of the schedule, over budget,
etc.) is already an issue in late 1960s.
Conclusions