July 20th, 2024

Teaching Programming with Basic

The article discusses the educational value of programming in GW-BASIC, emphasizing fundamental concepts like variables and loops. Despite criticisms, starting with BASIC can provide a solid foundation for beginners.

Read original articleLink Icon
Teaching Programming with Basic

The article discusses the author's experience with programming in GW-BASIC and highlights the simplicity and educational value of the language. It describes the basic structure of a GW-BASIC program, including user input, loops, and jumps. The author emphasizes that understanding fundamental programming concepts like variables, conditionals, and loops is crucial before moving on to more complex languages. The article also provides an example of drawing text-mode windows using GW-BASIC, showcasing the language's capabilities without relying on external libraries. Despite criticisms from figures like Edsger Dijkstra regarding BASIC's limitations, the author argues that starting with BASIC can provide a solid foundation for understanding computer operations before transitioning to more modern and complex languages. The article concludes by suggesting that while BASIC is a suitable starting point for beginners, transitioning to modern languages is essential to appreciate their capabilities fully.

Link Icon 11 comments
By @cortesoft - 6 months
This is very close to my heart because I learned to program in BASIC in the early 90s by reading a BASIC book from 1978. We didn’t have the internet yet, so that book was all I had, but it was simple enough for 8 year old me to figure out on my own from reading it.

I still remember the moment I ran into my parents bedroom to tell them I could print a line of text to the screen. That thrill hasn’t left me in over 30 years.

By @ggambetta - 6 months
I'd avoid using BASIC for anything serious these days, but I'm part of the "BASIC was my first language when I was 5" club, so I have to respect it as a teaching language (although I'd go for Python nowadays).

I wonder how much of the spaghettiness BASIC is infamous for is due to the language, and how much is about the programmer's mental models -- my recent raytracer for the ZX Spectrum [0] is a pretty straightforward transliteration of my JS ones.

[0] https://gabrielgambetta.com/zx-raytracer.html

By @jbandela1 - 6 months
Especially when teaching children, limiting abstractions is helpful.

A 5 year old can tell you what:

    10 PRINT “HELLO”
    20 GOTO 10

Does. You can basically look at each line In isolation and figure out what is going on. There is no nesting or scopes.

In addition other than the quotes there are minimal additional symbols. Even parentheses in a function call can be confusing.

By @dusted - 6 months
I kind of agree, it's an interesting observation that BASIC is actually pretty close to a simple machine if you think of the line numbers as addresses, goto as jumps and the keywords as instructions.

I dipped my toes in BASIC on the C64 when I was around 8 until I got my first PC at 10, and there I continued to play around with QBASIC (it was AWESOME for having the on-line help built into the IDE!!!), but my efforts never amounted to much, I never really got it and I never really made anything beyond tic-tac-toe and a few animations using the "screen 13" mode..

I only learned to program proper in PHP and later C, and JavaScript, then ASM, but to this day, I've never done anything substantial in BASIC, it's just too hard! But, as a language that introduces a few of the easier concepts, yeah, I kind of think it might be good.. I tried once to "bootstrap" on the C64, I wrote a text-editor, so that I could write the asm files.. That worked out okay. Then I started writing the assembler, in basic, and got it to spit out a few opcodes and it did generate executable images in the end, but it was so slow (something about how you load characters in from disk and concatenating strings made it run out of string memory right away and start spending all the time cleaning up instead).

I'm wondering what language I should introduce to my kid if he shows the interest, it might be whatever is adjacent to the game he might want to mod..

By @Carrok - 6 months
The included quote by Edsger Dijkstra is completely absurd. As the article points out, learning BASIC provides a fantastic foundation to build on.
By @vunderba - 6 months
I remember when I was a small child being introduced to BASIC for the first time on what I think was an IBM 286 machine.

At the time, I had no concept of things like "functions" or "subroutines" and was writing a BASIC program where I needed to re-use the same dozen lines of code to transform a value.

I attempted to "kludge" together a block of code that you would GOTO, but I couldn't figure out how to automatically return to the next label of code, e.g.:

  CLS
  10 X = 32
  20 RETNUMBER = 40 
  30 GOTO MYFUNCTION
  40 REM CONTINUE HERE
  <snip>
  70 ARG = 64
  80 RETNUMBER = 100 
  90 GOTO MYFUNCTION
  100 REM CONTINUE HERE
  <snip>

  MYFUNCTION:
  REM DO STUFF WITH ARG
  GOTO RETNUMBER
Of course, I hit an immediate syntax error - not being allowed to pass a variable to the GOTO keyword.

As I recall I ended up implementing a bunch of IF-ELSEIF statements like this:

  IF RETNUMBER = 40 THEN GOTO 40
  ELSEIF RETNUMBER = 100 THEN GOTO 100

The sheer explorative value of a quick interpretive language like BASIC cannot be understated.
By @shortrounddev2 - 6 months
The first language I got good at was QuickBASIC. It's always been sad to me that BASIC has become a hobbyist only language. Even Visual BASIC has essentially been deprecated by Microsoft
By @drewcoo - 6 months
The article is not about teaching at all despite the title.

The closest it comes to pedagogy is claiming (without evidence) that BASIC is how computers work instead of those other languages with useful abstractions.

> BASIC lacks some universally agreed-upon programming concepts

> if one wants to understand how computers work, I think it’s easier to start closer to the level they operate

Strangely, there's no mention of the PEEK and POKE commands if the author wants us to be lower level . . .

By @BobbyTables2 - 6 months
The simple graphics and cursor movements is unmatched.

However “gosub” and lack of arguments is a major shortcoming.

I had a hard time understanding the classic Microsoft demos and book/magazine games as a child.

Looking at them again, they are still hard to follow — the code is a royal mess!!!

By @fpiacenza - 6 months
Agreed. But, QBASIC is even better. No need for numbered lines, no need for a book, the basic help documentation covers all you need to know to learn as a 8 yo kid.