4 ms·
Last winter I wrote BlockLike.js, an educational library that allows one to use Block programming concepts in JavaScript. This required supporting pacing and wa
by ronilan 8y ago
Last winter I wrote BlockLike.js, an educational library that allows one to use Block programming concepts in JavaScript. This required supporting pacing and waiting while still allowing the user to write simple (and valid) JavaScript.
When I started I had this voice in my head whispering again and again "eval is evil, eval is evil". Then I just got over it...
I ended up with one-pass, event triggered, construct-and-run (essentially "eval") solution. The user writes simple code that is event triggered. The code is converted into a string, rewritten in realtime and "enhanced". An Asynchronous Function Constructor then converts it back to a function and it gets invoked by the triggering event.
It works great and though there is, obviously, a performance penalty for the realtime rewriting, it is never the limiting performance factor for implementations (multiple DOM element animation is).
Examples:
https://www.blocklike.org/example/12-advanced/recursion_tree.html https://www.blocklike.org/example/12-advanced/recursion_tree...
https://www.blocklike.org/example/12-advanced/color_bubbles_sprite_factory.html https://www.blocklike.org/example/12-advanced/color_bubbles_...
https://www.blocklike.org/example/14-games/avoid.html https://www.blocklike.org/example/14-games/avoid.html
Repo:
https://github.com/ronilan/BlockLike https://github.com/ronilan/BlockLike