DEV Community

JoeStrout
JoeStrout

Posted on • Edited on

MiniScript Ports

Since its introduction in 2017, MiniScript's community has been steadily growing. And a delightful community it is — it spans the gamut from brand-new, never-coded-before beginners to experienced software engineers.

Some of those experienced community members have gone so far as to port or reimplement MiniScript in other languages and environments. Because of its minimal nature (see its one-page quick reference!), implementing an interpreter or bytecode compiler for MiniScript is a much more accessible task than for most other languages. Let's take a look at some of the ports currently available.

Official Reference Implementations

There are two official reference implementations of MiniScript: one in C#, and one in C++. Both are actively maintained, and available on GitHub.

Java and Kotlin

There are two MiniScript ports that run on the JVM (Java Virtual Machine). The first one was actually written for Kotlin, and is available here. It was last updated over 4 years ago, so it's probably a little out of date now, but would be an excellent starting point and probably wouldn't take much effort to refresh.

The other one is for standard Java, available here. It was last updated 2 years ago, so it's a bit newer but still not completely current. This might be an excellent launching point to adding MiniScript support to a Java-based game or app. (Minecraft mods leap to mind!)

MiniScript in MiniScript

Active community member Marc Gurevitx has recently published a project called ms.ms, a MiniScript interpreter written in MiniScript.

MiniScript in MiniScript?!?

While Marc is quick to warn you that the result runs slowly, in cases where you need something like this, that's not the point. Among other tricks, gives MiniScript an "eval" function — a way to evaluate an arbitrary snippet of MiniScript code stored in a string, from within your own MiniScript program.

(ms-ms is based on another of Marc's projects, peg-ms, which implements Parsing Expression Grammars. That's a topic that's dear to me as well — see my 2011 blog post extolling the virtues of PEG over regular expressions!)

MiniScript in TypeScript

Finally (for now!), another active community member Sebastian Nozzi (@sebnozzi) has been developing a MiniScript implementation in JavaScript — or more specifically, TypeScript (strongly-typed JavaScript). This enables MiniScript to run directly in a web browser! It's fast, too; on some code, the speed is comparable to command-line MiniScript or Mini Micro running on your local machine.

He's currently divided his work into two projects on GitHub: MiniScript.TS is the language core, while MiniScript-NodeJS adds Node.js support and a script-runner. The latter includes support for print and input, the import command, and a subset of the Mini Micro /sys disk.

The importance of this work cannot be overstated. Until now, the only way to run MiniScript code in a web browser was to send it to a back-end server running a command-line build (like our current Try-It! page, or to use the web version of Mini Micro, which is built in Unity and does not work well on mobile browsers. All that has changed! Now we can run MiniScript code directly in the browser, no need for a backend server. And Seb has already ported several of his old Mini Micro games, like Sliding Puzzle and Foggy Window, to use his MiniScript.TS engine rather than Mini Micro, enabling them to work fine even on mobile devices.

I'm already planning to work with Seb to reimplement the official MiniScript Try-It! page using his port, as well as the Robo-Reindeer Rumble game. Eventually, I expect to see an explosion of web-based apps and game development environments based on MiniScript and running happily within the browser. All thanks to the hard work @sebnozzi's been putting in on MiniScript.TS and related code!

Future Work

The official MiniScript discord server has a #ports channel, where anybody interested in porting MiniScript (or working with existing ports) can discuss. Projects that have been kicked around there include porting MiniScript to:

• Go
• Rust
• Lua
• pure C (sans C++)
• 6502 assembly
• WebAssembly
• compiler backends, like LLVM or Cranelift

It's exciting to see all this work going on! And remember, if you've ever wanted to find out what it's like to implement a language, MiniScript is a great choice — tiny enough to be relatively easy to implement, but powerful enough to be useful for real programs. And you'll have an entire community of enthusiastic users cheering you on!

Top comments (0)