When scripting languages shrink



Javascript, Python, Ruby: these are the popular dynamic languages in 2019. Naturally, people want to use them not just for app development but also to script software written in C or the like. Problem is, the official implementations of all these languages have grown rather large (even Tcl isn't small anymore), and that makes them tricky to use for such a purpose. Only Lua has stayed as lean as always, but no matter how good it is, having a choice is always the better idea.

Intreprid programmers have set out to correct this situation however, and nowadays we can enjoy tiny alternative scripting engines for several of these languages.

Duktape is a JS interpreter consisting of one C file and its header. It can be used as such, or customized to include or omit certain features. By default it builds to an executable around 200-300K in size (I seem to have deleted my copy in the mean time). The official website lists a number of reputable projects that use it, and half a dozen alternatives!

MicroPython is an interpreter for the eponymous language designed to run directly on single-board computers, but also on popular operating systems, and even web browsers. It aims to be largely compatible at the language level, though the standard library sports many differences, for obvious reasons.

Jim Tcl is a surprisingly complete Tcl implementation, including a couple of extensions not even the official interpreter supports. It also has a compatibility layer to cover what differences exist, and enjoys a good reputation.

TinyScheme is no less than the scripting engine used in GIMP! It can be easily built to a stand-alone executable 170K in size, and claims to implement a good chunk of R5RS, the last version of the language that cared about minimalism. Hasn't been updated since 2013 unfortunately.

As you've probably noticed, I only played with a couple of the above, briefly. What all of them have in common is being implemented in C; native scripting engines for other compiled languages are much less common, except in the Java and C# world. Honorable mentions for a few others:

  • LIL, another miniature Tcl-like;
  • MuJS, another small JS that even has a DOS port;
  • MRuby might be interesting to fans of that language.

There are of course many others, for original and/or less known languages, but you don't need to go entirely off the beaten path to keep your software small and light on dependencies. So give a chance to one of the above next time.


Tags: programming, links