Shovel - a bytecode virtual machine that is embeddable, secure and interruptible
Shovel is a bytecode virtual machine (VM) that allows programs written for it to be:
- embeddable - Shovel is implemented as a library, it can be loaded and used by your program;
- secure/sandboxed - Shovel processes can only perform the operations you explicitly allow and the CPU/RAM usage of the process can be bound by soft limits;
- and interruptible - a Shovel process can be stopped, saved to a database and resumed later, possibly on another machine.
Have you ever needed to make RPC calls in an unspecified sequence and wanted them to be executed transactionally (all or none), but you didn't want to (or couldn't) use distributed transactions? Maybe you wanted to replace a long sequence of 'tiny' RPC calls with just one 'large' call? Shovel is great in this case.
Maybe you like continuation-based web frameworks, but would like to be able to stop the server and restart it without losing the continuations? Or maybe use load-balancing and run the continuation on a different machine? Shovel can help you design such a web framework.
More generally, have you ever needed to associate a 'program' with a 'business object', but needed the 'process' generated from that 'program' to be actually running for only a small fraction of its lifetime and to spend the rest of the time tucked away in a database somewhere (thus freeing memory and threads for more urgent needs)? Software for document management, bug tracking, task tracking etc. needs such an approach - and the 'programs' mentioned may become real programs by using Shovel (instead of being hopelessly complected with the rest of the application).
The code generator and Shovel VM are modeled after the Scheme compiler from Peter Norvig's Paradigms of Artificial Intelligence Programming book (chapter 23). Thank you, Peter Norvig! (I hope I haven't broken your code beyond recognition, any bugs in the Shovel code generator and VM are obviously my bugs and my fault)