1. Welcome to Game Makers Forums

    Whether you are a new, amateur or professional developer, you will find your place here.

    Register to Download Sample Code or Advertise your Project.

    Register also gives you the ability to be helped or help others:

    Dismiss Notice

Bytecode VM for your game

Discussion in 'Programming Theory' started by a_bertrand, Jun 6, 2017.

  1. a_bertrand

    a_bertrand Administrator

    Joined:
    Oct 28, 2014
    Messages:
    1,264
    Likes Received:
    562
    Trophy Points:
    113
    Gender:
    Male
    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.
     

Share This Page