MiniScript 1.6 Now Available
Tags: miniscript, commandline, programming, news
Published: 2023-02-06 21:39:57

Today is the official release of MiniScript version 1.6!  This is the first official update in slightly more than a year, and brings some great new features, as well as a good set of fixes and other improvements.

You can read the [full release notes](https://miniscript.org/files/MiniScript-Release-Notes.txt) for details, but here are the highlights.

## New Features

#### Math-Assignment Operators

After [much careful deliberation](https://luminaryapps.com/blog/math-assign-ops/index.html) and consultation with the community, it was decided to add **math-assignment operators** to the language.  That means you can now do things like:

`x += 42`

to add 42 to `x`.  This is a small but significant quality-of-life improvement, especially when your variable names are not as short as `x`, but something like `shipVelocityX`.  In such cases, the math-assignment syntax is not only easier to type correctly, but faster and easier to read and understand as well.

#### Better `print`

Then, there's a refinement to the `print` intrinsic.  It now takes an optional second argument, which is what should be used as the delimiter after the first argument is printed.  By default this is a line break, so `print "Hello"` continues to work as it always has.  But now you can specify something else — such as an empty string — allowing you to suppress or replace the line break:

```
print "Hello ", ""    // no line break here!
print "World!"
```

This now prints "Hello world!" all on one line, even though it was two different lines of code.  This particular example is trivial and pointless, but it's surprisingly common to need to do something like this in real-world code.  Before, that could be done in [Mini Micro](https://miniscript.org/MiniMicro/) by monkeying with [`text.delimiter`](https://miniscript.org/wiki/TextDisplay.delimiter), but it couldn't be done in most other environments at all.  Now it's easier, and universal!

#### New Intrinsics

Finally, a couple new standard intrinsic functions have been added.  The first, `refEquals`, allows you to compare two maps or lists to see if they refer to the exact same object, rather than two different objects that happen to contain the same data.  This isn't often needed, but if you need it you _really_ need it, and until now there was no good solution.

The other is `stackTrace`, which gives you a peek at the call stack to the current line (or in some environments, the line at which the program stopped).  This is mainly handy for debugging.  It was a feature in Mini Micro before, but now it's standard, because it's something you are likely to want anywhere you're writing some nontrivial MiniScript program.

#### Other Improvements

Error messages have been improved in several cases, such as the common mistake of using `=` instead of `==` in an `if` statement.  (The error now says "found = instead of == in if condition".)

Finally, ten or so obscure bugs have been fixed, from the relatively harmless (`else if(x)` would fail unless you put a space after the `if` — though in this case you should probably remove the spurious parentheses anyway), to the potentially severe (a reference loop in the `__isa` chain could cause your script to go into an infinite loop).

## Where to Find MiniScript 1.6

The [Try-It! page](https://miniscript.org/tryit/) has been updated, and is the quickest way to see the latest and greatest MiniScript in action.

If you are a [command-line MiniScript](https://miniscript.org/cmdline/) user, that too has been updated (and comes with some big improvements of its own, such as support for [`import`](https://miniscript.org/wiki/Import) and a whole collection of standard import modules!).  So I would definitely recommend downloading and installing the latest.

In addition, of course, you can just [download the source from GitHub,](https://github.com/JoeStrout/miniscript) to build it yourself or incorporate it into your own projects.

**Coming Soon:**

- an update to the [Unity Asset](https://assetstore.unity.com/packages/tools/integration/miniscript-87926), which hasn't been updated in far too long

- version 1.2 of [Mini Micro](https://miniscript.org/MiniMicro/), which will incorporate MiniScript 1.6 along with a bunch of improvements of its own

Follow me here or on [Mastodon](https://noc.social/@miniscript) to be sure you hear the news!

## Upgrade Notes

If you're using MiniScript in your own C# or C++ apps, you will have to make one change: the text output callbacks which previously took just a String parameter, now take an additional parameter, `bool addLineBreak`.  This should control whether or not the host app should append a line break after printing the given string, and is needed to support the nifty new `print` feature that lets users easily replace the standard line break with something else (or nothing at all).

## Conclusion

I couldn't be more happy to be getting these improvements out the door and into the hands of the users.  And with this done, it's going to be a very exciting year of related goodies, like the big Mini Micro upgrade (with some very cool new demos), and a secret project I'm calling _MiniBASIC_.  Stay tuned!