S
S
Sirion2017-03-21 00:20:59
JavaScript
Sirion, 2017-03-21 00:20:59

Interpreted language FOR JS can you tell me?

Yes, you heard right. I had a need for a Wishlist - to allow the user to post some scripts, which will then be executed by other users. I will not describe the subject area, I will only describe the obvious requirements for such scripts: they must be safe (roughly speaking, do not redirect to phishing sites), and they must not hang the browser (run for a certain predictable time or die with an error, it is also desirable to eat a predictable amount of memory). Accordingly, the stupid decision "JS via eval" is no longer needed.
Tell me, comrades, is there any standard solution for such a situation? Maybe you can somehow cunningly achieve the specified requirements from JS? Or is there a browser-based interpreter for some other language that meets the requirements already mentioned? No special power is required from the language (although it is still desirable not to be a brainfuck), the main thing is security, controlled execution time and controlled memory consumption.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Lerg, 2017-03-21
@Lerg

You can embed Lua, for example. There is a VM implementation for JS. I can't say how convenient it is.

S
Sergey Sokolov, 2017-03-21
@sergiks

JS Interpreter fits the description, but I haven't tried it.

A
Anton Anton, 2017-03-21
@Fragster

codecombat.com in open source, probably there are interpreters there too... https://github.com/codecombat/codecombat

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question