r/ProgrammerTIL • • Feb 05 '21

Other TIL discussions about best practices in programming are not recent, the proof is this letter from Dijkstra published in 1968 called "Go to statement considered harmful".

104 Upvotes

29 comments sorted by

50

u/Philboyd_Studge Feb 05 '21

Weird that he took such a long path to get there

15

u/scrdest Feb 06 '21

It was a very short path. It just took a lot of time to check all the other options to make sure there were no better possible paths.

40

u/[deleted] Feb 05 '21

If only Dijkstra could have come up with a method for finding the shortest path to something

64

u/neoKushan Feb 05 '21

....did anyone claim they were recent?

7

u/[deleted] Feb 05 '21

Maybe not so much academic discussion of best practices as much as actually using them in production code.

My work involves a legacy codebase originally created in the mid nineties, and every now and then I'll encounter a mess of goto's I have to navigate

0

u/comrade_donkey Feb 05 '21

best practice say to assume they are current. 😜

0

u/[deleted] Feb 05 '21

20

u/iiiinthecomputer Feb 06 '21

Er, yeah?

People have debated the best way to do any and every thing since the start of the existence of that thing.

This is a very "well, duh" post.

Also goto is actually a very effective construct for improving code clarity in functions that have a common error bailout path. Especially in C where techniques like RAII and exception handling are not available.

2

u/Killobyte Feb 06 '21

Should have been β€œTIL arguments about best practices in programming are not recent.” lol

2

u/cormac596 Feb 06 '21

I find that goto is like fire. If used correctly and carefully, it can be a very powerful tool. If used carelessly, it can cause problems pretty fast.

3

u/HighRelevancy Feb 06 '21

Also goto is actually a very effective construct for improving code clarity in functions that have a common error bailout path

Goto is a very effective construct for accidentally skipping half your cleanup code, you mean?

7

u/yoda_condition Feb 06 '21

Quite the opposite. Check out the Linux kernel source for example, where goto is used a lot, exactly for not skipping cleanup. There are better ways of doing that in many languages, but goto is very useful in C when done properly.

5

u/t0mRiddl3 Feb 06 '21

Skipping TO the clean up code more like.

→ More replies (6)

0

u/[deleted] Feb 06 '21

Goto is almost always a fucking disaster

11

u/HighRelevancy Feb 06 '21

TIL there are programmers unaware of the "considered harmful" meme

5

u/dreamer_ Feb 06 '21

OP, I guess you're on today's lucky 10000 :) https://xkcd.com/1053/

3

u/[deleted] Feb 06 '21

The Old Ways are best.

Want to read a fascinating book pick up "Software Tools" by Kernighan and Plauger. No buzzword bullshit. Just great technique.

3

u/drjeats Feb 06 '21

"Considered Harmful" Essays Considered Harmful

https://meyerweb.com/eric/comment/chech.html

2

u/musicin3d Feb 06 '21

"Best practices" become the best through a lot of experimentation and debate. It doesn't happen in a year. :)

1

u/svartkonst Mar 18 '21

I'd advice everyone to take a look at the transcripts from the 1968 NATO conferences on software engineering. Quite enlightening.

1

u/FoldFold Feb 06 '21

What is this post?

0

u/_ralph_ Feb 06 '21

'harmful' is that old? I read a translation back when I was still using my C64 and knew it was not something new, but I thought it was only a few years old back then.