Page 1 of 1

Bytecode VM for your game

Posted: Tue Jun 06, 2017 4:25 am
by a_bertrand
A couple of weeks ago I changed my script execution from an AST direct execution to a bytecode execution allowing me to interrupt the script execution basically anywhere and restoring the flow later on. This is mandatory in my case as Javascript handle some calls (ajax or websockets) in async mode, and my script is instead synchronous. My bytecode is not super efficient and could certainly be optimized, but it is also currently clearly slower than the AST execution. Not a big deal for most cases.

However as I always like to read around how others implements their things, I fell on this nice article, which I strongly suggest any developer to read:

http://gameprogrammingpatterns.com/bytecode.html

Don't be scared by the "bytecode" or "vm" keywords, and don't be scared by the fact the guy wrote it in C++, it's pretty easy to follow and could be implemented in any language nearly the same way.

In my case I started from a text scripting language and a compiler to end up to the bytecode, while he started from the bytecode and went to a scripting language to make it easier to work with.

As the author of the article I'm also thinking about the option to deliver a graphical language and allow non-dev to code in an easy to approach way. Maybe some features will not go through but it should at least cover most.

Re: Bytecode VM for your game

Posted: Tue Jun 06, 2017 10:14 pm
by hallsofvallhalla
Sweet I love good articles like this. Thanks for the share.