If you bought a home computer in the 1980s, chances are you learnt a little bit of BASIC programming. The command line interface meant that the difference between starting to play a game and writing a short program was not as big as today, and most of the Commodore 64 User’s Manual was dedicated to explaining how to program your own game or program in BASIC. So for the last few years, our first year Computing Technology: History, Theory and Practice students have had a two hour workshop where they learn to program in BASIC. Here are my notes from the first time I taught this workshop, and the post you’re reading right now gives you some updated ideas.

This is a great class to teach. It’s a simple introduction to a programming language that is of no practical value today, but that was immensely important to a generation of early home computers. The historical value is clear: we use Commodore 64 emulators so get a feel for what computers were really like in the 1980s. It teaches some simple concepts that are important in other programming languages: what is a variable? How do computers follow instructions? Why are programming languages different from each other? And it lets today’s students actually experience working with a command line interface, where you can’t use the mouse and the computer doesn’t register what you typed unless you press enter. Also, it’s very easy to start programming, so there’s instant gratification.

And you can use Nick Montfort, Patsy Baudoin, John Bell, Ian Bogost, Jeremy Douglass, Mark C. Marino, Michael Mateas, Casey Reas, Mark Sample, and Noah Vawter’s wonderful book 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 (MIT Press 2012) which is also available open access as a free PDF. I assigned the first section of the book, which goes through that one line program step by step in a very enlightening manner. You could certainly ask students to read other sections of the book as well.

I’ve got worksheets all worked out so it’s a prepackaged two hour session. Feel free to borrow, steal or adapt. Here is the worksheet I give students as a PDF, and here it is in Word format, in case you want to edit it.

Before you start, install VICE (the Versatile Commodore Emulator), which you can download for almost any platform, or use a web-based Commodore 64 emulator like cĂ´deazur’s Flash-based FC64.

Start the class off by talking a bit about early home computing, and show students this 1983 ad for the Commodore 64 to show them how programming was marketed as a really attractive aspect of home computers.

Once students have got their emulators fired up, explain that the C64 keyboard layout is more or less like a modern US keyboard, but when you press shift you get fancy symbols, so the characters shown on the screen won’t always match what your keyboard says. You can refer to these keyboard layout diagrams.

C64-keyboard-layout

Some students take quite a while to figure out the command line interface. The computer (well, emulator) won’t process what you type until you press enter at the end of a line. Using the arrow keys to go up and fix a typo won’t work unless you actually press enter for each line you changed. This is not a graphical interface.

Then I hand out worksheets and let students work their way through them. I walk around and help students who are having trouble with the command line interface.

  1. Let’s start. Type PRINT “HELLO WORLD” and press return.
  2. What’s the difference between PRINT 2 + 2 and PRINT "2 + 2"?
  3. Make a program by using line numbers. We use 10, 20, 30 rather than 1, 2, 3 so that it’s easy to add new lines in between if needed.10 PRINT “HELLO WORLD”
    20 END
    Type RUN to run your program. Type LIST to see the program code. Try adding a line:

    15 PRINT “IT’S A LOVELY DAY"Remember this is a command line interface. You can edit lines in the program by using arrow keys to get to the line and typing over the existing words. Then press RETURN or the computer won’t pay any attention to your changes. Another way to edit is to wait for the computer to say “READY” and give you a cursor. The type the line with the error all over again, and press RETURN. Now type LIST and the computer will show you the whole program, with your corrected line.

  4. To start a new program (and get rid of the old one!) type NEW.
  5. Now try a GOTO loop:10 PRINT “HELLO WORLD”
    20 GOTO 10
    Press ESC to escape the endless loop. This maps to the RUN/STOP key on the original Commodore 64.
  6. REM lets you add comments to your code. Add some.30 REM THIS IS A NOTE TO MYSELF THAT THE COMPUTER WILL IGNORE.
  7. We need variables:10 PRINT "TELL ME A NUMBER"
    20 INPUT X
    30 PRINT "YOU LIKE THE NUMBER " X "?"
    Now type RUN. The computer will show "TELL ME A NUMBER" on the screen and then a ? and a blinking cursor. That means it wants you to type something in. Now the variable X is set to the number you typed. When your program finishes running, you can try typing “PRINT X” (without line numbers, just as a command) and the computer will show you the number you typed in. It’s in memory now, not just part of the program.
  8. Now try a text variable (a string). If you want a variable to contain text and not just numbers, you need to put a $ at the end of it.40 PRINT "WHAT IS YOUR NAME?"
    50 INPUT NAME$
    60 PRINT "HELLO " NAME$

    Play around and see what you can do with this. After a bit of messing around, we’ll do a show and tell.
  9. Let’s try an IF-THEN loop:
    10 PRINT "WHAT IS YOUR NAME?"
    20 INPUT NAME$
    30 IF NAME$ = "ENOUGH" THEN GOTO 50
    40 GOTO 20
    50 END
    You can use other operators than the equal sign, like lesser than < and greater than >. <> (is lesser than or greater than) means NOT EQUAL TO. So:IF NAME$ <> "CORDELIA" THEN PRINT "I REALLY PREFER THE NAME CORDELIA"

    Play around a bit more. If you get stuck in an endless loop, you may have to reset your emulator – use the file menu at the top to find the reset options.

  10. OK, now we’re going to look at an example. Type this program in and see what happens:10 PRINT CHR$(205.5+RND(1)); : GOTO 10How does this work? Hints: have a look at (or Google) the RND command and the Commodore 64 character set. Now, what can you make, using what we’ve learnt?

OK, that’s all we really have time for in a 90 minute class session. If you come up with improvements or other ideas, I would love to hear about them – please post them in the comments!

Leave A Comment

Recommended Posts

Triple book talk: Watch James Dobson, Jussi Parikka and me discuss our 2023 books

Thanks to everyone who came to the triple book talk of three recent books on machine vision by James Dobson, Jussi Parikka and me, and thanks for excellent questions. Several people have emailed to asked if we recorded it, and yes we did! Here you go! James and Jussi’s books […]

Image on a black background of a human hand holding a graphic showing the word AI with a blue circuit board pattern inside surrounded by blurred blue and yellow dots and a concentric circular blue design.
AI and algorithmic culture Machine Vision

Four visual registers for imaginaries of machine vision

I’m thrilled to announce another publication from our European Research Council (ERC)-funded research project on Machine Vision: Gabriele de Setaand Anya Shchetvina‘s paper analysing how Chinese AI companies visually present machine vision technologies. They find that the Chinese machine vision imaginary is global, blue and competitive.  De Seta, Gabriele, and Anya Shchetvina. “Imagining Machine […]

Do people flock to talks about ChatGPT because they are scared?

Whenever I give talks about ChatGPT and LLMs, whether to ninth graders, businesses or journalists, I meet people who are hungry for information, who really want to understand this new technology. I’ve interpreted this as interest and a need to understand – but yesterday, Eirik Solheim said that every time […]