I've started coding when I was 13. In Basic. And no, I'm not gonna say "good old times". Going back to those days, the only things I remember are the command
AUTO to automatically create line numbers and the (ab)use of the
Few years later, at the high school, my computer science teacher told me that
goto is evil but luckily its use can be always avoided (see the Structured Program Theorem). One of the reasons for its bad reputation is that usually the code that uses
goto is less readable and the program flow is difficult to follow. In two words: spaghetti code.
Only a couple of years ago I realized that this is not true.
goto is not evil by itself and in some (many) situations its use can produce a code that is more readable, more optimized, and a with a smaller memory footprint.
Do you want some examples? How do you exit from multiple nested loops? Without using
goto you should have at least a variable and an
if for every loop that encloses loops and then you should have a bunch of
breaks. And you know what
break is, right? A masked
And what about multiple exit conditions that need to free allocated memory? Without using
goto, you should duplicate the cleanup code with the risk to forget something every time you need to modify the code in the future.
These are only a couple of examples about the usefulness of the
goto statement. If you are not fully convinced, have a look to this thread.
Image created by me with memegenerator.net
Post last updated on 2022/12/28.
I've started coding on a Olivetti PC 128S that ran an operating system loaded from ROM. The OS was written in BASIC and the interpreter was available at user space too. Unfortunately the embedded editor was really poor, so, the fastest way to create a program was to directly type instructions in the command line, preceded by the row number. The command AUTO automatically added multiples of ten at the begin of each row. ↩︎