Donkey.bas is 45 Years Old – 131 line of Glory
144 points by jkrauska 5 hours ago | 59 comments

vunderba 4 hours ago
Nice job. The sound effects are a bit too advanced because early IBM computers shipped with pretty simple, magnetically driven dynamic speakers.

On a related note, I’ve actually spent the last four months working on a 100% faithful adaptation of both QBasic and QuickBasic 4.5 that runs entirely in the browser on a virtual CPU and hardware abstraction layer. It’s a love letter to everyone who learned to program on Microsoft’s BASIC interpreters in the ’80s and early ’90s.

The best compliment I’ve received so far is from friends who grew up in the same era I did: when I fullscreen the browser, a few of them assumed it was a virtual machine running the real thing.

A QBasic port of the original BASIC-based DONKEY.BAS was one of the first programs I got running in it:

https://mordenstar.com/share/qbasic-core-demos

reply
HeyLaughingBoy 4 hours ago
At my first job, our entire order-entry and inventory management system was written in QBASIC. I wish I had the source to try it out with this.

I know someone who might, if we could figure out how to get it off a DOS 5.25" floppy!

reply
vunderba 2 hours ago
That’s awesome. If you ever end up getting a copy of it, I’d love to stress-test QBasic-Core against it since I built in a virtual hard drive to allow File I/O (PUT for random access, PRINT to file number, etc.)

I’ve got a fairly large collection of several hundred programs from the early to late ’90s that I’ve been carefully testing A/B testing against period accurate hardware and my simulator but actual professionally used QBASIC-based applications from back with the source intact are hard to come by.

reply
d3Xt3r 53 minutes ago
And for the slightly younger folks who have more memories of Visual Basic than QBasic, check out GAMBAS: https://gambaswiki.org/website/en/main.html
reply
vunderba 45 minutes ago
Loved Visual Basic! VB3 was probably my first experience as a kid to the idea of “threading” and UI-blocking operations.

Remember this?

  DoEvents
reply
d3Xt3r 21 minutes ago
I do remember DoEvents! Sadly it's not present in GAMBAS, but there's WAIT, which is kinda the same: https://gambaswiki.org/wiki/lang/wait
reply
mysterydip 3 hours ago
This is fantastic! As one of those kids who spent the early 90s in QBasic, thank you!
reply
mosburger 3 hours ago
aw neat I'd love to try doing this for its predecessor GWBASIC (my first programming language on the Tandy 1000EX)
reply
vunderba 2 hours ago
You absolutely should!

I’ve already sunk hundreds of hours into building out the fidelity of QuickBASIC (everything down to emulating memory access so you can simulate realistic PEEKing and POKEing), so I don’t have the sanity points left to tackle any other variants myself, but I’d love to see a GW-BASIC version.

reply
nfriend 4 hours ago
Brings back memories of GORILLA.BAS! https://en.wikipedia.org/wiki/Gorillas_(video_game)
reply
EvanAnderson 3 hours ago
I was more of a Nibbles[0] person. I played it with other people on my XT-class laptop in high school.

[0] https://en.wikipedia.org/wiki/Nibbles_(video_game)

reply
hdgvhicv 3 hours ago
I’ve got the music in my head just from seeing it written down. And the sound effect from gorrilla.
reply
vunderba 54 minutes ago
Yeah it's very iconic. It’s actually the same melodic motif that’s played in the intro of GORILLA.BAS and NIBBLES.BAS - it’s a short snippet from Tchaikovsky’s 1812 Overture.

Kind of reminds me of how most people don’t know “Korobeiniki” (Коробейники) by name, they just call it the Tetris song.

reply
EvanAnderson 45 minutes ago
I love the 1812 Overture, in part, because it has artillery.

"Oh, yes-- I play in the orchestra. I am in the auxiliary percussion and artillery sections."

reply
vunderba 42 minutes ago
Haha, symphonies with accompanying armaments really make you appreciate where you’re going to be seated as an audience member.
reply
TonyAlicea10 59 minutes ago
GORILLA.BAS got me into programming decades ago. I made an (admittedly partially vibe coded) homage this year: https://gameswithtony.com/gorillas/
reply
gxd 3 hours ago
For those who don't know why GORILLA.BAS is so cool... Back in the day, computers were expensive and games weren't readily available. Sometimes a parent would buy a computer for word processing or spreadsheets or take kids to the office which also had business computers. Children were curious about the computers but there wasn't really anything fun to do with them besides banging on the keyboard...

...Until you found the BASIC dialect that came with MS-DOS, that is! GORILLA.BAS was bundled with DOS and was a fun little game you could play in those computers. It's not like you could access web games on the Internet - there was no Internet!

reply
pavel_lishin 3 hours ago
It was also a very educational experience to start messing with the code until you broke it - forcing you to figure out how to fix it, to get your game back.
reply
vunderba 2 hours ago
Just as importantly - it was an all‑in‑one. I think a lot of people tend to forget that there were already plenty of earlier BASIC dialects (GW‑BASIC, Apple II BASIC, C64 BASIC, etc).

However QBASIC was likely the first freely available, all‑in‑one "batteries included" environment that came bundled with MS‑DOS 5 with a relatively friendly IDE that had built‑in help for every single command. GORILLA.BAS and NIBBLES.BAS were the gateway drugs for many future programmers.

reply
bluedino 2 hours ago
> Back in the day, computers were expensive and games weren't readily available.

You could get a PC for a thousand bucks back then, and shareware was a thing in 1990-91. Crystal Caves, Commander Keen, Duke Nukem were huge hits and there were tons of less popular games...not to mention copying commercial games from friends.

reply
gxd 29 minutes ago
> You could get a PC for a thousand bucks back then

In the United States... In a lot of countries, computers cost a lot more than that in the local currency which, together with lower salaries, made computers inaccessible to most people.

I remember seeing people playing GORILLA.BAS in computer stores...

reply
egypturnash 2 hours ago
$1k in 1990 ~= $2.5k today.
reply
QuercusMax 2 hours ago
Crystal Caves! I've been trying to remember the name of that game for ages! I never bought the full version but played the shareware endlessly...
reply
Arainach 39 minutes ago
There's a (presumably) excellent modern port of it a available on Steam: https://store.steampowered.com/app/1330890/Crystal_Caves_HD/

I say presumably because I played their excellent Secret Agent HD port but haven't played Crystal Caves yet.

reply
RankingMember 3 hours ago
GORILLA and NIBBLES!
reply
jimt1234 3 hours ago
We used to do quick tests of PC builds with GORILLA.BAS. It was later replaced by the 'Doom test'.
reply
marcuskaz 22 minutes ago
The game theory is all wrong, this is a cooperative game, either they both win or both lose. I don't see how the Donkey getting hit by a car should be classified as "Donkey wins"
reply
jamesdhutton 4 hours ago
For anyone unfamiliar with DONKEY.BAS: it’s notable for having been co-written by Bill Gates. More info on its history bere: https://en.wikipedia.org/wiki/DONKEY.BAS
reply
jkrauska 5 hours ago
Inspired by the 45th anniversary of the IBM PC, I got my slopmachine cracking on a port of DONKEY.BAS to work in a browser. Pretty happy with the result. As a young person I remember being fascinated that you could make a game like this with so little code.
reply
sedatk 3 hours ago
I once heard the rumor that DONKEY.BAS was the last piece of code Bill Gates wrote himself at Microsoft. I wonder if it's true.
reply
friarpuck 4 hours ago
Someone gave my grandfather a Games BASICA floppy that had this and other games on it. But this copy had a few games that had been "modified". I remember in DONKEY.BAS, it would curse at you if you hit the donkey. "YOU STUPID SONOFABITCH". We thought it was hilarious. My grandfather was less pleased. He took it away from us when he found out.
reply
syntheticnature 30 minutes ago
As a kid I modified DONKEY.BAS for my younger brother who wanted to play as a donkey avoiding cars. It was a clumsy modification, I didn't account for the differing size of the pseudo-sprites, but it made him happy.
reply
transitorykris 44 minutes ago
Modifying those games were the first times I ever touched code! There was one that existed somewhere between DOS 2.0 and 3.2 that simply asked your name, then asked how the hell you got that name. It was maybe half a dozen lines, but easy enough to modify output and learn a bit about variables.
reply
dmd 2 hours ago
I learned most of the best cursing I've ever done from my grandfather. He took pride in teaching his grandkids to curse.

He was involved in setting up the radar systems at Pearl Harbor, much good that did.

reply
atum47 3 hours ago
My perceptron can play this game, I think

https://github.com/victorqribeiro/carGamePerceptron

reply
flowofcontrol 4 hours ago
my car keeps hitting the donkey when switching lanes even though I'm already well past it..
reply
stronglikedan 4 hours ago
have you had anything to drink recently?
reply
pavel_lishin 5 hours ago
On my machine, it is flickering like _crazy_, as if it's trying to shift back and forth between two resolutions.

OSX, Firefox, browser size 3326×2830 pixels. Only happens at or around that particular size - resizing the window fixes the issue.

reply
jkrauska 4 hours ago
reply
pavel_lishin 4 hours ago
Also, on reflection, I think the firefox window size is half of what I reported - I'm not sure what OSX does to its screenshots, but using SHIFT-CTRL-CMD-3, it's reporting about half that size. Not sure if that makes a difference to your changes (likely not).
reply
buildsjets 2 hours ago
Clearly this needs to be replicated as GTA minigame.
reply
phront 3 hours ago
It turned out that Dino run has deep roots
reply
ChrisArchitect 4 hours ago
Related:

Happy 45th Birthday to the IBM PC and Model F/XT

https://news.ycombinator.com/item?id=49280103

reply
NDlurker 3 hours ago
Surprisingly fun!
reply
wk_end 4 hours ago
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.

reply
diegof79 30 minutes ago
What we lost is simplicity across the stack.

I learned to program with BASIC. It was awful. I didn’t know how awful it was until many years later. So I don’t miss the language. But something I miss is how easy it was to learn what your machine was doing.

The DOS boot and config involved only two files: CONFIG.SYS and AUTOEXEC.BAT, that was it. Most programs were self-contained, so you could copy the directory to a floppy disk and run them on another machine. If you broke something, copy the files again and restart; that was it… I “broke” config and programs many times, and it was a good way to learn.

reply
ligne 2 hours ago
131 lines and about 10% of them are the title/copyright banner. Genuinely impressive in it's terseness
reply
commandlinefan 2 hours ago
Nearly a quarter of it is checking for necessary prerequisites, too.
reply
tancop 4 hours ago
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.
reply
Joel_Mckay 3 hours ago
I usually recommend the inexperienced do at least 1 project in godot:

https://godotengine.org/

Then port it to UE if they are interested in skill reuse for future projects:

https://www.unrealengine.com/

SDL has a lot of issues, and falls into the "only if you must" category. Still better than .NET or Java in many ways, as spacial audio is easy in the mixer. =3

reply
krapp 2 hours ago
>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.
reply
sltkr 3 hours ago
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/
reply
Joel_Mckay 3 hours ago
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

reply
mempko 3 hours ago
This is what got me into programming. When I was a kid, I had a shitty 386 because my father got a computer second hand from a friend (we were poor). I was playing the game and then pressed a key and it took me to the basic editor. I was confused with what I saw and started changing things. I changed a number and the size of the explosion on the banana got bigger. My best friend at the time went to computer camp and explained to me that it was code. 30 years later I'm still programming.
reply
makapuf 5 minutes ago
WTF 386 was for me a sci-fi like device I wouldnt dare think about having when I was a kid. I had a very nice 8086 I cherished, with VGA video no less ! (Yes driving a vga card with a 8086 was slow..
reply
toolslive 3 hours ago
tangential: I still remember how disappointed I was in PCs being used to a C64 (which was released in 1982) The quality of the games & sound effects was just not on the same level (C64 being much more advanced)
reply
spwa4 4 hours ago
Ahhh I never saw donkey.bas, and only saw the Microsoft one. You know, when that company cared about being part of the industry, as opposed to being the entire industry, and really want to be 5 other industries to, as they do now.

Gorillas.bas (it's more or less like worms, except with only 1 gorilla per team)

On the plus side: it was much prettier.

reply
dec0dedab0de 4 hours ago
Donkey was for basica/gwbasic. Gorillas was for qbasic, like a decade later.
reply