Remix.run Logo
▲ ranger_danger a day ago

I think they're using a slightly different definition of "safe" than you are

▲EGreg a day ago | parent [-]

It’s not the job of a language to solve everything. Sometimes the solution belongs in sandboxing and virtual machines. You should be isolating untrusted code anyway.

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.

▲Rohansi a day ago | parent | next [-]

What you are saying here is completely different to what your GitHub readme says. You say it protects the host's environment there but here you say it actually doesn't so use a real sandbox.

> 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.

▲EGreg 11 hours ago | parent [-]

I’m sure you can. This is much more of a modern solution than Lua was in the 90s.

▲Rohansi 9 hours ago | parent [-]

Depends what you consider modern? You get a much better isolation model with Lua because you can use separate Lua VM (isolates), explicitly expose only what's needed, and set your resource limits for them.

▲EGreg 7 hours ago | parent [-]

I consider Javascript more modern

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?

▲Rohansi 2 hours ago | parent [-]

You don't have to write Lua. As you've already said in a different comment, it isn't a problem in QuickJS because it has memory limiting built in. IMO that's the right way to do this - instead of transpiling JS to try and make it safe you should run it in a virtual machine like QuickJS/Lua/etc does.

▲ranger_danger a day ago | parent | prev [-]

Why are you trying so hard to defend programs that can crash by blaming it on their runtime environment?

▲hoppp a day ago | parent | next [-]

I like the erlang philosophy of letting programs die if they crash.

The runtime environment handles those errors, not the code.

▲EGreg a day ago | parent | prev [-]

What?