3 ms·
The primary advantage is that it's already done, really. It's not hard to define isolated environments in almost any language you could name ("I should be able
by jerf 8y ago
The primary advantage is that it's already done, really. It's not hard to define isolated environments in almost any language you could name ("I should be able to have two runtime environments that support as much of the original language as possible, and they should not be able to affect each other" - a thousand i's to dot and t's to cross, but that pretty much captures the idea), but implementing them is another thing entirely. So much of the rest of language design tends to cut the other way, making sure that things are hooked together deeply for the convenience of the programmer.
I'm not particularly convinced Javascript is that much better than any other language as the language goes, but the implementation is far ahead of almost anything else. I know of other implementations of this idea in other languages ("Safe" in Perl [1], various attempts at sandboxing in Python which have generally failed, Safe Haskell [2], many others), but without the browser use case driving them forward, they tend to be poorly tested and even decay over time. It tends to be a use case popular enough to get some stab at support, but not popular enough to quite result in a robust, real-world-tested library support. The browser is an exceptional use case.
[1]: https://perldoc.perl.org/Safe.html https://perldoc.perl.org/Safe.html
[2]: https://ghc.haskell.org/trac/ghc/wiki/SafeHaskell https://ghc.haskell.org/trac/ghc/wiki/SafeHaskell