lesson plan: BASIC for DIKULT104
[updated after class]
I taught a two hour lab on BASIC for our DIKULT104: Computing Technology: History, Theory and Practice students today. This was the first time I’ve taught BASIC, but I’m thrilled to get the chance. I have nostalgic memories of dad teaching me simple programming in BASIC when I was a kid, and even of typing programs into my C64 from computing magazines. Thank goodness for the internet, eh? The aim of this class isn’t to create programmers: we want to give students a taste of a range of languages, and for them to learn what kinds of conceptual frameworks programs can be built around and something about how to read code. We certainly aren’t trying to create a new generation of BASIC programmers, but we do hope to teach a generation that has some understanding of how programming works and that knows about the history of programming languages.
The best web-based BASIC emulator I’ve found so far is this one for Applesoft BASIC, although it’s not perfect. For a very gentle tutorial for this dialect of BASIC, the book A Touch of AppleSoft, from 1986, is perfect, and chapters 1-3 and 5 are required reading for DIKULT104. You can read it on Scribd.com (or course website for DIKULT104 students.)
I taught two groups following this lesson plan, and it went very well. Next year I’d like to have a better emulator installed on the computers in the lab, because the browser-based emulator wasn’t very good. If we use the 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 again we should try to get a C64 emulator, too, as it relies on a C64-specific character set – or find the / and \ signs in the AppleSoft character set.
To start us off, let’s take a quick look at this ad for a Commodore 64 from 1983 – notice how the inclusion of “Introduction to BASIC – a teach yourself program for the whole family” is emphasised.
Here’s what I’m planning on doing in our lab session:
- Introduce BASIC. The blurb in the New Media Reader (which is on our syllabus) is a good start. Seymour Papert’s objections (BASIC is to programming what QWERTY is to typing) are interesting. And the fact that BASIC came installed on practically every personal computer for a long time – though no longer, which may be Why Johnny Can’t Code. (That link, btw, leads to a passionate essay I’d recommend reading. Here’s a snippet: “BASIC was close enough to the algorithm that you could actually follow the reasoning of the machine as it made choices and followed logical pathways.”). Moving on to syntax and structures, have a quick look at a knitting pattern for comparison – then look at this comparison of different languages which has some fairly simple examples at the start.
- OK, everyone: fire up an emulator. Look, there’s a Hello World program. Let’s run it. Try making it say other things. Make a GOTO loop. Add a few more words. See what FLASH does (eek!) See if there are other interesting commands you could add.
- What’s the difference between PRINT 2 + 2 and PRINT “2 + 2”?
- REM lets you add comments to your code. Add some.
- We need variables:
10 print "Tell me a number"If you want a variable to contain text and not just numbers, you need to put a $ at the end of it. When you run your program it will blink a prompt at you in the top windsomething in a number. Then try a text variable (a string).
20 input X
30 print "You like the number " X "?"
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 see what people have come up with.
- Let’s try an IF-THEN loop:
20 INPUT "What is your name?" ; Name$
30 IF name$ = "ENOUGH" then goto 50
40 GOTO 20
You can use other operators than =
IF NAME$ <> "JILL" THEN PRINT "The teacher's name is Jill"
IF X > 100 THEN NumberSize$="big"
Play around a bit more.
- 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 the RND command and the ASCII character set. Another hint: the Applesoft emulator may not be displaying the ASCII characters quite right – it’s supposed to look more like this (scroll down for the screenshot).
- Now, what can you make, using what we’ve learnt?
Further reading (and thanks for the inspiration)
- Graphics were important and simple in BASIC and we haven’t even touched upon them. If you’re interested, it won’t take you long to run through the tutorials in A Touch of AppleSoft BASIC.
- This article by Mark Marino was very useful (wonderfully, Mark will be visiting us in Bergen in March as a Fulbright specialist and teaching into DIKULT103 and DIKULT303): The ppg256 Perl Primer: The Poetry of Techneculture, in Emerging Language Practices.
- bpNichols used BASIC to write First Screening: Computer Poems in 1984. In this recreated version you can see an emulation and the original code.
- Another very short art piece in BASIC is 10 poke 54272+int(rnd(1)*25),int(rnd(1)*256) : goto 10 by Noah Vawter – this code generates 18 minutes of sound on a C64 (review by Nick Montfort).
- Consider contemporary languages meant to help beginners learn programming, such as Hackety Hack! which leads you to Ruby.
- Watch or read Nick Montfort talking about 10 PRINT CHR$(205.5+RND(1)); : GOTO 10