Announcing MiniBASIC
Tags: beginners, programming, basic, minimicro
Published: 2023-02-26 23:41:42


I'm delighted to officially announce the release of **MiniBASIC**, a clean, powerful new implementation of the classic 1980s BASIC programming language.

MiniBASIC is [available at itch.io](https://joestrout.itch.io/minibasic) to use online, or to download for Windows, Mac, or Linux.  It's also completely open-source (hosted at [GitHub](https://github.com/JoeStrout/minibasic)).

![Spirograph Demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9qnoxf1y88b05ify5y68.png)

## A New Way to Program Mini Micro

MiniBASIC runs within [Mini Micro](https://miniscript.org/MiniMicro/), a powerful neo-retro virtual computer.  So there are now two languages you can use to write Mini Micro programs, its native [MiniScript](https://github.com/JoeStrout/miniscript.org/) language, or the new MiniBASIC.

This might be of interest if you already know BASIC, and want to quickly bang out a game or utility.  MiniBASIC provides a good set of high-resolution drawing commands, suitable for making plots, graphs, and diagrams.  It also has access to all the data on the [built-in /sys disk](https://github.com/JoeStrout/minimicro-sysdisk), including stock images, sounds, and a complete English word list!  And, being completely cross-platform, Mini Micro (and so MiniBASIC) runs identically on any desktop computer (and soon mobile devices, too).  So if BASIC is already in your wheelhouse, MiniBASIC offers a great way to take advantage of these Mini Micro features.

![Spirograph demo code listing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nb9ts1az253csh5sp3mp.png)

## An Extremely Compatible BASIC

MiniBASIC is the perfect way to recapture — or experience for the first time — the joy of programming in the world's first widely popular programming language.  BASIC was the subject of a great many books for kids of all ages, like these beautiful [Usborne BASIC programming books](https://usborne.com/us/books/computer-and-coding-books), or the influential books of [BASIC Computer Games](https://blog.codinghorror.com/updating-the-single-most-influential-book-of-the-basic-era/).

MiniBASIC was carefully designed to be widely compatible with  resources such as these.  Though BASIC was never fully standardized, MiniBASIC follows the most common conventions in loving detail.  Code from these classic books will work in MiniBASIC with little or no alteration.  For example, the 500-line program from [Mystery of Silver Mountain](https://drive.google.com/file/d/0Bxv0SsvibDMTZ0xkNW5Id3NLVVk/view?resourcekey=0-zd1AmVtIaboWogtXloOIxA) required only two minor changes, in the lines that open a file.  (This game is now one of the included demos).

## The BASIC Platform We All Dreamt Of

While being very compatible with 1980s BASIC, MiniBASIC is far more pleasant to use than any actual 1980s computer (in emulation or reality).  All the little bits of polish that didn't exist at the time are present: when typing you can hold Alt to move the cursor or delete by whole words; you can press control-A/E to move to the start/end of the line; you can use the up/down arrows to recall previous input from the history buffer.

MiniBASIC also includes a RENUMBER command, which takes most of the pain out of using line numbers by allowing you to easily move code around in your program; and an EDIT command, which lets you edit a line of code without having to retype it.

![Demonstration of the EDIT command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6ej070apr738z7f20pd.gif)

MiniBASIC's feature set is just a bit beyond the best of the 1980s home computer in other ways, too.  In terms of graphics, it features a full-color, high-resolution screen with a full set of drawing primitives including polygons and ellipses, both filled or outlined with variable pen size.  It can even draw JPEG or PNG images from disk.  And it supports a sophisticated sound synthesizer, similar to the Commodore 64, but with unlimited sound channels.  All this makes MiniBASIC a delightfully powerful BASIC environment and a joy to hack around in.

![Screen shot showing the standard color palette](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d031zice9qil8e62dtcp.png)

## Easily Extensible

The MiniBASIC interpreter is written in MiniScript, a clean, modern, high-level language.  The code is neatly organized, with one function for each BASIC command.  For example, here is the code underlying the RECT command:

```
Machine.cmd.RECT = function(tokens, startIdx, endIdx)
	if startIdx+1 >= endIdx then return printErr("incomplete RECT statement")
	args = getDrawingArgs(tokens, startIdx+1)
	if args == null then return printErr("syntax error in RECT")
	if args.len != 4 then return printErr("invalid arguments to RECT")
	x = [args[0], args[2]];	x.sort
	y = [args[1], args[3]]; y.sort
	if machine.fill then
		gfx.fillRect x[0], y[0], x[1] - x[0], y[1] - y[0]
	else
		gfx.drawRect x[0], y[0], x[1] - x[0], y[1] - y[0], gfx.color, machine.pen
	end if
	machine.plotPos = args[2:]
end function
```

This means that if you are working on a BASIC program, and find a need to do something MiniBASIC can't already do, you can easily extend the MiniBASIC interpreter to add your own feature.  You will find that MiniScript is a joy to program in, and the Mini Micro feature set is powerful and [easy to use](https://miniscript.org/files/MiniMicro-CheatSheet.pdf).

![Code listing for colors demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zzhwj172utchrl8sstmm.png)

## Try it now!

Why not give it a try?  Head on over to [MiniBASIC](https://joestrout.itch.io/minibasic), run the project, and then at the `>` prompt, type in this classic program you might have found running on the demo machines at K-Mart back in the day:

```
10 PRINT CHR$(47 + 45 *(RND(1) > 0.5)); : GOTO 10
```

Then, enter `run` to make it go.  (MiniBASIC is not case sensitive, so it doesn't matter how you capitalize these commands.)

This classic display is an infinite loop, so press Control-C when you want to stop it.

Note that the web version of MiniBASIC does not support copy/paste; nor can you save files to disk.  So you will probably want to download MiniBASIC to run on your local machine.  You'll find download links towards the bottom of the [web page](https://joestrout.itch.io/minibasic).

MiniBASIC is 100% free.  I do this because I grew up with BASIC; I loved it, and I still do, though I now do most of my coding in modern languages like MiniScript or C#.  There is still a ton of value in those great old BASIC books, and I want others to have a chance to experience the delight as I did.

So, enjoy MiniBASIC, and share it with your friends.  I hope it brings you joy!