JS-Interpreter

31 views
Skip to first unread message

Max Stephen Russell

unread,
Nov 22, 2024, 3:39:38 PMNov 22
to Blockly
May I ask what is the precise meaning of this statement in the Guide?:

If you are serious about running the user's blocks properly, then the JS-Interpreter project is the way to go.

https://developers.google.com/blockly/guides/app-integration/running-javascript

Thank you. 😎

Steve

Neil Fraser

unread,
Nov 22, 2024, 3:57:13 PMNov 22
to blo...@googlegroups.com
If your blocks are generating JavaScript, broadly speaking there are two ways to execute this generated code.

1) You can use JavaScript's eval function.  Eval is very well-known to be dangerous (see the warning at the top of the linked page).  That said, if your Blockly application is simple, this may be the simplest and quickest approach.  If you are just getting started, then use eval.

2) You can use JS-Interpreter.  This is trickier to set up, but it completely eliminates all the security issues of eval.  It allows one to execute code at any speed or even backwards.  It allows multi-threading and debugging.


--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/blockly/06ad7d46-873a-4be9-a856-4d736255593cn%40googlegroups.com.


--
Neil Fraser, Switzerland
https://neil.fraser.name

Max Stephen Russell

unread,
Nov 22, 2024, 4:00:07 PMNov 22
to Blockly
OK, I'm sold. Thanks, Neil!

--Steve

Reply all
Reply to author
Forward
0 new messages