SafeScript was just inspired by Google’s CaJa project from 10 years ago. My Qbix Webserver started rewriting PHP before loading it, and I wondered what if I could start over and just reduce the language the way JSON reduced it to just data, and was wildly successful. I chose JS as the base because it’s everywhere. I then made it also execute inside PHP. I made it auto-await every promise so it could work in non-evented environments like vanilla PHP.
This could be the next Lua, for instance, but for the modern era and far safer.
Having said that… there may be some static analysis you could do, to conservatively overestimate how much memory any given program could waste, and reject those that COULD waste it. The nice thing about static analysis is you only have to run it once per particular script.
The runtime environment handles those errors, not the code.
> This could be the next Lua, for instance, but for the modern era and far safer.
It isn't the default but you can sandbox all of this with Lua already. Including limiting CPU and memory use.
A lot of people don’t want to have to write Lua, to eg handle clicks on buttons. And how would you embed Lua scripts safely on the web, anyway?