Javascript ponderance

Overview

In this area I'm going to set out my ideas about using Javascript for large chunks of Warzone core functionality...

This idea may at first sound absurd. In particular, there will be concerns over the performance of JS compared to C++. While it's true that finely tuned C++ code will be faster than JS, recent competition in the browser market has led to some amazing improvements in JS compilation and runtime performance.

However, I'm not insane enough to imagine that the whole game could be written in JS - that would just be stupid. But, there are large chunks of the C++ code for which performance is non-critical, primarily because most code gets called due to a state change, rather than constantly whilst in that state. Code that's called only occasionally doesn't need to be high performance - it could be bloaty ad horrible and yet still not have any adverse effects on the game. So identifying where and when to use JS vs. C++ is going to be a key goal of my experiments.

Proof of concept

Over the next two months, I plan on chipping away at a JS proof of concept that will show how a great deal of the C++ code relating to droids can be ported over to JS. As I'm doing this in my spare time, don't expect results any time soon!

My plan of attack is currently:

  • Create a JS representation of "base object" (the superclass of droid, structure and feature objects)
  • Make an array of such objects
  • Focussing on droids, start implementing the common droid properties
  • Extend objects differently based on their .droidType
  • Add in an API for defining orders and actions, etc.
  • Work out how best to apply mutators

The tasks above will identify some key areas where JS definitely can't be used, and at the same time enable some new features that would be otherwise tedious to implement in C++.

I also expect that I'll need to create structures around bodies, propulsions and turrets in order to fully flesh out my droid experiment.

In the last stage of my proof of concept, the implementation of a mutator system, I hope to find a very clean and easy to use approach for creating and deploying mutators to the objects. In particular I'll be looking at class-level mutators (eg. something that affects all droids, or all droids using a specific propulsion, and so on) as well as instance level mutations (stuff that affects a single droid). I want to ensure that multiple mutations can be in effect at the same time, and I want to try implementing many of the existing game features (such as burning droids, EMP disabled droids, etc) using mutations to explore what works and what doesn't.

Anyway, my lunch break is now over so it's back to RL for me!