Basic forever

Basic on the WWW

Web browsers are great at showing off text, images and even multimedia. It's much more clunky to make them showcase running code, despite their scripting support; Javascript requires quite a bit of scaffolding to actually put much of anything on screen. That's nowhere near as casual as we were once promised.

Google's answer to that is wwwBasic: an interpreter for the classic programming language in a single 100KB file, that can be included in a web page to turn it into a good old Basic runtime, complete with emulated graphics screen, but also mouse and touch support. No, really, hello, world looks like this:

<!DOCTYPE html>
<meta charset="utf-8">
<title>Hello, world!</title>
<script src="wwwbasic.js"></script>
<script type="text/basic">
print "Hello World!"

Official examples include more advanced embedding options (also look at the Basic Anywhere Machine!) but it's probably easier to just use an iframe, like this:

More notes: wwwBasic is open source under the Apache License 2.0, but poorly documented as of August 2023. On the plus side, it consists of just over 3500 lines of readable Javascript code. The language is very similar to QBasic at first sight, and as it compiles to JS, performance should be good. Not so much accessibility, because it renders to a canvas element, but it can't be helped. Error messages aren't great either.

Survival guide

See also: my wwwBasic cheat sheet.

Basic Anywhere Machine

It's not very convenient to edit your source code without syntax highlighting, and with the line numbers way off in error messages. That's where the Basic Anywhere Machine steps in to fill the gap: a browser-based IDE and virtual computer of sorts built on the TiddlyWiki platform, that lives in a single web page and can also export each program to a stand-alone file that includes the runtime.

The BAM project also provides extensive reference documentation for wwwBasic, including numerous extensions. Bonus points for how well it resembles the QBasic of yore, except with 21st-century aesthetics.