The Map Man Says GOTO is Evil

In the days before the C# language became popular, many people coded in BASIC.

BASIC has a rather controversial statement in the family of jump statements called GOTO. The GOTO statement lets you move the flow of control to any point in the source code that you desire. It was usually used within the THEN or ELSE clause of an IF statement. But, if you had numerous nested-IFs it could be difficult—if not impossible—to look at the source code and have any idea what it was going to do. So, you had to be careful how you wrote your code. You still do.

At the time, there was some debate on the use of this statement with respect to the maintainability of source code. And, it was much frowned upon in many circles to the point where one would be judged badly for using it.

Well, this morning, as I sifted through the changes in the C# Language Specification 5.0, I came across the goto statement. I smiled and thought to myself, “They haven’t killed you yet?” I kind of like the GOTO statement. It lets you do what you want to do; however you like . . . make up your own rules . . . you can be a rebel if you like (kind of like commas, semi-colons, em-dashes and ellipses in grammar),

Then I remembered this essay, “A Case against the GO TO Statement,”   by Edsger W. Dijkstra, the creator of the algorithm for finding the shortest path from a to b in a directed graph; or in layman’s terms, the initial ancestor of the algorithm that Google maps or your GPS receiver uses when it plots how to get from your house to the grocery store within the shortest amount of time or distance—kind of a hard thing to do.

Having studied and used some of his algorithms in college, he certainly had and still has my respect. And, if you’ve ever used a GPS, he should have yours as well. He kind of knows what he’s doing wouldn’t you say?

Back in school when I came up on the essay, I gave it strong consideration when he said:

The go to statement as it stands is just too primitive, it is too much an invitation to make a mess of one’s program.

With the exception of using, say, JMPs in assembly language (the equivalent of a GOTO in BASIC), I have tried to avoid using them as much as I can for the very same reason he states above.

But, I am happy that you can still GOTO in C#. So, if you feel like being a bit of a rebel . . . GOTO for it! Just don’t over do it . . . the Map Man might come looking for you (and he knows the quickest way to get to your house!)

Anders Hejlsberg—My Favorite Geek

Aside from Bill Gates, Anders Hejlsberg is my favorite geek.

In the mid-80s, my black-and-white TV had the phrase, “UNDER LICENSE FROM MICROSOFT” burned into the screen. It looked like the image to the right here (only in B&W).

But, once I grew out of my TRS-80 MC-10 and my TRS-80 Color Computer, BASIC was no longer a viable language to be coding in. I was in the PC world now with my AT&T 6300 on loan from my employer. And to code on that, I needed Turbo Pascal.

I loved Pascal. It was how I thought about software. And, Borland’s books taught me how to code in it and how to think about software. Later, Borland came out with Object Pascal, and Anders taught me object-oriented programming. And, along with Charles Petzold, I learned event-driven programming in Windows 3.1. Petzold and CompuServe was Stackoverflow and Google all rolled into one.

And then Anders created Delphi and combined windows and Pascal into one GUI that produced tiny, fast .exe’s that blew away Visual Basic in so many ways. Delphi was wonderfully easy to program in.

Well, Bill Gates was having none of that. So, he swooped into Borland and stole Anders from Philippe Kahn—killing Delphi. Then, Gates let Anders work his magic at Microsoft. And, when VB.NET and C# came out with the new Visual Studio and the .NET libraries, I felt the same feeling as I had felt when I experienced Delphi.

This was right. This was the way it’s supposed to be. Anders hasn’t let us down.

And now . . . he’s working on TypeScript . . . listen to “the man” talk about it . . . and download it if you like it . . . from my favorite geek, Anders . . . he’s making JavaScript better these days . . . too . . . cool . . .