Recently, a friend of mine was lamenting the fact that he had a hard time learning programming by reading or watching videos. I suggested he learn like I did: looking at code and typing it in. Then I had a great idea and suggested that he look up an old magazine with a BASIC program and convert it to whatever language he was trying to pick up.
Long ago, back when the world was still flat, a computer in the home was seen as an expensive frivolity. There was nothing particularly compelling about getting one because whatever you could do on a computer, you could do cheaper with a pencil and paper. Maybe it would make sense if you were a company, but not so much for the individual.
Finding software, then, could be difficult and expensive. Luckily, there were magazines and books that contained code listings for various types of programs. Mostly, they were in a language called BASIC.
The thing is, as a child in this computer pre-history time, I didn’t have a lot of money to buy software. It was a lot easier to get the parents to plunk down a lot less money on a book or magazine. It could even be justified as being educational, because I could learn how to program by typing in those code listings.
The joke was on me, though, because I did, in fact, learn how to program that way. And debug. When you don’t have an Internet to search, going through a program you typed in to find out why it doesn’t behaving properly does wonders for figuring out how programs work and where you made your mistake.
BASIC is not a universally loved language. It was designed to be a learning language; something easy for someone, like children, to pick up and learn the basics (get it?) of programming. Many people, then as now, thought BASIC should be buried beneath the Earth and not taught to anyone, much less children in their formative years.
But BASIC was popular among the home computer users because, in most cases, it came built into the computer. You turned it on, there was BASIC. Even if you didn’t have a disk drive, you still had BASIC. It was ubiquitous. Given the choice of, say, dropping $95 to buy Microsoft’s Fortran for your TRS-80 (which would be the equivalent of $318 today) or using the BASIC the computer came with, well, you kind of know who’s going to win that one.
So, it was (technically) cheap, and (generally) available. The other advantage BASIC had was that it was an interpreted language. That meant the BASIC commands were turned into “machine code” when they were encountered. This meant typing in something quick and dirty, like PRINT 27*42, would give you an immediate answer and you wouldn’t have to compile it, link it, and then run it.
What about the disadvantages, then? Why wouldn’t people want this language taught to people? There are probably numerous issues (memory management, etc.) but one of the biggest was that BASIC did not teach structured programming. It was, in fact, very unstructured. It gave rise to the descriptor of “spaghetti code.” This was all most due to one command: GOTO.
The GOTO command allowed the programmer to jump to any line in the program, arbitrarily. Aside from being a great source of bugs (like, maybe using it to jump to the wrong line), it also made programs very hard to read. Given that early BASICs didn’t have, say, IF..THEN..ELSE statements, GOTO was used a lot.
10 IF X > 10 THEN 30
20 PRINT “X is less than or equal to 10”:GOTO 40
30 PRINT “X is greater than 10”
This simply checks to see if variable X is greater than 10. If it is, it jumps over line 20 to print a message saying so. If it’s less than or equal to 10, it prints its message then jumps to line 40. This may not seem particularly awful, but when you have a program that’s a hundred lines or more, following all those GOTO statements gets to be a real chore.
With a structured programming language (or a more modern BASIC), one could write the same thing like this:
IF X > 10 THEN PRINT “X is greater than 10”
ELSE PRINT “X is less than or Equal to 10”
By chance, around the time my friend mentioned his issue about learning and my suggestion of converting a BASIC program, I was reading a post by the CRPG Addict about a game called “The Devil’s Dungeon.” Evidently, there was some controversy about its status, not only as an RPG (or, Role Playing Game) but also about if it could be termed the ‘first commercial computer RPG’ because it was written in BASIC and distributed in a book, rather than being sold on disk or cassette.
“What luck,” I thought. If I could find a copy of this book online, I could try converting it to, say, Python and show my friend just how awesome an idea it was. So I found a copy of the book that “The Devil’s Dungeon” was in and began the task of converting it over. I thought it would be pretty easy.
It was not as easy as I thought it would be. The biggest sticking point was (and you should be completely not surprised by this) was the GOTO statements. It’s not a particularly long program, but following the twists and turns of the GOTOs, used to jump over sections of code and then to jump back into those previously skipped portions was breaking my brain. IF statements had to be reversed in order to get things to flow properly.
As it is, the game sort of works in Python, but I know there are issues all due to how the program executes. I may try to find these problems and fix them, some how.
After the trouble of doing this, I began to re-think my advice of converting a BASIC program to a different language. It wouldn’t, necessarily, be an easy task. But then I thought about how much I learned about Python (take away: I don’t like it) just by having to look things up or working around issues. So, I still stand by it. I still think it’s a valid learning experience. If nothing else, one would learn how not to write a program.
I may fix Devil’s Dungeon. Or, I may move on to another game that was mentioned by the CRPG Addict, called “The Dungeon of Danger.” I found the listing for it, already. It’s a lot longer and a lot more complicated than Devil’s Dungeon. It also re-introduces a long forgotten command, ON GOTO, which is already causing me heartburn. But, I also miss those old DATA statements.