DEV Community


Posted on

Is MiniScript a dialect of BASIC?

I've recently been working on converting 100 classic BASIC computer games to MiniScript. Also, I continue to work periodically on refining MiniBASIC. All this has led me to hang out with some other BASIC enthusiasts in a Facebook group, and I got asked the question: is MiniScript a dialect of BASIC?

It's an interesting question. The MiniScript language is a clean-sheet design, not intended to derive or extend any particular previous language. But it certainly drew inspiration from various languages, including REALbasic (where I was chief engineer for a number of years). In my "Why MiniScript?" post, I called out Python, Lua, REALbasic, and C# as particular examples (though I drew from other languages too -- anybody remember MOO?).

So. Does this make MiniScript a BASIC language or not? I guess it depends on what you consider to be the defining characteristics of a modern BASIC. Let's argue it both ways.


Modern BASICs (like Xojo, Visual Basic, etc.) have outgrown line numbers and GOTO, instead using flow control based on keywords. These include if-then, generally terminated with end if. And that is exactly what MiniScript does too.

if 2+2 == 4 then
    print "math works!"
else if pi > 3 then
    print "pi is tasty"
else if "a" < "b" then
    print "I can sort"
    print "last chance"
end if
Enter fullscreen mode Exit fullscreen mode

The same applies to while loops, though some BASICs use wend, MiniScript uses a more consistent end while.

s = "Spam"
while s.len < 50
    s = s + ", spam"
end while
print s + " and spam!"
Enter fullscreen mode Exit fullscreen mode

Also like modern BASICs, a subroutine call can be made without parentheses, enabling a PRINT statement that looks almost exactly like BASICs of yore (see listings above).

More generally, BASIC — true to its name (Beginner's All-purpose Symbolic Instruction Code) — is known for being simple and easy to pick up, with very little extraneous syntax and punctuation. MiniScript has that same quality. So in this abstract (and admittedly subjective) sense, at least, MiniScript is true to the spirit of BASIC.

BASIC It Ain't

BASIC languages, to my knowledge, have always been statically typed. Even in old-school BASIC, while you don't need to declare your variables, they are typed by their very names: X is a number while X$ is a string, and X$() is an array of strings.

MiniScript, on the other hand, is dynamically typed. X could be any value, and it can even change from one type to another over the course of the program, like in this snippet where inp starts out a string (the result of input), and morphs into a number.

inp = input("Enter a number (or hit return for 42: ")
if inp == "" then
   inp = 42
   inp = inp.val
end if
Enter fullscreen mode Exit fullscreen mode

Next, let's consider core datatypes. Modern BASICS generally have core types of string, integer, float, and arrays of same. MiniScript's core types are string, number, list, and map. This set of four core types, it turns out, is really important to the character of a modern scripting language. Lists and maps can easily substitute for almost any common data structure: arrays, queues, stacks, sets, even classes and objects. Modern BASICs work quite differently; they have statically-declared container classes and such, more similar to something like C# than to MiniScript.

So in these ways, MiniScript is much more Python than BASIC.


So, is MiniScript a variant of BASIC or not? I guess that is in the eye of the beholder. I can tell you that when porting those 100 BASIC computer games, in many cases, the old BASIC code translated directly into MiniScript with no fuss. But at other times — mainly when the original code was a mess of GOTOs and THEN-jumps — it was a royal pain.

If you're coming from a BASIC background, but looking for a simple, quick scripting language where you can just hack around without declaring variables and data structures ahead of time, I think you'll feel right at home in MiniScript. And perhaps that's all that matters!

Top comments (0)