Google released an elegant but incomplete open-source implementation of BASIC in 2018 and maintained it through 2022. The primary design goal was to run graphical QBASIC programs directly from the browser, without needing a machine-code emulator.

The easiest way to experiment with Google’s implementation is through this editor.

Unlike actual QBASIC, but like many browser-based implementations, you can’t STOP a program and can’t PRINT or change variables to speed your debugging. That’s because this implementation is not a traditional interpreter. Your BASIC program is translated to a series of JavaScript instructions, which are then executed.

The GitHub repository doesn’t document the language keywords that are supported. I should have started by reviewing the source code to see what keywords the language supported, but I enjoyed typing in BASIC programs and seeing if they would work. It took me back to the late 1970s and early 1980s, when every one of my friends had a different computer with its own version of BASIC.

The language supports a nice range of structured BASIC keywords and constructs, including defined subroutines, functions, and types.

The source code does have a long list of remaining to-do items marked in comments, though most programs won’t need these. Some highlights:

  • No support for error handling; e.g., ON ERROR GOTO and RESUME (NEXT).
  • No audio support.
  • Little mouse support (GETMOUSE).
  • No file handling.
  • No memory map (PEEK/POKE, DEF SEG).
  • No STATIC variables. REDIM is not supported and array subscripts are not checked for out-of-bound errors.
  • Color differences from CGA, EGA, VGA modes.
  • Incomplete support for the DRAW command. The POINT() function always returns false.

Error messages are often off by a single line number, typically pointing to the line before as the source of the error. The parser can be finicky: you have to use ELSEIF as one word or it won’t work, for instance; keywords often need to be delimited by a space.

So… what’s this good for?

  • For converting graphical BASIC programs that aren’t too complex into web pages, like DONKEY.BAS (play it here).
  • Lacking vertical scrolling, the implementation is less useful for the classic text-interface BASIC games I grew up on. Instead of scrolling, when text would go off the screen, the program just starts printing at the top of the screen, without clearing anything.
  • The web UI is suitable for writing short, simple structured BASIC programs (most of the other browser-based BASICs rely on line numbers).
  • With its elegant architecture, this may be useful for hacking your own browser-based BASIC, perhaps emulating your favorite dialect of microcomputer BASIC from the late 1970s or early 1980s.

I had hoped you could embed BASIC progams into blog posts, but I could not get that to work in WordPress. For the example below, it’s just an embedded web page.

Charlie Veniot has created a robust fork of the language for TiddlyWiki, addressing many of the issues raised above, called the BASIC Anywhere Machine. Check it out! [Thanks to Charlie for pointing out some other issues with wwwBASIC.]

Embedded web page: