So it had to happen…
The more I work on this game the more I realize that I kind of like it… and that means there’s certain things need to change. For starters, it’s definitely running longer than I expected it to (the original two-week estimate now sounds pretty “out there”). For this reason, I need to shave down on the programming time. It has become pretty obvious to me that for every 1/2 hour that I spend writing code in swift for this game, 10 minutes of it is spent screwing around with the language and that is friction then I can no longer accept. So I’m dropping swift for this game.
Since I’m switching languages and I’m going to be rewriting some code, I decided to open things up quite a bit and go back to C++. It’s going to cost me roughly a week or two to rewrite things, but the benefit is going to be huge. For starters, since this game depended on my very large and very complicated Objective-C graphics engine (Verto Studio), I now have the “opportunity” to continue rewriting all of this code in C++ (this was originally started on my github as VGLPP). This means that this game and any other game that I want to use with the ported engine will be able to run on ANY platform including windows. This is a major win for me since making a game for OSX/iOS only isn’t really that smart. I’ve been wanting to do this for awhile and my frustrations with swift finally pushed me to do it.
So that’s what I’m going to be up to for awhile. As I’ve mentioned on twitter, I’ll be streaming roughly twice a week on my twitch channel for anyone who is curiuos about the process and wants to follow along. http://twitch.tv/vertostudio3d
I’ve already gotten quite a bit done and have surpassed my biggest barrier for doing this which was finding a reasonable way to parse verto studio files (spat out by NSKeyedArchiver/NSCoder objective-c mechanisms) in a portable way in C++. TinyXML and a little of reverse engineering did the trick.
With respect to all of the “benefits” swift and Objective C were providing over a lower level language such as C++, I’ve essentially found a reasonable replacement for each one thanks to C++11′s new features.
Basic Outline of Porting to C++
Swift/Objc | C++11 |
Strong Pointer (Reference Counting) | std::shared_ptr |
Weak Pointer (Reference Counting) | std::weak_ptr |
Blocks & Closures | Lambda Functions |
Protocols | Multiple Inheritence |
Dynamic Typechecking via “isKindOfClass” | C++ typeid / RTTI |
So you get the idea, nothings really out of reach with C++. It’s still more annoying and I’m not 100% thrilled with dealing with things like templates, header files and verbose syntax again, but I’ll take it over an unstable language any day.