April 21, 2008
Edsger Dijkstra had this to say about Beginner's All Purpose Symbolic Instruction Code:
It is practically impossible to teach good programming style to students that have had prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.
I'm sure he was exaggerating here for effect; as much as I admire his 1972 "The Humble Programmer" paper, it's hard to square that humility with the idea that choosing the wrong programming language will damage the programmer's mind. Although computer languages continue to evolve, the largest hurdle I see isn't any particular choice of language, but the fact that programmers can write FORTRAN in any language. To quote Pogo, we have met the enemy, and he is us.
Dismissing BASIC does seem rather elitist. Like many programmers of a certain age, I grew up with BASIC.
I mentioned in an earlier post the curious collision of early console gaming and programming that was the Atari 2600 BASIC Programming cartridge. I had to see this for myself, so I bought a copy on eBay.
I also bought a set of the Atari 2600 keypad controllers. The overlays come with the cartridge, and the controllers mate together to make a primitive sort of keyboard. (Also, if you were wondering what kinds of things I do with my ad revenue, buying crap like this is a big part of it, sadly.)
Surprisingly, the manual isn't available anywhere online, so I scanned it in myself. Take a look. It's hilarious. There is a transcribed HTML version of the manual, but it's much less fun to read without the pictures and diagrams.
I booted up a copy of the Basic Programming ROM in the Stella Atari 2600 emulator, then followed along with the manual and wrote a little BASIC program.
You'll notice that all the other screenshots of Atari 2600 Basic Programming on the web are essentially blank. That's probably because I'm the only person crazy enough to actually try programming in this thing. It may look painful, but you have no idea until you've tried to work with this funky "IDE". It's hilariously bad. I could barely stop laughing while punching away at my virtual keypads. But I have to confess, after writing my first "program", I got that same visceral little thrill of bending the machine to my will that I've always gotten.
The package I got from eBay included a few hand-written programming notes that I assume are from the 1980s.
Isn't that what BASIC – even this horribly crippled, elephant man Atari 2600 version of BASIC – is all about? Discovering fundamental programming concepts?
Of course, if you were at all interested in computers, you wouldn't bother programming on a dinky Atari 2600. There were much better options for gaming and programming in the form of home computers. And for the longest time, every home computer you could buy had BASIC burned into the ROM. Whether it was the Apple //, Commodore 64, or the Atari 800, you'd boot up to be greeted by a BASIC prompt. It became the native language of the hobbyist programmer.
Even the IBM PC had BASICA, GW-BASIC and finally QBasic, which was phased out with Windows 2000.
It's true that if you wanted to do anything remotely cutting-edge with those old 8-bit Apple, Commodore and Atari home computers, you had to pretty much learn assembly language. I don't recall any compiled languages on the scene until the IBM PC and DOS era, primarily Turbo Pascal. Compiled languages were esoteric and expensive until the great democratization of Turbo Pascal at its low, low price point of $49.99.*
Even if you lacked the programming skills to become the next David Crane or Will Wright, there were still a lot of interesting games and programs you could still write in good old BASIC. Certainly more than enough to figure out if you enjoyed programming, and if you had any talent. The Creative Computing compilations were like programming bibles to us.
For a long, long time, if you were interested in computers at all, you programmed in BASIC. It was as unavoidable and inevitable as the air you breathed. Every time you booted up, there was that command prompt blinking away at you. Why not type in some BASIC commands and see what happens? And then the sense of wonder, of possibility, of being able to unlock the infinitely malleable universe inside your computer. Thus the careers of millions of programmers were launched.
BASIC didn't mutilate the mind, as Dijkstra claimed. If anything, BASIC opened the minds of millions of young programmers. It was perhaps the earliest test to determine whether you were a programming sheep or a non-programming goat. Not all will be good, of course, but some inevitably will go on to be great.
Whether we're still programming in it or not, the spirit of BASIC lives on in all of us.
* as an aside, you may notice that Anders Hejlsberg was the primary author of Turbo Pascal and later Delphi; he's now a Technical Fellow at Microsoft and the chief designer of the C# language. That's a big reason why so many longtime geeks, such as myself, are so gung-ho about .NET.
Posted by Jeff Atwood
To the kid wanting to start programming:
DO NOT TAKE UP ANY FORM OF BASIC, VISUAL OR OTHERWISE. If you want something less complex and hardcore than C/C++ to start with, and want to learn a popular general purpose language, look to Java, C# (pronounced "C-sharp"), or Python. If you are mostly interested in web applications, look at PHP, Python, or Ruby. Again, AVOID visual basic at all costs.
I saved my pocket money for four months to buy Blitz Basic for the Amiga.
Basic started my programming career and like you, I am appreciative of the fact it was the first language I wrote.
Thanks for giving Basic a much needed shout-out.
I remember going to the library to photocopy 'Compute!' magazine listings, featuring cool BASIC games like "Roadar" (a racing game) and "Worms" (nibbles in Quickbasic). I also have a children's book called "Island of Secrets", which has a complete BASIC listing of an adventure game. I remember well the exhausting task of typing those listings into the computer and the pleasure of typing run and playing a real game.
And you know what? If it wasn't for the nostalgia, we'd all be saying what an abomination this BASIC is. It's next to impossible to learn anything at all from those listings. I just got out my copy of "Island of Secrets", and it's utter gibberish. Even more than Perl, traditional BASIC is a write-only language -- at least the way real BASIC programs were written. I certainly learnt nothing about programming from early exposure to BASIC. Indeed, it was almost child abuse. Tell a kid he can write real programs with his computer, and then watch him struggle vainly to reimplement "Buck Rogers" in a language that is barely worthy to implement "Hello World." The most typing in BASIC listings ever did for me was slighly improve my transcribing skills.
Things are just better now. Like blatant sexist advertising, glam metal, flickering low-resolution green text-mode terminals, and office workers chain smoking at their desks all day long, BASIC is one of those things that deserves to be consigned to the dark ages of the eighties where it belongs.
If I were to teach kids programming today I would skip all of those and start with Smalltalk. It's not terribly "useful" in today's business world but it's a wonderful way to learn programming.
Try Python. It's not quite as beautiful or pure in concept as Smalltalk, but it's Smalltalk's legitimate heir, and a real working language with lots of libraries and a big community behind it (so you can get real work done with it.)
(In fact, Python, Smalltalk and probably Lisp are the only languages I can think of that I would classify as "not child abuse" if taught as first languages in primary/secondary school. Smalltalk was of course initially designed for use by children. Granted, extraordinarily bright children, but children nonetheless.)
5 REM FIZZBUZZ IN C64 BASIC BY JASON STOKES
10 FOR I = 1 TO 100
20 GOSUB 100
30 IF D3 = -1 AND D5 = -1 THEN PRINT "FIZZBUZZ": GOTO 70
40 IF D3 = -1 THEN PRINT "FIZZ": GOTO 70
50 IF D5 = -1 THEN PRINT "BUZZ": GOTO 70
60 PRINT I
70 NEXT I
100 IF I - (INT(I / 5) * 5) = 0 THEN D5 = -1: GOTO 120
110 D5 = 0
120 IF I - (INT(I / 3) * 3) = 0 THEN D3 = -1: GOTO 140
130 D3 = 0
Man, was that hard. I'd forgotten so many gory details about the language. Like how there's only an IF construct, not an IF... ELSE construct. Oh, and in C64 BASIC variable names are only significant to the second character, so CO, COL and COLUMN are the same variable.
The apparent lack of a modulo division operator or function threw me for a while, but I improvised with a GOSUB - which, in true BASIC fashion, communicates via global variables, since there are no function arguments in BASIC -- unless you want to use DEF FN, and who the hell ever did that? Not to mention that if we declare I to be of integer type (done with I%) we can't use it in a FOR construct -- and since variables are stored internally as floats and converted for integer arithmetic, an integer in C64 BASIC is actually slower than a FLOAT anyway.
There's no booleans either -- apparently the convention is to use -1 (hex FFFF) for TRUE, and 0 for FALSE.
That brought back a lot of memories. Painful ones.
Atari 800XL, how I loved thee.
Your BASIC, I loved to program, but nowhere could I save you!
You were so volatile.
And then we got that shoe-box sized 5 1/4" external disk drive. Though, at the age of 7, I still don't think I figured out how to save to you. At least I could program beeping musics and flashing, techni-color screens!
Ah, those were the days :)
Now I feel OLD. I started on a PET 2001 (it is in my basement, and may be headed for Digibarn.) I agree that there are some constructs in BASIC that are bad, but that is with any language. You could even say that Pascal was designed for academia, and never should have left, but in the end, it is the programmer, not the language.
It also surprises me how many started about the same age I did, 6. Maybe that is the real key, not the language, but getting started, and thinking logically very early.
My first was a Heathkit H-8 (Intel 8008 processor). I had to build it before I could program it. My first programs were entered in octal machine code from the front panel keypad until I could afford a serial I/O card kit. I finally got it up to a whopping 24K of memory.
I miss Heathkit. I built radios, stereos, walkie-talkies, and test equipment besides the computer. I think the company is still around, but they do continuing education now, rather than hardware.
Oh wow - flashback. I had an Atari 800 (the one with the keyboard), and my mom used to program games for me on it. I was 6 - not quite at the level to start programming myself, although I could write simple programs. At any rate, there was no way to save them (except for a tape drive you had to buy separately), so you pretty much could play with your programmed game until you had to turn off the console - then goodbye cool game!
Anyway, I always think that I had a way-cool mom for that reason. She's not even a software engineer, so extra credit for being a marketing manager and learning to program games on an atari 800 for your kid.
Several commenters have brought up the question of how to best go about introducing a young child to computer programming in this modern day and age. Jeff, I'd love to see you address that question sometime.
And yes, a "me too": I started programming at age 5 or 6 on an IBM PC 5150 that my Dad brought home from his job at IBM. Like the Apple, Commodore, and Atari machines of the era, it booted to a BASIC programming environment if you turned on the machine with no diskette in the A: drive!
I remember that the SAVE and LOAD commands (for saving your program to a diskette, and loading it back later) would only work if you started BASIC by booting to a DOS diskette and then running BASIC (or BASICA -- both were available) from that!
At least GOTO doesn't let you jump to a location that is outside your program or doesn't contain an instruction. Infinitely more damage has been done by improperly used strcpy() and pointer arithmetic than by GOTO.
Sorry to dredge up the old post, but I really enjoyed your article and the images of the old school keyboard controllers. Those are crazy.
I remember the hour upon hours of programming I did on the old Apple computers (in addition to playing billions of hours of games). It is amazing to think back of the progression from playing and programming dinky little games to what we do today. I run a really old school, online text game company - http://www.ironrealms.com - but it is still the same old thing, hours of endless fun playing games, and coding games.
Wouldn't trade it for the world.
Well, Turbo Pascal is still alive!
And I also started with ZX Spectrum and Basic. Those were the times...