Safe Scripting Syntax
I've already done a first pass of this with the dist.ribut.us VM but the idea fascinates me so I may try and do a more advanced version.
Being able to take arbitrary commands and execute them safely and bounded is interesting. The language should have no means to escape it's bounds. It should have base constructs that are guaranteed, language extension modules that can be provided by the environment and library modules.
I think the correct approach is a byte code. The lowest level is primitive but can be run fast.
A level up is a scripting language.
- Data structures
- associative array
- array
VM Safety
This is kind of the whole point, so it's important. Most critical is that the script is fully sandboxed - no access to disk or network and memory access is controlled.
Memory is use bounded. So is computation.
Simplicity
I would eventually like this implemented in many languages. For that reason, it should be easy to implement.
Assembly
The assembly starts by expressing the expected arguments and requesting memory. It then requests which language extensions and modules it needs.
I like the idea of memory pages, but it may make more sense to tag pages as read-only, read-write or execute.
At the assembly level commands are named and scoped
IaddVal $0, 100 foo.bar $0, 400, 3.1415
When compiling, these are reduced to bytes. Module commands are replaced with Calls. Language extensions add commands. The total number of commands is fixed, so that determines how many bytes a call requires.
Module Loading
There should be standard collections of packages. A server can quickly download an index. When a script requests that a module be included the server can go get it. The risk this avoids is being able to define arbitrary package names and having the runtime make a network request searching for that which becomes identifiable.
Scripting
- Data Structs
- array
- associative array
- base types
- signed int
- unsigned int
- byte
- 64bit float
- string
Script is strongly typed. Probably OO very similar to Go.
Operators
- if
- for : continue, break
- func : return
- exit
The exit operator causes the script to terminate. I think I'm going to leave it up the context to determine if the script was successful or not.
I'll write the compiler as a package and include a command line so it can be used anywhere.
Memoization
A detail, but interesting. The base language should be fully deterministic. Language extensions can set a non-deterministic bit. This way, we can run a deterministic script and record the starting state and the output and memoize the whole process.