One of the toughest decisions early in Mecromage’s development was deciding what language to use for the game and its tools. As with many development decisions, the decision to use C# for the tools and C++ for the game and engine was not obvious at first glance.
I was tempted to use C++ for everything for the following reasons:
- Tool and game code would have a lot of common functionality, and I’d only have to write these commonalities once.
- We’d be able to edit the game as we play it more easily.
- C++ hides nothing, as long as you stick to a limited subset of the language. When nothing is hidden, you have the keys to the kingdom when stuff goes wrong. C# does a lot more for you upfront, but, especially performance-wise, hides the details. Garbage collectors have no place in games.
What drove me to C# for the tools, initially, was how easy and fast it was to build GUI applications. I soon decided that I’d use the best language for each job: C# for tools, C++ for game.
As I progressed, secondary benefits arose from having a language wall between the tool and game code:
- I can alter tool code without worrying about indirectly introducing bugs into the game codebase, and vice versa. If you stick to a single language for everything you *could* quarantine the tool from the game code, but using different languages removes even the temptation of sharing.
- The ideal data representation of objects meant for editing (tool) is different from objects meant to be processed quickly (game). Thus, even sticking to a single language won’t let you share code as much as you’d expect.
We’re a small team that wears many hats. Unlike big teams that specialize, each of us are responsible for knowledge that spans many domains. When I take off my game hat and put on my tool hat, the language shift helps me pop the stack and exist in “tool land.” This is because the differences between C# and C++ mirror the mindsets I need when developing tool and game code. C# is fast to write (especially for GUIs), slower to execute. C++ is a bit slower to write, but lets you optimize where needed to what ever extent necessary.
-goat
Level Editor in Action