I went looking for the source code from my first ever C program (a screen saver). I couldn’t find it, but instead I found the homework exercises from my first ever computer programming class in high school. They are all written in a BASIC flavor called True BASIC.
This class was taught by an aging math teacher who liked playing bridge and Go with his students after school - he was kind of a classic late-20th-century US nerd figure, with glasses and maybe, like, a pocket protector. I guess he’s probably not still around anymore, which is sad to realize. He always liked me and encouraged me to keep learning about computers. I didn’t really understand that I was lucky to get that kind of encouragement.
I remember this class being way too easy for me at the time. The most complicated thing in it was a quicksort implementation.
A more typical exercise was this:
REM Program: True BASIC/4d/Star Pattern/01 5/5
REM Purpose: To print a pattern of stars:
REM *
REM **
REM ***
REM ****
REM for 40 rows and then go in reverse:
REM 40 *s
REM 39 *s
REM Author: Eli Thorkelson
REM Date: 14 Mar 1997
REM These are the opening statements
PRINT " StarPattern 1.0"
PRINT " By Eli Thorkelson"
PRINT ""
PRINT ""
PRINT " Press any key when ready"
GET KEY useless !This variable is useless
REM Beginning of the first FOR-NEXT loop
REM This loop prints the first half of the *s
FOR step1 = 1 to 40
PRINT "" ! This moves to the next line
FOR step2 = 1 to step1
PRINT "*";
NEXT step2
NEXT step1
REM Beginning of the second FOR-NEXT loop
REM This loop prints the second half of the *s
FOR step1 = 40 to 1 step -1
PRINT "" ! Moves to the next line
FOR step2 = 1 to step1
PRINT "*";
NEXT step2
NEXT step1
I haven’t looked at this language in such a long time. I like the nested loop implementations. It’s both clumsy and oddly easy to read.
My favorite line, clearly, is GET KEY useless !This variable is useless
, although it should really have read !This comment is useless
since the variable name is already self-documenting. Perhaps unused
would have been a better name than useless
, though.
I tried to figure out how to execute this program. I managed to get some of it to run on qbjs.org. I had to shorten it to ten lines instead of 40, and remove the confirmation step.
StarPattern 1.0
By Eli Thorkelson
*
**
***
****
*****
******
*******
********
*********
**********
**********
*********
********
*******
******
*****
****
***
**
*
I honestly have no idea why this was even a homework exercise. I guess it assesses whether we could write nested loops. Or maybe our teacher just liked seeing stars.