50 years ago, Edgar Dijkstra published a controversial (at the time) editorial entitled "Go To Statement Considered Harmful". In it, he stated what others had already hinted at - notably, Tony Hoare (creator of ALGOL and the billion dollar mistake), and John McCarthy (creator of LISP) - that goto
statements in high-level languages impeded understanding of the code. Since then, we've seen movement away from goto
... but we're still not fully clear of it.
One of my first projects as a software engineering intern was to take legacy FORTRAN and convert it into true OO C++... and make it a drop-in replacement to be called from other legacy FORTRAN as a full conversion of the codebase was performed. This was around 30 years after Djikstra's editorial and yet... in 1999, my partner and I found excessive used of goto
s in functions that were hundreds of lines long. Having the code printed out, with lines drawn between labels and their respective goto
s, trying to adapt the logic into if..else
and return
, continue
, and break
equivalents took the better part of the summer.
Unfortunately, that wasn't my last encounter with that dreaded four-letter word: goto
. On one of my former projects, I tried to use my "free time" in long release cycles to try to remove one goto
that we had in a relatively new C# project. It was buried deep inside of a numerical method. I spent the better part of a day trying to figure out how in the world I could rid of it, and... there wasn't a good, clean way. I called up the developer who'd written the code (he had moved to another company, but we're still good friends) and asked him "What in the world were you thinking?" After a long laugh at my misfortune, he said he'd ported that method from C++ at the recommendation of one of our data scientists and that was the one goto he was unable to remove cleanly. And so it stayed, presumably to this day.
It's actually pretty amazing to me that C#, a language developed around the turn of the millennium, still allowed developers to use goto
! Java actually has goto
as a reserved word, but has it marked as unused. JavaScript, with all its faults, doesn't have goto defined as a keyword. Of course, that has stopped someone from adding them in for some reason.
This kind of led me to an interesting question: what do we do in everyday development that we can do, but shouldn't? People have since posited that several things are "considered dangerous," from NULL references, to IPv4 wrapped addresses to even entire chipset families. I've found one that I agree with (to an extent) about the the overuse of Electron due to its severe bloat.
What practices and processes do you "consider harmful"? JavaScript everywhere? Measuring the wrong metrics for software quality? Crypto-everything? Let's discuss in the comments!
Object-relational mapping, aka the Vietnam of computer science.
Honestly, I don't think even
goto
is an excommunicable offense. It's a very simple, very powerful tool that's very easy to do terrible things with, and it's almost always better to use other control structures to manage execution flow in more readable terms, but there are exceptions to everything. Notably the case of breaking out of nestedwhile
loops is only easily accomplished withgoto
. And of course all loops reduce down tojmp
statements in assembly so we're technically all guilty anyway.