← Back to all projects

LEARN BASIC PROGRAMMING DEEP DIVE

Learn BASIC Programming: From Zero to Retro Computing Master

Goal: Deeply understand BASIC—from its historical origins and unique philosophy to implementing interpreters, building games, exploring retrocomputing, and understanding why BASIC shaped a generation of programmers.


Why Learn BASIC?

BASIC (Beginner’s All-purpose Symbolic Instruction Code) was the first programming language for millions of people. Created in 1964 by John Kemeny and Thomas Kurtz at Dartmouth College, it was designed with a revolutionary goal: make programming accessible to everyone, not just mathematicians and scientists.

BASIC differs from other languages in fundamental ways:

  • Interactive by design: You type, you see results immediately (REPL before REPL was cool)
  • Line numbers as addresses: Programs are sequences of numbered lines—jump anywhere, anytime
  • Human-readable by philosophy: Commands like PRINT, INPUT, IF...THEN, GOTO
  • No compilation needed: Interpreted execution means instant feedback
  • Minimal syntax: Fewer rules, faster learning, more experimentation

After completing these projects, you will:

  • Understand why BASIC was revolutionary and how it democratized computing
  • Write and run programs on vintage systems (or emulators)
  • Build a BASIC interpreter from scratch, understanding parsing and execution
  • Appreciate the trade-offs between immediate feedback and performance
  • Understand how modern languages inherited ideas from BASIC
  • Create games and applications that ran on 8-bit computers

Core Concept Analysis

The BASIC Philosophy

┌─────────────────────────────────────────────────────────────────────────┐
│                    THE BASIC DIFFERENCE                                  │
│                                                                          │
│  FORTRAN/COBOL (1950s-60s):                                             │
│    1. Write code on paper                                               │
│    2. Punch onto cards                                                  │
│    3. Submit to operator                                                │
│    4. Wait hours/days                                                   │
│    5. Get error messages on printout                                    │
│    6. Repeat                                                            │
│                                                                          │
│  BASIC (1964+):                                                         │
│    1. Type: PRINT "HELLO"                                               │
│    2. Press Enter                                                       │
│    3. See: HELLO                                                        │
│    4. Learn, experiment, iterate instantly                              │
└─────────────────────────────────────────────────────────────────────────┘

BASIC Language Structure

┌─────────────────────────────────────────────────────────────────────────┐
│                         BASIC PROGRAM STRUCTURE                          │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  10 REM This is a comment                                               │
│  20 LET X = 5                                                           │
│  30 PRINT "Enter a number: ";                                           │
│  40 INPUT N                                                             │
│  50 IF N > X THEN GOTO 80                                               │
│  60 PRINT "Too small!"                                                  │
│  70 GOTO 30                                                             │
│  80 PRINT "You got it!"                                                 │
│  90 END                                                                 │
│                                                                          │
├─────────────────────────────────────────────────────────────────────────┤
│  Key Elements:                                                          │
│  • Line Numbers: Execution order and jump targets                       │
│  • REM: Comments for humans                                             │
│  • LET: Variable assignment (often optional)                            │
│  • PRINT: Output to screen                                              │
│  • INPUT: Get user input                                                │
│  • IF...THEN: Conditional execution                                     │
│  • GOTO: Unconditional jump                                             │
│  • GOSUB/RETURN: Subroutine calls                                       │
│  • FOR...NEXT: Loop construct                                           │
│  • END: Program termination                                             │
└─────────────────────────────────────────────────────────────────────────┘

BASIC vs Other Languages

┌───────────────────┬────────────────────────────────────────────────────┐
│    Aspect         │           Comparison                               │
├───────────────────┼────────────────────────────────────────────────────┤
│ Learning Curve    │ BASIC: Minutes to first program                   │
│                   │ C: Days to understand compilation                  │
│                   │ Assembly: Weeks to understand basics               │
├───────────────────┼────────────────────────────────────────────────────┤
│ Feedback Speed    │ BASIC: Instant (interpreted)                       │
│                   │ Python: Fast (interpreted)                         │
│                   │ C: Slow (compile, link, run)                       │
├───────────────────┼────────────────────────────────────────────────────┤
│ Control Flow      │ BASIC: GOTO + line numbers                         │
│                   │ Structured: Functions + blocks                     │
│                   │ Modern: Pattern matching + closures                │
├───────────────────┼────────────────────────────────────────────────────┤
│ Performance       │ BASIC: Slow (interpreted)                          │
│                   │ Python: Slow (interpreted)                         │
│                   │ C: Fast (compiled)                                 │
├───────────────────┼────────────────────────────────────────────────────┤
│ Memory Model      │ BASIC: Automatic, simple                           │
│                   │ C: Manual, explicit                                │
│                   │ Rust: Ownership + borrowing                        │
├───────────────────┼────────────────────────────────────────────────────┤
│ Philosophy        │ BASIC: "Easy to learn, immediate gratification"   │
│                   │ C: "Trust the programmer, stay close to hardware" │
│                   │ Python: "Readability counts"                       │
└───────────────────┴────────────────────────────────────────────────────┘

The BASIC Family Tree

                          BASIC (1964)
                              │
            ┌─────────────────┼─────────────────┐
            │                 │                 │
      Tiny BASIC         Microsoft            Structured
        (1975)           BASIC (1975)          BASICs
            │                 │                    │
    ┌───────┴───────┐   ┌────┴────┐         ┌────┴────┐
    │               │   │         │         │         │
 Altair          Pet  Apple     GW-BASIC  True    QBasic
 BASIC          BASIC  BASIC      (1983)   BASIC   (1991)
                         │                   │         │
                    Applesoft               │      Visual
                    BASIC (1977)            │      Basic
                                            │     (1991)
                                            │         │
                                      BBC BASIC    VB.NET
                                       (1981)     (2002)
                                            │
                                    ARM BBC BASIC
                                    (still active!)

Key BASIC Concepts

1. Variables and Types

10 REM Numeric variables
20 A = 42
30 X = 3.14159

40 REM String variables ($ suffix)
50 NAME$ = "JOHN"
60 GREETING$ = "HELLO, " + NAME$

70 REM Arrays
80 DIM SCORES(10)
90 SCORES(1) = 100
100 SCORES(2) = 85

2. Control Flow

10 REM IF-THEN-ELSE
20 IF X > 10 THEN PRINT "BIG" ELSE PRINT "SMALL"

30 REM FOR loop
40 FOR I = 1 TO 10
50   PRINT I * I
60 NEXT I

70 REM WHILE-like loop with GOTO
80 LET COUNT = 0
90 IF COUNT >= 10 THEN GOTO 130
100   PRINT COUNT
110   COUNT = COUNT + 1
120 GOTO 90
130 REM Done

3. Subroutines

10 PRINT "Main program"
20 GOSUB 100
30 PRINT "Back in main"
40 END

100 REM Subroutine
110 PRINT "In subroutine"
120 RETURN

4. Input/Output

10 PRINT "What is your name?"
20 INPUT NAME$
30 PRINT "Hello, "; NAME$; "!"

40 REM Formatted output
50 PRINT USING "###.##"; 3.14159
60 PRINT TAB(10); "Indented text"

Why BASIC Matters Today

  1. Historical Significance: Shaped how we think about accessibility in programming
  2. Educational Value: Still used in teaching (BBC BASIC, Small Basic)
  3. Retrocomputing: Active community preserving and creating for vintage systems
  4. Language Design: Understanding trade-offs between simplicity and power
  5. Interpreter Building: Perfect target for learning parsing and execution
  6. Game Development: Classic games were written in BASIC—recreate them!

Project List

The following 15 projects will teach you BASIC from its foundations through implementing your own interpreter.


Project 1: BASIC Time Machine (Historical Exploration)

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: BASIC (Dartmouth BASIC emulator)
  • Alternative Programming Languages: Any historical BASIC variant
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 1: Beginner
  • Knowledge Area: Computer History / Language Evolution
  • Software or Tool: DTSS BASIC emulator, historical documentation
  • Main Book: “Back to BASIC” by John Kemeny and Thomas Kurtz

What you’ll build: A documented exploration of original Dartmouth BASIC, running programs from 1964 on an emulator and understanding why each design decision was made.

Why it teaches BASIC: Before writing modern BASIC, you need to understand the original. This project immerses you in the historical context and design philosophy.

Core challenges you’ll face:

  • Finding authentic emulators → maps to understanding what “original BASIC” means
  • Reading historical documentation → maps to primary source research
  • Understanding the teletype paradigm → maps to why PRINT works the way it does
  • Appreciating the constraints → maps to design under severe limitations

Resources for key challenges:

Key Concepts:

  • Time-sharing systems: “Computer Lib/Dream Machines” by Ted Nelson
  • Interactive computing: “Tools for Thought” by Howard Rheingold
  • Language design philosophy: “Back to BASIC” Chapter 1

Difficulty: Beginner Time estimate: 3-5 days Prerequisites: Curiosity about computing history

Real world outcome:

RUN
DARTMOUTH BASIC (1964 SIMULATION)

10 PRINT "HELLO, WORLD!"
20 END

RUN
HELLO, WORLD!

READY

10 FOR I = 1 TO 10
20 PRINT I, I*I, I*I*I
30 NEXT I
40 END

RUN
 1       1       1
 2       4       8
 3       9       27
 4       16      64
 5       25      125
 6       36      216
 7       49      343
 8       64      512
 9       81      729
 10      100     1000

READY

Implementation Hints:

Start by setting up a historical BASIC environment:

  1. Find a Dartmouth BASIC emulator or use Vintage BASIC online
  2. Read the original BASIC manual from 1964
  3. Type in programs from the original documentation
  4. Note what’s different from modern languages

Questions to explore:

  • Why are line numbers necessary in 1964?
  • Why is LET optional in assignments?
  • What happens when you type a line without a number?
  • How did time-sharing make interactive programming possible?

Create a “lab notebook” documenting:

  • Programs you run
  • Behaviors that surprise you
  • Design decisions you notice
  • Comparisons to modern languages

Learning milestones:

  1. Run first program → Understand the REPL cycle
  2. Use all basic commands → PRINT, INPUT, IF, GOTO, FOR
  3. Document historical context → Why BASIC was revolutionary
  4. Compare to modern languages → What we gained and lost

Project 2: Microsoft BASIC Explorer (8-bit Era)

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Microsoft BASIC (Commodore, Apple II, TRS-80)
  • Alternative Programming Languages: BBC BASIC, Atari BASIC
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 1: Beginner
  • Knowledge Area: Retrocomputing / 8-bit Systems
  • Software or Tool: VICE (C64), AppleWin, TRS-80 emulators
  • Main Book: “Mapping the Commodore 64” by Sheldon Leemon

What you’ll build: Programs that explore the capabilities and limitations of 8-bit BASIC systems, including graphics, sound, and memory manipulation.

Why it teaches BASIC: The 8-bit era defined BASIC for a generation. These variants show how the language was adapted to different hardware.

Core challenges you’ll face:

  • Understanding hardware-specific extensions → maps to PEEK, POKE, SYS
  • Working with limited memory → maps to fitting programs in 64KB or less
  • Graphics and sound programming → maps to platform-specific capabilities
  • Saving and loading programs → maps to tape and disk storage

Resources for key challenges:

  • “Commodore 64 Programmer’s Reference Guide” - Official documentation
  • C64-Wiki - Comprehensive resource
  • AppleWin Emulator - Apple II emulation

Key Concepts:

  • Memory-mapped I/O: “Mapping the Commodore 64” - Memory maps
  • Character graphics: C64 PRG Chapter 5
  • Sound synthesis: C64 PRG Chapter 9 (SID chip)

Difficulty: Beginner Time estimate: 1 week Prerequisites: Project 1 (Historical Exploration)

Real world outcome:

10 REM COMMODORE 64 GRAPHICS DEMO
20 PRINT CHR$(147) : REM CLEAR SCREEN
30 FOR I = 1 TO 25
40   FOR J = 1 TO 40
50     POKE 1024 + (I-1)*40 + (J-1), INT(RND(1)*256)
60     POKE 55296 + (I-1)*40 + (J-1), INT(RND(1)*16)
70   NEXT J
80 NEXT I
90 PRINT "RANDOM SCREEN - PRESS ANY KEY"
100 GET A$: IF A$ = "" THEN 100
110 REM PLAY A SIMPLE TONE
120 POKE 54296, 15 : REM VOLUME MAX
130 POKE 54277, 190 : REM ATTACK/DECAY
140 POKE 54278, 248 : REM SUSTAIN/RELEASE
150 POKE 54273, 34 : REM FREQUENCY HI
160 POKE 54272, 75 : REM FREQUENCY LO
170 POKE 54276, 17 : REM WAVEFORM (TRIANGLE + GATE)
180 FOR D = 1 TO 500: NEXT D
190 POKE 54276, 0 : REM GATE OFF
200 END

Implementation Hints:

Set up multiple emulators to compare:

  1. VICE for Commodore 64
  2. AppleWin for Apple II
  3. TRS-80 emulator for TRS-80

Explore platform-specific features:

  • C64: PEEK/POKE for hardware, SID chip for sound
  • Apple II: HGR for graphics, Speaker clicks for sound
  • TRS-80: Limited graphics, but powerful text

Key memory locations to explore (C64):

  • 1024-2023: Screen memory (40x25 characters)
  • 55296-56295: Color memory
  • 53248-53294: VIC-II chip (graphics)
  • 54272-54300: SID chip (sound)

Learning milestones:

  1. Run emulator successfully → Set up development environment
  2. Write graphics programs → Understand video memory
  3. Create sound → Understand audio hardware
  4. Compare platforms → See how BASIC was adapted

Project 3: Text Adventure Game (Classic BASIC Application)

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Any BASIC variant
  • Alternative Programming Languages: QB64, FreeBASIC
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 2. The “Micro-SaaS / Pro Tool”
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Game Development / Narrative Design
  • Software or Tool: QB64, FreeBASIC, or vintage BASIC
  • Main Book: “Creating Adventure Games on Your Computer” by Tim Hartnell

What you’ll build: A complete text adventure game with multiple rooms, items, puzzles, and an inventory system—the quintessential BASIC application.

Why it teaches BASIC: Text adventures were the “killer app” for home computers. Building one teaches string manipulation, data structures (in arrays), and program organization.

Core challenges you’ll face:

  • Parsing player input → maps to string manipulation
  • Managing game state → maps to variables and arrays
  • Room navigation → maps to data structures
  • Inventory system → maps to array management

Resources for key challenges:

Key Concepts:

  • Parser design: “Creating Interactive Fiction with Inform 7” Chapter 2
  • Room graphs: Any graph theory introduction
  • State machines: Game state management

Difficulty: Intermediate Time estimate: 2 weeks Prerequisites: Projects 1-2

Real world outcome:

DARK CAVE ADVENTURE
==================

You are standing in a dark cave. Water drips from stalactites
above. A narrow passage leads NORTH. A rusty door is to the EAST.

> LOOK
You see a TORCH on the ground.

> GET TORCH
You pick up the torch. It's unlit.

> INVENTORY
You are carrying:
  - A rusty key
  - An unlit torch

> LIGHT TORCH
The torch bursts into flame, illuminating the cave.
You can now see strange symbols on the walls...

> READ SYMBOLS
The symbols spell: "THE PASSWORD IS XYZZY"

> GO EAST
The rusty door is locked.

> UNLOCK DOOR
You use the rusty key. The door creaks open.

> GO EAST
You enter a treasure chamber! Gold coins glitter everywhere.
*** CONGRATULATIONS! YOU WON! ***

Final score: 85 out of 100 points
Moves: 12

Implementation Hints:

Game structure approach:

  1. Define rooms in DATA statements or arrays
  2. Use a 2D array for room connections (N, S, E, W, Up, Down)
  3. Store inventory as a string array or flags
  4. Parse input by extracting first word (verb) and second word (noun)

Simple parser approach:

1. Get input string
2. Convert to uppercase
3. Find first space to split verb/noun
4. Check verb against known commands
5. Execute command with noun parameter

Room data structure:

Room 1: Cave entrance - N:2, S:0, E:3, W:0
Room 2: Narrow passage - N:4, S:1, E:0, W:0
Room 3: Locked room - N:0, S:0, E:0, W:1
...

Start simple and iterate:

  1. Two rooms with basic navigation
  2. Add items you can pick up
  3. Add locked door puzzle
  4. Add full vocabulary and error handling

Learning milestones:

  1. Navigate between rooms → Data-driven design
  2. Pick up and drop items → Array manipulation
  3. Solve simple puzzles → State management
  4. Complete game with win condition → Program organization

Project 4: Graphical Game (Sprites and Animation)

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Commodore 64 BASIC or BBC BASIC
  • Alternative Programming Languages: QB64, FreeBASIC with graphics
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Game Development / Graphics Programming
  • Software or Tool: VICE, BBC Micro emulator, QB64
  • Main Book: “Machine Language for the Commodore 64” by Jim Butterfield

What you’ll build: An action game with moving sprites, collision detection, and sound—pushing BASIC to its limits.

Why it teaches BASIC: Games reveal BASIC’s speed limitations, teaching you about hardware acceleration (sprites) and when to drop to machine language.

Core challenges you’ll face:

  • Real-time input → maps to non-blocking keyboard reading
  • Sprite definition and movement → maps to hardware sprites vs character graphics
  • Collision detection → maps to mathematical bounds checking
  • Game loop timing → maps to consistent frame rate

Resources for key challenges:

  • “Programming the VIC” - C64 sprite programming
  • “BBC BASIC Reference Manual” - MODE 2 graphics
  • QB64 Graphics reference - Modern BASIC graphics

Key Concepts:

  • Sprite hardware: C64 Programmer’s Reference Guide, VIC-II chapter
  • Double buffering: Advanced graphics techniques
  • Input polling: GET vs INKEY$

Difficulty: Intermediate Time estimate: 2-3 weeks Prerequisites: Projects 1-3, understanding of graphics concepts

Real world outcome:

10 REM *** SPACE SHOOTER ***
20 REM C64 BASIC - USE SPRITE HARDWARE
30 PRINT CHR$(147) : REM CLEAR SCREEN
40 V = 53248 : REM VIC-II BASE ADDRESS

50 REM DEFINE SPRITE 0 (SHIP)
60 FOR I = 0 TO 62 : READ D : POKE 832+I, D : NEXT I
70 DATA 0,24,0,0,60,0,0,126,0,0,255,0
80 DATA 1,255,128,3,255,192,7,255,224,15,255,240
90 DATA ... (more sprite data)

100 REM ENABLE SPRITE
110 POKE V+21, 1 : REM ENABLE SPRITE 0
120 POKE 2040, 13 : REM SPRITE POINTER
130 POKE V+39, 1 : REM SPRITE COLOR (WHITE)

140 REM GAME LOOP
150 X = 160 : Y = 200 : REM STARTING POSITION
160 POKE V, X : POKE V+1, Y : REM SET POSITION

170 GET K$ : REM READ KEYBOARD
180 IF K$ = "A" THEN X = X - 4
190 IF K$ = "D" THEN X = X + 4
200 IF K$ = " " THEN GOSUB 1000 : REM FIRE!

210 IF X < 24 THEN X = 24
220 IF X > 255 THEN X = 255

230 POKE V, X : REM UPDATE POSITION
240 GOTO 170

1000 REM FIRE SUBROUTINE
1010 REM (Sound and bullet logic)
1020 RETURN

Implementation Hints:

For Commodore 64:

  • Use hardware sprites (8 available, 24x21 pixels each)
  • Sprite data goes in memory at 64-byte boundaries
  • VIC-II chip at $D000 (53248) controls all graphics
  • Use GET for non-blocking input (doesn’t wait for Enter)

For BBC BASIC:

  • MODE 2 for colorful graphics
  • PLOT commands for drawing
  • INKEY$ for keyboard input
  • SOUND for music and effects

For QB64 (modern approach):

  • _DISPLAY and _LIMIT for frame control
  • _PUTIMAGE for sprites from PNG files
  • _KEYDOWN for input
  • SOUND for basic audio

General game loop structure:

10 Initialize game state
20 Clear/setup screen

100 REM === MAIN LOOP ===
110 Read input
120 Update player
130 Update enemies
140 Check collisions
150 Draw everything
160 Sound effects
170 Check win/lose
180 GOTO 100

Learning milestones:

  1. Moving sprite on screen → Understand sprite hardware
  2. Keyboard control → Real-time input
  3. Multiple sprites → Enemies and bullets
  4. Complete game loop → Win/lose conditions

Project 5: BASIC Tokenizer (First Step to Interpreter)

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Python
  • Alternative Programming Languages: C, Rust, JavaScript
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Compiler Design / Lexical Analysis
  • Software or Tool: Python, regular expressions
  • Main Book: “Writing Interpreters and Compilers for the Raspberry Pi Using Python” by Anthony J. Dos Reis

What you’ll build: A tokenizer (lexer) that breaks BASIC source code into tokens—the foundation for building an interpreter.

Why it teaches BASIC: Understanding how BASIC is parsed reveals why it’s designed the way it is. Line numbers become meaningful addresses; keywords become recognizable patterns.

Core challenges you’ll face:

  • Recognizing keywords → maps to PRINT, INPUT, GOTO, etc.
  • Handling strings → maps to quoted text preservation
  • Parsing numbers → maps to integers and floats
  • Line structure → maps to line number as first token

Resources for key challenges:

  • “Crafting Interpreters” by Robert Nystrom (free online) - Chapter on Scanning
  • “Writing an Interpreter in Go” - Thorsten Ball - Lexer chapter
  • Regular expression tutorials

Key Concepts:

  • Lexical analysis: “Crafting Interpreters” - Scanning chapter
  • Token types: Define your token categories
  • State machines: Handling multi-character tokens

Difficulty: Intermediate Time estimate: 1 week Prerequisites: Basic programming, regular expressions helpful

Real world outcome:

$ python basic_tokenizer.py test.bas

Input:
10 PRINT "HELLO, WORLD!"
20 LET X = 42
30 IF X > 10 THEN GOTO 50
40 PRINT X
50 END

Tokens:
[LINE_NUMBER(10), PRINT, STRING("HELLO, WORLD!"), NEWLINE]
[LINE_NUMBER(20), LET, IDENTIFIER(X), EQUALS, NUMBER(42), NEWLINE]
[LINE_NUMBER(30), IF, IDENTIFIER(X), GREATER, NUMBER(10), THEN, GOTO, NUMBER(50), NEWLINE]
[LINE_NUMBER(40), PRINT, IDENTIFIER(X), NEWLINE]
[LINE_NUMBER(50), END, NEWLINE]

Token Summary:
  Keywords: PRINT(2), LET(1), IF(1), THEN(1), GOTO(1), END(1)
  Numbers: 10, 20, 30, 42, 10, 40, 50
  Strings: 1
  Identifiers: X(3)

Implementation Hints:

Token types to define:

- LINE_NUMBER: Starts a line
- Keywords: PRINT, INPUT, IF, THEN, ELSE, GOTO, GOSUB, RETURN,
            FOR, TO, STEP, NEXT, LET, DIM, REM, END, DATA, READ
- Operators: +, -, *, /, ^, =, <, >, <=, >=, <>, AND, OR, NOT
- Punctuation: (, ), ,, ;, :
- Literals: NUMBER (integer/float), STRING (quoted)
- IDENTIFIER: Variable names (may end with $)
- NEWLINE: End of statement

Algorithm approach:

  1. Read input character by character
  2. Skip whitespace (but not newlines)
  3. Recognize token type based on first character:
    • Digit → number
    • Quote → string
    • Letter → keyword or identifier
    • Symbol → operator or punctuation
  4. Build token and add to list
  5. Handle REM specially (rest of line is comment)

Questions to consider:

  • How do you distinguish keywords from identifiers?
  • How do you handle string escapes (or don’t you)?
  • What about multi-line strings (usually not allowed)?
  • How do you handle the $ in string variable names?

Learning milestones:

  1. Tokenize numbers and strings → Basic literal handling
  2. Recognize all keywords → Complete BASIC vocabulary
  3. Handle line structure → Line numbers as addresses
  4. Error reporting → Useful error messages

Project 6: BASIC Parser (Abstract Syntax Tree)

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Python
  • Alternative Programming Languages: C, Rust, JavaScript
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 3: Advanced
  • Knowledge Area: Compiler Design / Parsing
  • Software or Tool: Python
  • Main Book: “Crafting Interpreters” by Robert Nystrom

What you’ll build: A parser that converts tokens into an Abstract Syntax Tree (AST), representing the program’s structure.

Why it teaches BASIC: BASIC’s simple grammar makes it an ideal first parser project. You’ll understand precedence, expressions, and statement structure.

Core challenges you’ll face:

  • Expression parsing → maps to operator precedence (, / before +, -)*
  • Statement types → maps to different syntax for each command
  • Control flow → maps to IF, FOR, GOSUB structures
  • Error recovery → maps to handling syntax errors gracefully

Resources for key challenges:

  • “Crafting Interpreters” - Chapters on Parsing
  • “Writing an Interpreter in Go” - Parser chapter
  • Pratt parsing tutorials

Key Concepts:

  • Recursive descent parsing: “Crafting Interpreters” - Parsing chapter
  • Operator precedence: Pratt parser or precedence climbing
  • AST design: Node types and structure

Difficulty: Advanced Time estimate: 2 weeks Prerequisites: Project 5 (Tokenizer)

Real world outcome:

$ python basic_parser.py test.bas

Parsing:
10 LET X = 2 + 3 * 4
20 IF X > 10 THEN GOTO 40
30 PRINT "SMALL"
40 PRINT "DONE"

AST:
Program:
  Line 10:
    LetStatement:
      variable: X
      expression: BinaryOp(+)
        left: Number(2)
        right: BinaryOp(*)
          left: Number(3)
          right: Number(4)

  Line 20:
    IfStatement:
      condition: BinaryOp(>)
        left: Identifier(X)
        right: Number(10)
      then: GotoStatement(40)

  Line 30:
    PrintStatement:
      expressions: [String("SMALL")]

  Line 40:
    PrintStatement:
      expressions: [String("DONE")]

Implementation Hints:

AST Node types to define:

Program: list of Lines
Line: line_number, statement

Statements:
  LetStatement: variable, expression
  PrintStatement: list of expressions
  InputStatement: list of variables
  GotoStatement: line_number
  GosubStatement: line_number
  ReturnStatement
  IfStatement: condition, then_stmt, [else_stmt]
  ForStatement: var, start, end, step, body
  NextStatement: variable
  DimStatement: arrays with sizes
  RemStatement: comment text
  EndStatement
  DataStatement: list of values
  ReadStatement: list of variables

Expressions:
  Number: value
  String: value
  Identifier: name
  BinaryOp: operator, left, right
  UnaryOp: operator, operand
  FunctionCall: name, arguments
  ArrayAccess: name, index

Expression parsing with precedence:

Lowest to highest:
1. OR
2. AND
3. NOT
4. =, <>, <, >, <=, >=
5. +, -
6. *, /
7. ^
8. Unary -, NOT
9. Parentheses, functions

Parsing strategy:

  1. parse_program(): Loop parsing lines until EOF
  2. parse_line(): Get line number, then parse statement
  3. parse_statement(): Switch on keyword
  4. parse_expression(): Recursive descent with precedence

Learning milestones:

  1. Parse expressions correctly → Precedence works
  2. Parse all statements → Complete BASIC coverage
  3. Build correct AST → Tree structure represents code
  4. Handle errors → Useful syntax error messages

Project 7: BASIC Interpreter (Execution Engine)

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Python
  • Alternative Programming Languages: C, Rust, JavaScript
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: 4. The “Open Core” Infrastructure
  • Difficulty: Level 3: Advanced
  • Knowledge Area: Interpreter Design / Execution
  • Software or Tool: Python
  • Main Book: “Writing Interpreters and Compilers for the Raspberry Pi Using Python” by Anthony J. Dos Reis

What you’ll build: A complete BASIC interpreter that executes programs, with variables, control flow, and I/O.

Why it teaches BASIC: Building the interpreter reveals how BASIC actually works. You’ll understand GOTO at the deepest level.

Core challenges you’ll face:

  • Variable storage → maps to environment/symbol table
  • Expression evaluation → maps to tree walking
  • GOTO implementation → maps to program counter manipulation
  • FOR/NEXT loops → maps to stack for loop state

Resources for key challenges:

  • “Crafting Interpreters” - Tree-Walk Interpreter chapter
  • “Writing Interpreters and Compilers…” - Dos Reis
  • Historical BASIC interpreter documentation

Key Concepts:

  • Tree-walking interpretation: “Crafting Interpreters” - Evaluating Expressions
  • Environment management: Variable scoping
  • Control flow implementation: GOTO, GOSUB, FOR

Difficulty: Advanced Time estimate: 3-4 weeks Prerequisites: Projects 5-6 (Tokenizer, Parser)

Real world outcome:

$ python basic_interpreter.py

TINY BASIC INTERPRETER v1.0
===========================

READY.

>10 PRINT "NUMBER GUESSING GAME"
>20 LET SECRET = INT(RND * 100) + 1
>30 LET TRIES = 0
>40 PRINT "GUESS A NUMBER (1-100):"
>50 INPUT GUESS
>60 LET TRIES = TRIES + 1
>70 IF GUESS = SECRET THEN GOTO 110
>80 IF GUESS < SECRET THEN PRINT "TOO LOW!"
>90 IF GUESS > SECRET THEN PRINT "TOO HIGH!"
>100 GOTO 40
>110 PRINT "YOU GOT IT IN "; TRIES; " TRIES!"
>120 END

>RUN
NUMBER GUESSING GAME
GUESS A NUMBER (1-100):
?50
TOO HIGH!
GUESS A NUMBER (1-100):
?25
TOO LOW!
GUESS A NUMBER (1-100):
?37
TOO HIGH!
GUESS A NUMBER (1-100):
?31
YOU GOT IT IN 4 TRIES!

READY.

>LIST
10 PRINT "NUMBER GUESSING GAME"
20 LET SECRET = INT(RND * 100) + 1
...

>LIST 40-60
40 PRINT "GUESS A NUMBER (1-100):"
50 INPUT GUESS
60 LET TRIES = TRIES + 1

READY.

Implementation Hints:

Interpreter structure:

class Interpreter:
    def __init__(self):
        self.variables = {}       # Variable storage
        self.lines = {}           # line_number -> AST node
        self.program_counter = 0  # Current line
        self.line_order = []      # Sorted line numbers
        self.for_stack = []       # FOR/NEXT state
        self.gosub_stack = []     # GOSUB return addresses
        self.data_pointer = 0     # DATA/READ position
        self.data_values = []     # Collected DATA values

Execution loop:

1. Sort lines by number
2. Set program counter to first line
3. While not at END:
   a. Get current line's AST
   b. Execute statement
   c. Advance to next line (unless GOTO)
4. Handle GOSUB/RETURN via stack
5. Handle FOR/NEXT via stack

GOTO implementation:

def execute_goto(self, line_num):
    if line_num in self.lines:
        self.program_counter = self.line_order.index(line_num)
    else:
        raise RuntimeError(f"Undefined line {line_num}")

FOR/NEXT implementation:

# FOR I = 1 TO 10 STEP 2
1. Store (variable, end_value, step, line_after_for) on stack
2. Set variable to start value

# NEXT I
1. Pop or peek loop info
2. Increment variable by step
3. If not done: goto line after FOR
4. If done: pop and continue

Built-in functions to implement:

  • ABS, INT, SQR, SIN, COS, TAN, LOG, EXP
  • RND (random number)
  • LEN, LEFT$, RIGHT$, MID$, CHR$, ASC, STR$, VAL
  • TAB, SPC (formatting)

Learning milestones:

  1. Evaluate expressions → Calculator works
  2. Execute simple programs → PRINT, LET, GOTO work
  3. Handle loops → FOR/NEXT work correctly
  4. Complete interpreter → Run real BASIC programs

Project 8: Interactive BASIC Environment (REPL)

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Python
  • Alternative Programming Languages: C, Rust
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 2. The “Micro-SaaS / Pro Tool”
  • Difficulty: Level 3: Advanced
  • Knowledge Area: Development Tools / User Interface
  • Software or Tool: Python, readline library
  • Main Book: “Crafting Interpreters” by Robert Nystrom

What you’ll build: A complete BASIC environment with line editing, program listing, saving/loading, and the classic “READY.” prompt.

Why it teaches BASIC: The REPL (Read-Eval-Print Loop) was BASIC’s signature feature. Building one teaches you about interactive programming environments.

Core challenges you’ll face:

  • Line editing → maps to insert, replace, delete lines
  • Immediate mode → maps to execute without line number
  • Program management → maps to NEW, LOAD, SAVE, LIST
  • Error handling → maps to graceful error messages

Resources for key challenges:

  • Python readline module documentation
  • “Crafting Interpreters” - A Tree-Walk Interpreter
  • Original BASIC documentation for command reference

Key Concepts:

  • REPL design: Interactive programming patterns
  • Line editor: Insert, delete, replace operations
  • File I/O: SAVE and LOAD implementation

Difficulty: Advanced Time estimate: 1-2 weeks Prerequisites: Project 7 (Interpreter)

Real world outcome:

TINY BASIC v2.0
===============
64K BASIC MEMORY FREE

READY.

>PRINT 2 + 2
4

READY.

>10 PRINT "HELLO"
>20 PRINT "WORLD"

>LIST
10 PRINT "HELLO"
20 PRINT "WORLD"

READY.

>15 PRINT "BEAUTIFUL"

>LIST
10 PRINT "HELLO"
15 PRINT "BEAUTIFUL"
20 PRINT "WORLD"

READY.

>15
>LIST
10 PRINT "HELLO"
20 PRINT "WORLD"

READY.

>SAVE "HELLO.BAS"
SAVED.

>NEW
READY.

>LOAD "HELLO.BAS"
LOADED.

>RUN
HELLO
WORLD

READY.

>RENUM 100, 10
>LIST
100 PRINT "HELLO"
110 PRINT "WORLD"

READY.

Implementation Hints:

REPL structure:

while True:
    line = input(">")
    
    if starts_with_number(line):
        # Program line - store it
        line_num = extract_number(line)
        rest = extract_rest(line)
        if rest.strip() == "":
            delete_line(line_num)
        else:
            store_line(line_num, rest)
    else:
        # Immediate mode - execute now
        execute_immediate(line)

Essential commands:

  • RUN: Execute program from first line
  • LIST: Show all lines (or range)
  • NEW: Clear program
  • LOAD "file": Load from file
  • SAVE "file": Save to file
  • RENUM [start, step]: Renumber lines
  • DELETE line[-line]: Delete lines
  • CONT: Continue after STOP
  • TRACE ON/OFF: Debug tracing

Line management:

  • Use a dictionary: {line_number: source_code}
  • To insert: just add with any number
  • To delete: type line number alone
  • To replace: type line number with new content
  • LIST sorts by line number

Learning milestones:

  1. Basic REPL works → Type and edit lines
  2. Immediate mode → Execute without numbers
  3. SAVE/LOAD → Persist programs
  4. Full environment → All editing commands work

Project 9: QBasic/FreeBASIC Modern Development

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: FreeBASIC or QB64
  • Alternative Programming Languages: PureBasic, PowerBASIC
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 2. The “Micro-SaaS / Pro Tool”
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Structured Programming / Modern BASIC
  • Software or Tool: FreeBASIC, QB64, DOSBox (for original QBasic)
  • Main Book: “QBasic by Example” by Greg Perry

What you’ll build: Modern structured programs in QBasic/FreeBASIC, exploring how BASIC evolved beyond line numbers.

Why it teaches BASIC: Modern BASIC variants show how the language evolved. You’ll understand the transition from GOTO-based to structured programming.

Core challenges you’ll face:

  • Structured constructs → maps to SUB, FUNCTION, SELECT CASE
  • Graphics programming → maps to SCREEN modes, CIRCLE, LINE
  • File handling → maps to OPEN, CLOSE, sequential/random access
  • Type definitions → maps to TYPE…END TYPE for structures

Resources for key challenges:

Key Concepts:

  • Structured programming: SUB/FUNCTION without GOSUB
  • Graphics modes: SCREEN statement
  • Type system: User-defined types

Difficulty: Intermediate Time estimate: 2 weeks Prerequisites: Projects 1-3

Real world outcome:

' BOUNCING BALL - QB64/FreeBASIC
' Demonstrates structured BASIC with graphics

SCREEN 12  ' 640x480, 16 colors

TYPE Ball
    x AS SINGLE
    y AS SINGLE
    dx AS SINGLE
    dy AS SINGLE
    radius AS INTEGER
    color AS INTEGER
END TYPE

DIM balls(1 TO 10) AS Ball
DIM i AS INTEGER

' Initialize balls
FOR i = 1 TO 10
    balls(i).x = RND * 600 + 20
    balls(i).y = RND * 440 + 20
    balls(i).dx = (RND - 0.5) * 10
    balls(i).dy = (RND - 0.5) * 10
    balls(i).radius = INT(RND * 20) + 5
    balls(i).color = INT(RND * 15) + 1
NEXT i

' Main loop
DO
    CLS
    
    FOR i = 1 TO 10
        UpdateBall balls(i)
        DrawBall balls(i)
    NEXT i
    
    _DISPLAY  ' QB64 double buffering
    _LIMIT 60  ' 60 FPS
LOOP UNTIL INKEY$ <> ""

SUB UpdateBall (b AS Ball)
    b.x = b.x + b.dx
    b.y = b.y + b.dy
    
    IF b.x < b.radius OR b.x > 640 - b.radius THEN b.dx = -b.dx
    IF b.y < b.radius OR b.y > 480 - b.radius THEN b.dy = -b.dy
END SUB

SUB DrawBall (b AS Ball)
    CIRCLE (b.x, b.y), b.radius, b.color
    PAINT (b.x, b.y), b.color, b.color
END SUB

Implementation Hints:

Key differences from classic BASIC:

  • No line numbers required
  • SUB/FUNCTION replace GOSUB
  • SELECT CASE replaces IF/GOTO chains
  • DO/LOOP replaces GOTO loops
  • TYPE for structures (like C structs)
  • DIM can appear anywhere (not just at start)

Graphics programming:

SCREEN 12           ' 640x480, 16 colors
SCREEN 13           ' 320x200, 256 colors
PSET (x, y), color  ' Plot point
LINE (x1,y1)-(x2,y2), color
CIRCLE (x, y), radius, color
PAINT (x, y), fill, border
GET (x1,y1)-(x2,y2), array  ' Capture region
PUT (x, y), array           ' Draw region

File handling:

OPEN "data.txt" FOR INPUT AS #1
OPEN "output.txt" FOR OUTPUT AS #2
OPEN "binary.dat" FOR RANDOM AS #3 LEN = 64

LINE INPUT #1, text$      ' Read line
PRINT #2, "Hello"         ' Write line
GET #3, recordNum, record ' Random access
PUT #3, recordNum, record

CLOSE #1, #2, #3

Learning milestones:

  1. Structured programs → No GOTO needed
  2. Graphics demo → Animation loop
  3. User types → Complex data structures
  4. Complete application → File handling included

Project 10: BBC BASIC Deep Dive

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: BBC BASIC
  • Alternative Programming Languages: ARM BBC BASIC, BB4W
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 2. The “Micro-SaaS / Pro Tool”
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Systems Programming / Education
  • Software or Tool: BeebEm, BBC BASIC for SDL, Matrix Brandy
  • Main Book: “BBC Microcomputer User Guide”

What you’ll build: Programs exploring BBC BASIC’s unique features: inline assembly, structured keywords, and the MODE system.

Why it teaches BASIC: BBC BASIC is considered the “best” BASIC variant—it’s still actively developed! It bridges BASIC and systems programming.

Core challenges you’ll face:

  • Procedure-based programming → maps to DEF PROC, DEF FN
  • Inline assembly → maps to writing 6502/ARM assembly in BASIC
  • Graphics modes → maps to MODE command and resolution control
  • Sound system → maps to ENVELOPE and SOUND commands

Resources for key challenges:

Key Concepts:

  • Structured BASIC: DEF PROC/ENDPROC, DEF FN
  • Inline Assembly: The assembler is built-in!
  • Graphics Modes: High-res to teletext

Difficulty: Intermediate Time estimate: 2 weeks Prerequisites: Projects 1-4, optional assembly knowledge

Real world outcome:

REM BBC BASIC - PLASMA EFFECT
MODE 1
VDU 23,1,0;0;0;0; : REM HIDE CURSOR

REM DEFINE COLOR PALETTE
FOR I% = 0 TO 15
  VDU 19, I%, I% MOD 8; 0;
NEXT I%

REM MAIN LOOP
TIME = 0
REPEAT
  T% = TIME / 50
  FOR Y% = 0 TO 255
    FOR X% = 0 TO 319 STEP 4
      V% = SIN(X%/32 + T%/5) * 128
      V% += SIN(Y%/16 + T%/3) * 64
      V% += SIN((X%+Y%)/64 + T%/7) * 64
      C% = (ABS(V%) DIV 16) MOD 4
      GCOL 0, C%
      PLOT 69, X%, 255 - Y%
    NEXT X%
  NEXT Y%
UNTIL INKEY(0) > 0

REM BBC BASIC WITH INLINE ASSEMBLY
DEF PROCfast_fill(addr%, count%, value%)
  LOCAL P%
  P% = buffer%
  [OPT 0
    LDX #count% MOD 256
    LDA #value%
  .loop
    STA addr%,X
    DEX
    BNE loop
    RTS
  ]
  CALL buffer%
ENDPROC

REM STRUCTURED PROGRAMMING
DEF FNfactorial(n%)
  IF n% <= 1 THEN = 1
  = n% * FNfactorial(n% - 1)

PRINT "10! = "; FNfactorial(10)

Implementation Hints:

BBC BASIC unique features:

  • DEF PROC/ENDPROC: Named procedures (better than GOSUB)
  • DEF FN: Named functions (can return values)
  • LOCAL: Local variables within procedures
  • [...]: Inline assembly between brackets
  • MODE n: Set graphics/text mode
  • VDU: Direct video control
  • *commands: OS commands (like shell)

Graphics modes (original BBC Micro):

  • MODE 0: 640x256, 2 colors
  • MODE 1: 320x256, 4 colors
  • MODE 2: 160x256, 8 colors (logical)
  • MODE 4: 320x256, 2 colors
  • MODE 5: 160x256, 4 colors
  • MODE 7: Teletext mode (text with graphics characters)

Modern BBC BASIC for SDL adds more modes.

Why BBC BASIC is special:

  1. Proper structured programming (1981!)
  2. Built-in assembler
  3. Long variable names
  4. Fast execution (partial compilation)
  5. Still actively developed (ARM, Windows, Mac, Linux)

Learning milestones:

  1. Use DEF PROC/FN → Structured programming
  2. Graphics programs → MODE and plotting
  3. Inline assembly → Bridge to machine code
  4. Complete application → Use all features

Project 11: Tiny BASIC Compiler (BASIC to C)

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Python (compiler), C (output)
  • Alternative Programming Languages: Go, Rust
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 4: Expert
  • Knowledge Area: Compiler Design / Code Generation
  • Software or Tool: Python, GCC
  • Main Book: “Writing a C Compiler” by Nora Sandler

What you’ll build: A compiler that translates BASIC source code to C, which can then be compiled to fast native code.

Why it teaches BASIC: Compiling BASIC to C shows you code generation and how high-level constructs map to lower-level ones.

Core challenges you’ll face:

  • Code generation → maps to translating AST to C
  • Variable management → maps to type inference and declarations
  • GOTO translation → maps to labels and switch/goto in C
  • Runtime library → maps to INPUT, PRINT, etc.

Resources for key challenges:

  • “Writing a C Compiler” by Nora Sandler
  • “Engineering a Compiler” by Cooper & Torczon
  • Tiny BASIC specification

Key Concepts:

  • Code generation: Translating AST to target language
  • Runtime library: Supporting functions
  • Type inference: Determining variable types

Difficulty: Expert Time estimate: 3-4 weeks Prerequisites: Projects 5-7 (complete interpreter)

Real world outcome:

$ cat guessing.bas
10 PRINT "GUESS THE NUMBER!"
20 LET SECRET = INT(RND * 100) + 1
30 PRINT "ENTER YOUR GUESS:"
40 INPUT GUESS
50 IF GUESS = SECRET THEN GOTO 90
60 IF GUESS < SECRET THEN PRINT "TOO LOW"
70 IF GUESS > SECRET THEN PRINT "TOO HIGH"
80 GOTO 30
90 PRINT "YOU WON!"
100 END

$ python basic_compiler.py guessing.bas -o guessing.c

$ cat guessing.c
#include "basic_runtime.h"

int main() {
    double SECRET, GUESS;
    
    basic_print_string("GUESS THE NUMBER!\n");
    SECRET = floor(basic_rnd() * 100) + 1;
    
line_30:
    basic_print_string("ENTER YOUR GUESS:\n");
    GUESS = basic_input_number();
    
    if (GUESS == SECRET) goto line_90;
    if (GUESS < SECRET) basic_print_string("TOO LOW\n");
    if (GUESS > SECRET) basic_print_string("TOO HIGH\n");
    goto line_30;
    
line_90:
    basic_print_string("YOU WON!\n");
    return 0;
}

$ gcc guessing.c basic_runtime.c -o guessing -lm
$ ./guessing
GUESS THE NUMBER!
ENTER YOUR GUESS:
50
TOO HIGH
ENTER YOUR GUESS:
25
TOO LOW
ENTER YOUR GUESS:
37
YOU WON!

Implementation Hints:

Code generation strategy:

def compile_program(ast):
    output = ['#include "basic_runtime.h"', '', 'int main() {']
    
    # Collect all variables
    variables = collect_variables(ast)
    for var in variables:
        if var.endswith('$'):
            output.append(f'    char {var[:-1]}[256] = "";')
        else:
            output.append(f'    double {var} = 0;')
    output.append('')
    
    # Generate code for each line
    for line in ast.lines:
        output.append(f'line_{line.number}:')
        output.append(compile_statement(line.statement))
    
    output.append('    return 0;')
    output.append('}')
    return '\n'.join(output)

Statement translation:

PRINT expr        →  basic_print_*(expr);
LET X = expr      →  X = (compile_expr(expr));
GOTO n            →  goto line_n;
IF cond THEN stmt →  if (compile_expr(cond)) { compile_stmt(stmt) }
FOR I = a TO b    →  for (I = a; I <= b; I++)
INPUT X           →  X = basic_input_number();
END               →  return 0;

Runtime library (basic_runtime.c):

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

void basic_print_string(const char* s) {
    printf("%s", s);
}

void basic_print_number(double n) {
    if (n == floor(n)) printf("%d", (int)n);
    else printf("%g", n);
}

double basic_input_number() {
    double n;
    scanf("%lf", &n);
    return n;
}

double basic_rnd() {
    static int seeded = 0;
    if (!seeded) { srand(time(NULL)); seeded = 1; }
    return (double)rand() / RAND_MAX;
}

Learning milestones:

  1. Generate valid C → Compiles without errors
  2. All statements work → PRINT, LET, GOTO, IF
  3. Loops work → FOR/NEXT translation
  4. Complete programs run → Match interpreter behavior

Project 12: BASIC Language Extensions

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Python (extend your interpreter)
  • Alternative Programming Languages: C, JavaScript
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 3. The “Service & Support” Model
  • Difficulty: Level 3: Advanced
  • Knowledge Area: Language Design / Extension Mechanisms
  • Software or Tool: Your interpreter from Project 7-8
  • Main Book: “Programming Language Pragmatics” by Michael Scott

What you’ll build: Extensions to your BASIC interpreter: graphics, networking, file I/O, and perhaps even user-defined functions.

Why it teaches BASIC: Extending a language teaches you about language design trade-offs and how features interact.

Core challenges you’ll face:

  • Graphics commands → maps to PSET, LINE, CIRCLE, etc.
  • Network operations → maps to modern socket programming
  • User-defined procedures → maps to DEF FN, DEF PROC
  • Error handling → maps to ON ERROR GOTO

Resources for key challenges:

  • Python pygame for graphics
  • Python socket for networking
  • Language design literature

Key Concepts:

  • Language extension patterns: How to add features cleanly
  • Graphics primitives: Drawing operations
  • Error handling: Exception mechanisms

Difficulty: Advanced Time estimate: 2-3 weeks Prerequisites: Projects 7-8 (complete interpreter)

Real world outcome:

>10 REM EXTENDED BASIC DEMO
>20 SCREEN 640, 480, "My Graphics"
>30 FOR I = 0 TO 360 STEP 5
>40   X = 320 + COS(I * 3.14159 / 180) * 200
>50   Y = 240 + SIN(I * 3.14159 / 180) * 200
>60   LINE 320, 240, X, Y, RGB(I MOD 256, 255 - I MOD 256, 128)
>70 NEXT I
>80 WAITKEY
>90 END

>RUN
[Window opens with colorful starburst pattern]
[Press any key to close]

READY.

>10 REM NETWORK EXTENSION
>20 OPEN #1, "TCP:example.com:80"
>30 PRINT #1, "GET / HTTP/1.0"
>40 PRINT #1, ""
>50 WHILE NOT EOF(1)
>60   LINE INPUT #1, L$
>70   PRINT L$
>80 WEND
>90 CLOSE #1
>100 END

>RUN
HTTP/1.0 200 OK
Content-Type: text/html
...

Implementation Hints:

Graphics extension (using pygame):

class GraphicsExtension:
    def __init__(self, interpreter):
        self.interpreter = interpreter
        self.screen = None
        
    def cmd_screen(self, args):
        # SCREEN width, height, "title"
        width, height = int(args[0]), int(args[1])
        title = args[2] if len(args) > 2 else "BASIC Graphics"
        pygame.init()
        self.screen = pygame.display.set_mode((width, height))
        pygame.display.set_caption(title)
        
    def cmd_pset(self, args):
        # PSET x, y, color
        x, y, color = int(args[0]), int(args[1]), args[2]
        self.screen.set_at((x, y), self._parse_color(color))
        pygame.display.flip()
        
    def cmd_line(self, args):
        # LINE x1, y1, x2, y2, color
        x1, y1, x2, y2 = map(int, args[:4])
        color = self._parse_color(args[4])
        pygame.draw.line(self.screen, color, (x1, y1), (x2, y2))
        pygame.display.flip()

New commands to implement:

  • SCREEN width, height: Open graphics window
  • PSET x, y, color: Plot point
  • LINE x1, y1, x2, y2, color: Draw line
  • CIRCLE x, y, radius, color: Draw circle
  • RGB(r, g, b): Create color value
  • WAITKEY: Wait for keypress
  • INKEY$: Non-blocking key check

For networking:

def cmd_open(self, args):
    # OPEN #n, "TCP:host:port" or "FILE:path"
    channel, spec = args
    if spec.startswith("TCP:"):
        host, port = spec[4:].split(":")
        sock = socket.socket()
        sock.connect((host, int(port)))
        self.channels[channel] = sock
    else:
        self.channels[channel] = open(spec, 'r')

Learning milestones:

  1. Graphics works → Draw on screen
  2. Animation possible → Real-time updates
  3. File I/O works → OPEN, CLOSE, INPUT#
  4. Network works → TCP connections

Project 13: Visual BASIC Archaeology

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Visual Basic 6 (emulated) or VB.NET
  • Alternative Programming Languages: Gambas (Linux VB clone)
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 3. The “Service & Support” Model
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Desktop Applications / RAD Development
  • Software or Tool: Visual Basic 6 (VM), VB.NET, Gambas
  • Main Book: “Programming Visual Basic 6.0” by Francesco Balena

What you’ll build: Desktop applications exploring Visual Basic’s event-driven, form-based programming model.

Why it teaches BASIC: VB revolutionized application development. Understanding RAD (Rapid Application Development) and event-driven programming through BASIC’s lens.

Core challenges you’ll face:

  • Event-driven programming → maps to buttons, timers, form events
  • Form design → maps to visual layout, controls
  • Data binding → maps to connecting UI to data
  • COM integration → maps to Windows component model

Resources for key challenges:

  • Gambas - Open source VB clone for Linux
  • VB6 documentation (archived)
  • VB.NET tutorials

Key Concepts:

  • Event-driven programming: “Visual Basic 6” - Balena, Chapter 4
  • Form design: UI construction
  • ActiveX/COM: Component integration

Difficulty: Intermediate Time estimate: 2 weeks Prerequisites: Projects 1-3, general programming knowledge

Real world outcome:

' VB6 / VB.NET / Gambas style
' Simple Calculator Application

Private Sub btnAdd_Click()
    Dim a As Double, b As Double
    a = Val(txtNum1.Text)
    b = Val(txtNum2.Text)
    txtResult.Text = Str(a + b)
End Sub

Private Sub btnSubtract_Click()
    txtResult.Text = Str(Val(txtNum1.Text) - Val(txtNum2.Text))
End Sub

Private Sub Form_Load()
    Me.Text = "Simple Calculator"
    txtNum1.Text = "0"
    txtNum2.Text = "0"
    txtResult.Text = ""
End Sub

' Timer-based animation
Private Sub Timer1_Timer()
    Static angle As Double
    angle = angle + 0.1
    picBox.Cls
    picBox.Circle (100 + 50 * Cos(angle), 100 + 50 * Sin(angle)), 10
End Sub

Implementation Hints:

For VB6 experience (if you can’t access VB6):

  • Use Gambas on Linux (very similar)
  • Use VB.NET (evolved version)
  • Study code examples without running

Key VB concepts:

Events:
  Form_Load          ' When form opens
  Button_Click       ' When button clicked
  Timer_Timer        ' Timer tick
  TextBox_Change     ' Text changed
  
Controls:
  TextBox            ' Text input
  Label              ' Static text
  Button             ' Clickable button
  ListBox            ' List of items
  ComboBox           ' Dropdown list
  PictureBox         ' Graphics area
  Timer              ' Time-based events

Properties:
  control.Text       ' Text content
  control.Enabled    ' Is enabled?
  control.Visible    ' Is visible?
  control.Left/Top   ' Position
  control.Width/Height ' Size

RAD workflow:

  1. Design form visually (drag controls)
  2. Set properties in Properties window
  3. Double-click controls to add event handlers
  4. Write BASIC code in event handlers
  5. Run and test immediately

Learning milestones:

  1. Create simple form → Controls and layout
  2. Handle events → Click, change, timer
  3. Data application → List, display, calculate
  4. Complete application → Multiple forms, menus

Project 14: BASIC Game Console (Custom Platform)

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Python (platform), BASIC (programs)
  • Alternative Programming Languages: C, JavaScript
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: 4. The “Open Core” Infrastructure
  • Difficulty: Level 4: Expert
  • Knowledge Area: Fantasy Console / Platform Design
  • Software or Tool: Your interpreter, pygame/SDL
  • Main Book: “PICO-8 Fanzine” (for inspiration)

What you’ll build: A “fantasy console” with fixed specifications that runs BASIC programs—like PICO-8 but with BASIC!

Why it teaches BASIC: Designing a constrained platform teaches you about trade-offs in language and system design while creating something fun.

Core challenges you’ll face:

  • Specification design → maps to defining limitations
  • Graphics system → maps to sprites, tilemap, palette
  • Sound system → maps to simple audio synthesis
  • Development tools → maps to editor, sprite tool

Resources for key challenges:

  • PICO-8 - Fantasy console inspiration
  • TIC-80 - Open source fantasy console
  • Pygame/SDL documentation

Key Concepts:

  • Fantasy console design: Constraints breed creativity
  • Sprite-based graphics: Tile and sprite systems
  • Chip-tune audio: Simple synthesis

Difficulty: Expert Time estimate: 4-6 weeks Prerequisites: Projects 7-8, 12 (interpreter with extensions)

Real world outcome:

BASIC-8 FANTASY CONSOLE
========================
Screen: 128x128 pixels
Colors: 16 fixed palette
Sprites: 256 8x8 sprites
Map: 128x64 tiles
Sound: 4 channels, 64 sounds
Code: BASIC with extensions

>EDIT 0
[Opens sprite editor]
[Design 8x8 player sprite]
[Save as sprite 0]

>EDIT CODE
10 REM BASIC-8 GAME
20 CLS
30 X = 64: Y = 64
40 SPR 0, X, Y
50 BTN$ = BUTTON()
60 IF BTN$ = "LEFT" THEN X = X - 1
70 IF BTN$ = "RIGHT" THEN X = X + 1
80 IF BTN$ = "UP" THEN Y = Y - 1
90 IF BTN$ = "DOWN" THEN Y = Y + 1
100 FLIP
110 GOTO 40

>RUN
[Game runs with sprite controlled by arrow keys]

>SAVE "GAME.B8"
>EXPORT "GAME.HTML"
[Creates playable web version]

Implementation Hints:

Console specifications to define:

Display:
  - Resolution: 128x128 (or similar small size)
  - Colors: 16 color fixed palette
  - Sprites: 256 8x8 sprites
  - Tilemap: Background tiles

Audio:
  - Channels: 4 simultaneous
  - Waveforms: Square, Triangle, Sawtooth, Noise
  - Notes: Predefined sound effects

Input:
  - D-pad: UP, DOWN, LEFT, RIGHT
  - Buttons: A, B
  - (Optional: Mouse)

Memory:
  - Code: 8KB limit (encourages tight code)
  - Sprites: 8KB (256 sprites × 32 bytes)
  - Map: 8KB (128×64 tiles)
  - Sound: 4KB

New commands for fantasy console:

CLS                     ' Clear screen
SPR n, x, y             ' Draw sprite n at x,y
SGET x, y               ' Get pixel color
SSET x, y, c            ' Set pixel color
MAP x, y, w, h, sx, sy  ' Draw tilemap
BTN(n)                  ' Check button
FLIP                    ' Update screen
SFX n                   ' Play sound effect
MUSIC n                 ' Play music pattern

Development tools needed:

  1. Sprite editor (8x8 pixel editor)
  2. Map editor (place tiles)
  3. Sound editor (simple tracker)
  4. Code editor with syntax highlighting

Learning milestones:

  1. Define specifications → Fixed platform design
  2. Graphics system works → Sprites and tiles
  3. Sound system works → Basic audio
  4. Complete games → Run full games on platform

Project 15: Cross-Platform BASIC Modernization

  • File: LEARN_BASIC_PROGRAMMING_DEEP_DIVE.md
  • Main Programming Language: Python or JavaScript
  • Alternative Programming Languages: Go, Rust
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: 4. The “Open Core” Infrastructure
  • Difficulty: Level 5: Master
  • Knowledge Area: Language Implementation / Modern Platform
  • Software or Tool: Your complete implementation
  • Main Book: “Crafting Interpreters” by Robert Nystrom

What you’ll build: A complete, modern BASIC implementation that runs on web, desktop, and mobile, with a package system and modern features.

Why it teaches BASIC: This capstone project combines everything: language design, implementation, and creating a usable product that honors BASIC’s philosophy of accessibility.

Core challenges you’ll face:

  • Cross-platform runtime → maps to web, desktop, mobile targets
  • Modern features → maps to modules, types, closures (optional)
  • Package ecosystem → maps to sharing and reusing code
  • Documentation and community → maps to making it usable

Resources for key challenges:

  • “Crafting Interpreters” - Complete reference
  • Emscripten for web compilation
  • Cross-platform UI frameworks

Key Concepts:

  • Cross-compilation: One codebase, multiple targets
  • Module systems: Code organization and sharing
  • Developer experience: Making the language pleasant

Difficulty: Master Time estimate: 2-3 months Prerequisites: All previous projects

Real world outcome:

MODERN-BASIC v1.0
=================
Now running on: Web Browser
Available platforms: Web, Windows, macOS, Linux, iOS, Android

$ modern-basic repl
MODERN-BASIC Interactive
> IMPORT graphics
> SCREEN 800, 600
> PRINT "Hello, Modern World!"

$ modern-basic run game.mb
[Runs game]

$ modern-basic publish game.mb
Publishing to modern-basic.io...
Published! Share at: https://modern-basic.io/yourname/game

$ modern-basic build game.mb --target web
Building for web...
Created: dist/game.html
Open in browser to play!

$ modern-basic build game.mb --target windows
Building for Windows...
Created: dist/game.exe

Example modern BASIC program:

' MODERN-BASIC: Keeps the spirit, adds the power

IMPORT graphics
IMPORT sound
IMPORT net

' Type definitions (optional, for safety)
TYPE Player
    name AS STRING
    x, y AS NUMBER
    score AS NUMBER
END TYPE

' Module-level code
DIM player AS Player
player.name = "Hero"
player.x = 100
player.y = 100
player.score = 0

' Procedures with parameters and local variables
SUB UpdatePlayer(p AS Player, dx AS NUMBER, dy AS NUMBER)
    p.x = p.x + dx
    p.y = p.y + dy
END SUB

' Functions return values
FUNCTION Distance(x1, y1, x2, y2) AS NUMBER
    RETURN SQR((x2-x1)^2 + (y2-y1)^2)
END FUNCTION

' Main game loop - still readable!
SCREEN 800, 600, "My Game"
DO
    CLS
    
    IF KEYDOWN("LEFT") THEN UpdatePlayer(player, -5, 0)
    IF KEYDOWN("RIGHT") THEN UpdatePlayer(player, 5, 0)
    
    SPRITE 0, player.x, player.y
    PRINT AT 10, 10, "SCORE: "; player.score
    
    FLIP
    WAIT 16  ' ~60 FPS
LOOP UNTIL KEYDOWN("ESCAPE")

Implementation Hints:

Architecture for cross-platform:

modern-basic/
├── core/
│   ├── lexer.py       # Tokenization
│   ├── parser.py      # AST generation
│   ├── analyzer.py    # Type checking (optional)
│   └── interpreter.py # Execution
├── stdlib/
│   ├── graphics.py    # Graphics module
│   ├── sound.py       # Audio module
│   ├── net.py         # Networking
│   └── math.py        # Math functions
├── backends/
│   ├── python/        # Python runtime
│   ├── js/            # JavaScript (web)
│   └── native/        # Compiled (optional)
├── tools/
│   ├── repl.py        # Interactive mode
│   ├── cli.py         # Command-line interface
│   └── packager.py    # Build tool
└── docs/
    ├── tutorial.md
    └── reference.md

Module system design:

' math.mb - Standard library module
EXPORT FUNCTION Factorial(n)
    IF n <= 1 THEN RETURN 1
    RETURN n * Factorial(n - 1)
END FUNCTION

EXPORT FUNCTION Fibonacci(n)
    IF n <= 1 THEN RETURN n
    RETURN Fibonacci(n-1) + Fibonacci(n-2)
END FUNCTION

' user_program.mb
IMPORT math

PRINT math.Factorial(10)  ' or just Factorial(10) with USE

Key design decisions:

  1. Keep BASIC’s immediate feedback (REPL)
  2. Add optional types for large programs
  3. Modern error messages (point to code)
  4. Seamless graphics/sound
  5. Easy sharing and publishing

Learning milestones:

  1. Core language complete → All BASIC features
  2. Standard library → Graphics, sound, etc.
  3. Multiple targets → Web and desktop work
  4. Package system → Share code easily
  5. Community → Documentation, examples, tutorials

Project Comparison Table

# Project Difficulty Time Key Skill Fun
1 BASIC Time Machine 3-5 days History ⭐⭐⭐
2 Microsoft BASIC Explorer 1 week Retro ⭐⭐⭐⭐
3 Text Adventure Game ⭐⭐ 2 weeks Game Design ⭐⭐⭐⭐⭐
4 Graphical Game ⭐⭐ 2-3 weeks Graphics ⭐⭐⭐⭐⭐
5 BASIC Tokenizer ⭐⭐ 1 week Parsing ⭐⭐⭐
6 BASIC Parser ⭐⭐⭐ 2 weeks Compilers ⭐⭐⭐
7 BASIC Interpreter ⭐⭐⭐ 3-4 weeks Interpreters ⭐⭐⭐⭐
8 Interactive Environment ⭐⭐⭐ 1-2 weeks Dev Tools ⭐⭐⭐⭐
9 QBasic/FreeBASIC ⭐⭐ 2 weeks Structured ⭐⭐⭐⭐
10 BBC BASIC Deep Dive ⭐⭐ 2 weeks Systems ⭐⭐⭐⭐
11 BASIC Compiler ⭐⭐⭐⭐ 3-4 weeks Code Gen ⭐⭐⭐⭐
12 Language Extensions ⭐⭐⭐ 2-3 weeks Design ⭐⭐⭐⭐
13 Visual Basic Archaeology ⭐⭐ 2 weeks RAD ⭐⭐⭐
14 Fantasy Console ⭐⭐⭐⭐ 4-6 weeks Platform ⭐⭐⭐⭐⭐
15 Modern BASIC ⭐⭐⭐⭐⭐ 2-3 months Everything ⭐⭐⭐⭐⭐

Phase 1: Historical Foundation (1-2 weeks)

Understand where BASIC came from:

  1. Project 1: BASIC Time Machine - Original Dartmouth BASIC
  2. Project 2: Microsoft BASIC Explorer - 8-bit era

Phase 2: BASIC Programming (3-4 weeks)

Write real programs in BASIC:

  1. Project 3: Text Adventure Game - Classic application
  2. Project 4: Graphical Game - Push the limits
  3. Project 9: QBasic/FreeBASIC - Structured BASIC
  4. Project 10: BBC BASIC - Best of BASIC

Phase 3: Build Your Interpreter (6-8 weeks)

Understand BASIC from the inside:

  1. Project 5: BASIC Tokenizer - Lexical analysis
  2. Project 6: BASIC Parser - Syntax analysis
  3. Project 7: BASIC Interpreter - Execution
  4. Project 8: Interactive Environment - Complete REPL

Phase 4: Advanced Topics (4-6 weeks)

Extend and modernize:

  1. Project 11: BASIC Compiler - Code generation
  2. Project 12: Language Extensions - Add features
  3. Project 13: Visual Basic Archaeology - Event-driven

Phase 5: Mastery (2-4 months)

Create something new:

  1. Project 14: Fantasy Console - Custom platform
  2. Project 15: Modern BASIC - Capstone project

Summary

# Project Main Language
1 BASIC Time Machine (Historical) BASIC (Dartmouth)
2 Microsoft BASIC Explorer BASIC (C64/Apple)
3 Text Adventure Game Any BASIC
4 Graphical Game C64 BASIC / BBC BASIC
5 BASIC Tokenizer Python
6 BASIC Parser Python
7 BASIC Interpreter Python
8 Interactive Environment Python
9 QBasic/FreeBASIC Development FreeBASIC / QB64
10 BBC BASIC Deep Dive BBC BASIC
11 BASIC Compiler Python → C
12 Language Extensions Python
13 Visual Basic Archaeology VB.NET / Gambas
14 Fantasy Console Python + BASIC
15 Modern BASIC Implementation Python / JavaScript

Resources

Essential Books

  • “Back to BASIC” by John Kemeny and Thomas Kurtz - From the creators
  • “Crafting Interpreters” by Robert Nystrom - Best interpreter guide (free online)
  • “BASIC Computer Games” by David Ahl - Classic game collection
  • “Commodore 64 Programmer’s Reference Guide” - C64 BASIC bible
  • “BBC Microcomputer User Guide” - BBC BASIC reference

Tools and Emulators

  • VICE: https://vice-emu.sourceforge.io/ - Commodore emulators
  • AppleWin: https://github.com/AppleWin/AppleWin - Apple II emulator
  • BeebEm: http://www.mkw.me.uk/beebem/ - BBC Micro emulator
  • QB64: https://qb64phoenix.com/ - Modern QBasic
  • FreeBASIC: https://www.freebasic.net/ - Modern BASIC compiler
  • BBC BASIC for SDL: https://www.bbcbasic.co.uk/bbcsdl/ - Cross-platform BBC BASIC

Online Resources

Historical Archives


Total Estimated Time: 6-12 months of exploration

After completion: You’ll understand programming language design, interpreter construction, and retrocomputing. You’ll appreciate why BASIC was revolutionary and how its ideas live on in Python, JavaScript, and modern languages. You’ll be able to write programs on vintage systems, build your own interpreters, and perhaps create the next great accessible programming environment.

BASIC’s philosophy—that programming should be accessible to everyone—remains as important today as it was in 1964. These projects will help you understand and carry forward that legacy.