I’ve finally realized that I succumbed to the excitement a developer has when working on a new project, which has left me with a hard choice: continue doing things in a way that is harder than it needs to be, or partially scrap it and start over. Note to future self: plan things out before starting.
In other words, I’ve decided to (sigh once again) change the language that I am writing the RPG engine in.
Here’s the thing: in my excitement to get started on this wonderful idea I had, I only partially planned out what I would need to be able to implement the idea. I wrote both the prototype and the beginnings of the real version using the language that I was currently learning and not the one that I decided was best suited for the purpose. With the prototype, because I had not planned out how one might write multiple games in the same engine, everything was hard-coded into the source. In the C++ version, I made some real headway by figuring out that I could use SQLite databases for containing the game data and save files. On the other hand, I decided I would use XML for scripting the game… There were multiple other issues that made things more difficult, but I was working through them:
- Anything involving the operating system layout (e.g. data and configuration directories) had to be split into their own source files and optionally included at build time
- To avoid creating a ton of copies of objects everywhere and abusing memory, I had to create collections of pointers that I somehow had to keep track of if they were being referenced or if it was safe to delete them
- XML was not made to be used to describe programmatic directions, so I needed to create a DSL. Doing so in C++ meant bringing in yet other tools (flex and bison) and learning how to use those on top of everything else.
It was that final item that broke the was the figurative straw. I went looking at Scala again and found that it contains features to take care of almost all of the issues I was dealing with, including ones not listed above. So, I’m putting together a plan of what is necessary for the engine, as much as I can before running into unforeseen issues. I’ll most likely work on a couple of example projects to learn the database library and the GUI library before beginning, to make sure they are the right tools to use.
Let this be a lesson to all software developers out there: for any project with a significant number of features to implement, be sure to plan it all out first.
The good news (?) of all of this is that most of the code I had written in the C++ engine was object class skeletons and database interaction. The former will certainly be easy to re-implement in Scala and the latter will… hopefully also be easy. So, it was just a learning experience.