Learning though experimentation and breaking things

Posted by Dave Tucker on Tue 12 November 2013

Lifehacker suggested“Learning to Code by Breaking Someone Else’s Code” and I wanted to share my personal experiences with this method….

The DOS era

When I was young, 7ish, my parents bought a Packard Bell 486 machine (a DX with goofy speakers that hook on the side of the monitor IIRC). It was supposed to be for school, but as far as I was concerned it was for playing games! While the PC ran Windows 3.11, all of my games ran on DOS. DOS, as many of you probably know, has no UI, so in order to install or run a game you were at the mercy of the manual. Typically, the manual would instruct you to “cd” to a removable disk drive and run an “.exe”. This taught me some basic DOS and that an “exe” was an application that I could run.

Sound, Joysticks, IRQ and DMA

Upon running the “exe” in DOS you would be lucky if the game would run correctly first time. Sometimes you would have graphics issues, other times no sound and sometimes your joystick wouldn’t work. To get a game to work you had to select the correct drivers for graphics and sound, screen resolutions, IRQ/DMA settings. I had no idea whether what graphics card or sound card I was using so instead I would tinker with the settings until I managed to coerce the game to work. 7 year old me would usually start with what ever settings sounded coolest: anything with “Blaster” or “Voodoo” in the title; big numbers trump little numbers. This taught me that with a little patience and experimentation I could achieve my desired result.

Discovering QBASIC

One day, after having exhausted all of my games (and tweaking with their settings) I decided to take a look around the computer. I knew “cd” got me in to a directory, “dir” showed me the contents and “exe” was an application. So I started in “C:\” and systematically opened every “exe” I came across until I found something called “QBASIC”. It looked like a text editor, but on closer inspection it could do a lot more… A little more poking around revealed a file called “GORILLAS.BAS” which I ran, and to my surprise I found myself destroying computer generated gorillas with explosive bananas - Awesome!

Breaking Code and Writing My Own Applications

After much banana tossing it suddenly dawned on me that the cryptic text I saw was how this game was working and If I could teach myself to understand it then I could bend the universe to my will (or so I thought). I proceeded to modified values, deletepieces of code and used “F1” when things went wrong. I made the radius of the explosion wider, made the banana’s faster but what I really wanted was to chnage the gorillas for squirrels and the bananas to nuts. Alas, drawing sprites and 2D math was a little beyond me at the time. Instead I used what I had learned to start to create my own text-based games, influenced heavily by the Lone Wolf books by Joe Dever that I was hooked on at the time. I now knew how to code. This reinforced that fact that with a little experimentation, I could acheive - almost -anything!

So where is this story heading?

To summarise, I taught myself to code at a young age after stumbling across QBASIC and I learnt through experimentation and breaking things. My coding skills evolved as I got older (and my PC got upgraded) and using similar techniques I was able to learn some Delphi, Pascal and Visual Basic.

One criticism of this technique is that it only teaches the practical side of the equation. While I could write code to do whatever I wanted it to do, I didn’t necessarily understand “why” it was done that way or “why not” to use one approach over another.

On a more positive note, I was writing working code (even if it wasn’t elegant) rather than pontificating on the “right” or “best” wasy to do things. This provided a good foundation for understanding why the theory-side of the equation is actually useful and what problems I could use my knowledge of theory to solve.

Learning approaches are a very personal thing so I can’t say that this is the best approach to take. However, I’m glad I learned this way, and I would encourage others to try it too.

Got comments? Please feel free to leave them below!

@dave_tucker


Comments !