It says something about what a thoughtful development environment these early BASICs were, that you could make a full simple little game like this in only 131 lines even though they're ostensibly far less powerful than modern languages. I'm not sure if you could even get an SDL window open and game loop running in 131 lines of (non-golfed) C.
Never mind how compact, beginner-friendly, and just plain fun they were to use. It's been said countless times but I'll say it again - we've lost something over the years.
>I'm not sure if you could even get an SDL window open and game loop running in 131 lines of (non-golfed) C.
The basics (window, events, renderer) can be done in about 30 lines:
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
static SDL_Window* window;
static SDL_Renderer* renderer;
int main(int argc, char* argv) {
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_GAMEPAD);
SDL_CreateWindowAndRenderer("test", 640, 480, SDL_WINDOW_RESIZABLE, &window, &renderer);
SDL_Event event;
while(true) {
while(SDL_PollEvent(&event) != 0) {
if (event.type == SDL_EVENT_QUIT) {
goto ENDGAME;
}
//events go here
}
// update here
SDL_SetRenderDrawColor(renderer,0,0,0,255);
SDL_RenderClear(renderer);
// render here
SDL_RenderPresent(renderer);
}
ENDGAME:
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
}
I don't think you could get all of donkey.bas done in 131 lines, though. SDL3 does ship with an embedded debug font but that seems like cheating. You probably couldn't replicate the drawing code easily, it would probably need to be faked with images, and you'd need a font atlas for the text.raylib might do it in less lines. SDL is designed as a cross platform base layer to wrap in another framework not as something you should be using directly.
It was really cool! The ease of getting started was definitely one of the selling points for the “home computers” of that era (GW-BASIC ran on IBM compatible PCs instead, but the appeal of BASIC was the same). Brevity was an important feature since a lot of people obtained programs by typing them over from a magazine or recording them from the radio. And of course, there was no such thing as auto-complete (let alone AI generation).
That being said, SDL isn't actually that bad either. A minimal example is about 40 lines of code [1], not counting comments and blank lines, but including lines with just a curly brace which you could easily remove if you were concerned about size. A slightly more serious implementation of Snake runs about 345 lines of code [2].
And to be fair, DONKEY.BAS is also cheating slightly on the line metric by stuffing lines full of statements, like for example:
A$=INKEY$:IF A$=CHR$(27) THEN 1298 ELSE POKE 106,0:IF LEN(A$)>0 THEN LINE (CX,CY)-(CX+28,CY+44),0,BF:CX=252-CX:PUT (CX,CY),CAR%,PRESET:SOUND 200,1
1. https://examples.libsdl.org/SDL3/renderer/01-clear/
2. https://examples.libsdl.org/SDL3/demo/01-snake/Python is the modern Basic replacement, and also has similar fundamental design trade-offs. VB6 was the peak of the OLE/Multimedia paradigm, and was functionally replaced by the web browser script sandbox.
> we've lost something over the years.
Indeed, Information Appliances were never general-purpose computers. Some people used to care about that sort of thing, and left civilization the GNU compilers as one of the most important intellectual artifacts of our generation. =3
131 lines and about 10% of them are the title/copyright banner. Genuinely impressive in it's terseness