One day I was thinking about a simple task: make a script-like program with proper CLI and pack it into a standalone executable. There was no particular need in the program itself, I just wanted to research as many ways to do it as possible β am I a language geek or not? π
Here I'm collecting examples made using stacks I tried so far. Below will be a complete list.
But first let's see the task's conditions.
- Each program should be standalone, i.e. "download and run". Ideally, a single binary executable. Here I'm testing the packaging.
- Each program should have a rich Command Line Interface with inline help & stuff. Here I'm testing the expressiveness of CLI-building libs/DSLs.
- Each program should be able to call external programs and let me write such code easily. Here I'm testing the expressiveness of shell-scripting capabilities.
Each program expects a single argument β string prefix. Then it should run the pipeline grep ^PREFIX /usr/share/dict/words | wc -l that will count each word int dictionary that starts with the prefix. Yes, I usually can do such calculations programmatically. But I want to be able to compose existing tools and wish to do it in a way as much close to bash/zsh/sh, as it possible in each language stack.
| Language | Executable size | Stripped | S | C | E |
|---|---|---|---|---|---|
| Python | 10 MB π«€ | breaks | π«€ | π | π |
| Rust | 1.1 MB |
908 KB | π | π | π |
| Haskell | 4.2 MB π«£ | 3.1 MB | π | π | π |
| Racket | 56 MB π | 55 MB | π | π | π |
| Kotlin/Native | 2.6 MB π | 1.9 MB | π | π | π |
| Swift | 1.5 MB |
808 KB | π | π | π |
| Scala/GraalVM | 14 MB π«€ | 14 MB | π«€ | π | π |
| Bunster | 3.3 MB π | 3.2 MB | π | π | π |
| Crystal | 2.1 MB π | 1.4 MB | π | π | π«€ |
| C# | 2.9 MB π | 2.9 MB | π«€ | π | π |
| Odin | 555 KB π | 520 KB | π | π | π«€ |
Here
S) "standalone'ability" of packed programs C) richness of the CLI E) code expressiveness around the subprocess calls and piping
(all the sizes I checked on my machine that runs under the MacOS(amd64))
To be continued...