Not being in the mood for anything more involved, I spent a few days porting Tomb of the Snake to C++ and Genie. Well, "porting". The port is barely started, and I'm going to set it aside most likely. It was more of a pretext for me to compare and contrast both languages for future reference.
Now, C++ needs no introduction. As for Genie, let's just say it's like Python except it compiles to C, using GLib for a runtime library. GLib is better known as the foundation of Gtk+, and implicitly a lot of Linux or BSD desktop software. But it can be installed just fine by itself, and gives you more basic stuff: an object system, reference counting, fancy string operations, data structures, things like that. It's useful... but it's a dependency. Hence why I'm conflicted about making software that relies on it, as you'll see.
I've known C++ for a long time, but only used it very little over the years. I should still be somewhat familiar with it, but somehow it always manages to fuss over the details, sending me on yet another wild goose chase on reference sites. Conversely, I've known about Genie (and Vala) since they were still new, just over ten years ago, but never actually used them before. Not least because documentation wasn't nearly as good back then. It still has gaps, but I was able to figure out a lot of things from related reading and simple experimentation. Which meant being able to hit the ground running.
Sounds like the ups and downs of each balance out so far. So how did it go?
First, the obvious: Genie looks a lot like Python, by design, and that makes it easier to move code between them. In C++ it's not just semicolons and curly braces, but also header files to worry about. A verbose syntax also means more types to define if I want to keep it readable. Where C++ wins out is in the inline data department: aggregate initializers are much more flexible, up to and including maps of maps of structs! In Genie, it took a
case statement to simulate those. Arguably a new game should use info files, making it an non-issue, but that would be a big change for a port like this.
Second, I quickly found that my old code assumes automatic memory management. Genie requires more care, but it still spares you the details. C++... doesn't. It should be possible to change the code so it uses RAII or some such, but the transition isn't nearly as smooth. See above: I've made plenty of games in languages that don't have malloc, let alone garbage collection, but this one simply wasn't written with as much care, and any port has to deal with that.
Speaking of language features: I didn't get far enough to actually need this stuff, but Genie, arguably a glorified thin wrapper over a C library, supports OOP features like properties or events / signals, only available in C++ with a preprocessor. Go figure. Even Python only knows about the former, and then as a bit of a hack. And then there are nullable types, something vanishingly few languages have even in 2020.
Too bad the language can't do everything by itself, and when it comes to using libraries, C++ can simply do it, while Genie expects so-called VAPI files, and I haven't quite figured out how they get made. Tellingly, the Vala compiler (which also handles Genie) comes prepackaged with a lot of them. Good thing all I need is already there. Well, almost everything.
Just as importantly, a C++ compiler is available pretty much anywhere, and generated executables without any unusual dependencies. Then again I tried to aim for maximum portability before, and the results weren't very satisfying.
Besides, using Genie is kinda fun. That matters when working on, you know, games. So I'm not writing it off yet. But neither can it become my next go-to programming language. Then again, should it? The more, the merrier.