The project can be found here: https://github.com/jabbalaci/nimbang . This repo is a fork of PMunch/nimcr, containing some of my own modifications. Thanks to PMunch for the original nimcr project!
How does it differ from nimcr?
Let's see an example:
$ cat hello.nim
#!/usr/bin/env nimbang
echo "hello nimbang"
$ chmod u+x hello.nim
$ ./hello.nim
# nim c --colors:on --nimcache:/home/jabba/.cache/nimbang/nimcache-99B454C0298D5236 --out:"/home/jabba/.cache/nimbang/nimcache-99B454C0298D5236/.hello" "/tmp/send/hello.nim"
hello nimbang
$ ./hello.nim
hello nimbang
By default, nimbang compiles in debug mode. This is faster than compiling in release mode, thus during the development it allows a faster iteration.
Under Linux, nimcr created the nimcache directory in /tmp. However, when you reboot a Linux machine, the content of /tmp is deleted. If you use lots of scripts, after a reboot you must wait a lot of time until they re-compile upon their first usage.
nimbang creates the nimcache directory in your HOME directory, in ~/.cache/nimbang/.... The compiled executables are also stored here, so the folder that contains your script won't be littered with a hidden EXE file. And, the EXEs will survive a reboot. After a reboot the scripts don't have to be recompiled.
If your script is finished, you can switch to release mode. Just add an extra line after the shebang line:
$ cat hello.nim
#!/usr/bin/env nimbang
#nimbang-args c -d:release
echo "hello nimbang"
$ ./hello.nim
# nim c -d:release --colors:on --nimcache:/home/jabba/.cache/nimbang/nimcache-99B454C0298D5236 --out:"/home/jabba/.cache/nimbang/nimcache-99B454C0298D5236/.hello" "/tmp/send/hello.nim"
hello nimbang
$ ./hello.nim
hello nimbang
I've decided to show a debug line when the script is compiled. This way you can check how exactly the nim compiler is invoked. As you can see, -d:release is applied this time.
Why to use nimbang when we have `nim r` ?
The nim compiler can do something similar. The command nim r prg.nim does the following: it compiles a program if necessary and then it launches the binary. However, if the binary is in the cache and the source hasn't changed, it simply launches the binary.
However, according to my experience, nim r launches an already-compiled EXE quite slowly.
Example:
$ time nim r --hints:off --warnings:off hello.nim
308 msec (compile time + launch)
$ time nim r --hints:off --warnings:off hello.nim
102 msec (nothing changed => no compilation, just launch)
Let's compare it with nimbang:
$ ./hello.nim
258 msec (compile time + launch)
$ ./hello.nim
8 msec (nothing changed => no compilation, just launch)
I had a question about it in the forum too (link).
Feedbacks are appreciated. The project is not yet in the Nim Package Directory.