[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:
10 home
20 INPUT "What is your name?" ; Name$
30 IF name$ = "ENOUGH" then goto 50
40 GOTO 20
50 end
You can use other operators than =
IF NAME$ <> "JILL" THEN PRINT "The teacher's name is Jill"
or
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 10
How 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
Valentin
ASCII is about 7 bits. So what is more than 127 is not ASCII. The MSB is used for extended tables. There are lots of ways, to extend the table. But there is not an “ASCII” way. The most standards would be the ISO/IEC 8859 tables http://en.wikipedia.org/wiki/ISO/IEC_8859
In the case of the link you provided, the program is apparently using the table of C64 which is:
http://en.wikipedia.org/wiki/PETSCII
You should try a C64 emulator like Vice:
http://www.viceteam.org/
Then you can run the program properly.
As a side note, BASIC is not a good language at all. People should stay away from it.
Jill Walker Rettberg
Thanks, Valentin – you’re right, the characters referred to are actually part of the C64 character set. I’ll look into the Vice emulator. And we talked about how there are lots of problems with BASIC – the intention of this lab was certainly not to create a new generation of BASIC programmers but to teach students of computing history about computer languages of the past.
William Patrick Wend
WOW, I remember A Touch of Applesoft!!!! I got that book with my Apple IIC in the mid-eighties as a child. I knew BASIC so well as a kid that I taught my principal in forth grade.
Jill Walker Rettberg
Wonderful! So can you come up with an excuse to teach it to your students?
Mark Sample
I was sorry to hear the C64 in-browser emulator didn’t work! I found another Java emulator that runs right in a browser, and I entered the
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
program, and it worked! (Though it ran much faster than it should.) Still, your best bet is an offline C64 emulator. VICE is probably the most popular option (it’s cross-platform).
KDS
Hmm, why do you have an ad for q500.no at the bottom of the page where I’m typing this?
(I don’t think one had that on the Commodore 64…)
Jill Walker Rettberg
Yes, I know. It’s deeply embarrassing. I tried putting an ad into the template a few years ago and forgot to remove it and now I can’t figure out where the code is. I really, really need to upgrade the blog (which means moving it away from UiB’s web hotel as they don’t support current versions of php) and start over with a clean template. Oh dear.
David Albrecht
I haven’t used BASIC in nearly 30 years. Like you, I have fond memories of writing programs for my VIC029 and my C-64.