madbean

The first program I ever wrote myself

12 Mar 2003

The other day, I recalled first program I ever wrote. Actually, I remember it distinctly. I was in Year 8 (aged 13 or 14) of high school. It was a bright warm summers day but cool and dark in the computer lab (the curtains were always closed on such days). Some mates and I had spent the last couple of weeks typing programs from books into the Apple IIe computers in the lab. (I can't remember what these books were called, but they were full of games like "Moonlander", written in BASIC that could run on a host of computers, like the Amstrad and our Apples.)

Anyway, after weeks of hand-copying programs from books, I actually wrote my own program from scratch. I remember thinking about it in the bus on the way to school; coming up with the idea, and how I would implement it. And here it is (this is how I remember it, anyway):

10  FOR I = 10 TO 0 STEP  - 1
20  HOME
30  PRINT I
40  FOR J = 1 TO 100 : NEXT J
50  NEXT I

Not to sophisticated, hey? It is simply a count down; ready for takeoff! It displays the numbers from 10 to 0 in the top-left of the screen (with a busy-loop as a delay). But I remember the amazing sense of accomplishment at having written my own program. And that feeling doesn't go away; I still feel the same thing each time I complete a program. Hmmm... that feeling is probably why I am a coder today.

So, feeling quite chuffed with my achievement, I called over my friends. They were all reasonably impressed (some were a year ahead of me and had been writing their own programs for a while). There was one inadequacy with my program, though. There was a noticeable flash between the HOME statement that cleared the screen and the PRINT statement that displayed the current number. Steve <#-- Palmer --> had a good solution for this, and in what probably qualifies as my first experience with pair programming, we modified the program as follows:

5  HOME
10  FOR I = 10 TO 0 STEP  - 1
20  VTAB 1
25  HTAB 1
30  PRINT I;" "
40  FOR J = 1 TO 100 : NEXT J
50  NEXT

(VTAB and HTAB position the cursor on the screen.)

So I'd written my first program, then improved it. That feeling was even better! Coding was like sculpting with frictionless clay; if you can imagine it, you can make it. And then you can change it, again and again.

Screen Shots

Feeling all nostalgic, I grabbed an Apple II emulator (AppleWin) and implemented these two programs:

First program:
screen shot 1

Second program:
screen shot 2

Boy, that brought back memories! I have literally spent hundreds upon hundreds of hours of my life sitting in front of that flashing checkered cursor, writing AppleBasic programs. (Later I used something I think was called "G-BASIC" or "Garry's BASIC", which was an enhanced AppleBasic and included GOSUBs with parameters, IIRC.)

Show me the IDE

Look at those line numbers, and that second program! If you wanted to add a line, you had to give that line a number between the line-numbers of the statements on either side. And the best way to edit a line on the Apple was to LIST it, press ESC, move the cursor to the line, and then re-type the line, pressing left-arrow for characters you wanted to preserve. There wasn't even an "insert" mode!

Compare that to now-days. I can get my IDE to refactor whole globs of my code at the press of a button. My programs are now stored in multiple files which themselves are stored and versioned in a source repository. Back then, the whole AppleBasic program was stored in one file, and you had to remember to SAVE it, and remember what 5 1/4" disk you saved it on.

"Who would have thought, thirty years ago, we'd all be sitting here drinking Château de Chaselet, eh?"

Links/Resources/Help?

  • Home
  • Blog