What is today's "goto"?
Tags: discuss, learning, tips, history
Published: 2018-06-20 15:37:15

---
title: What is today's "goto"?
published: true
description: Identifying harmful practices
tags: #discuss #learning #tips #history
cover_image: https://thepracticaldev.s3.amazonaws.com/i/406dbcbj8el2mlkmquac.jpeg
---

50 years ago, Edgar Dijkstra published a controversial (at the time) editorial entitled ["Go To Statement Considered Harmful"](https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf). In it, he stated what others had already hinted at - notably, Tony Hoare (creator of ALGOL and [the billion dollar mistake](https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare)), 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](https://stackoverflow.com/questions/9751207/how-can-i-use-goto-in-javascript) 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](https://ewontfix.com/11/) [references](https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare), to [IPv4 wrapped addresses](https://tools.ietf.org/html/draft-itojun-v6ops-v4mapped-harmful-02) to even [entire chipset families](https://blog.invisiblethings.org/papers/2015/x86_harmful.pdf). I've found one that I agree with (to an extent) about the [the overuse of Electron](https://drewdevault.com/2016/11/24/Electron-considered-harmful.html) 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!