Over the past couple of months I’ve been working as a consultant on an embedded project written in C99 and I’ve been toying with the idea of transitioning the codebase of Rival Fortress from C++ to plain C.
As I hinted in a previous post I’m not a big fan of most of the features that C++ offers, and in the past month I realized how much I enjoy the bare bones feel of coding in plain C.
This weekend I decided to bite the bullet and changed the build script flag from
To my surprise porting the game to C didn’t take too long: I was done in a couple of days.
Bye bye overloading
One of the “features” of C that I never thought I would come to appreciate is the lack of function overloading.
Like many Linux programmers, my home is in the
shell, and being able to
grep the codebase for a function name and having it return a list of all the exact call sites has been proven to be very useful in more than one occasion.
The lack of operator overloading does make to code very verbose at times, but I’m the kind of guy that likes long variable and function names, so that’s a plus for me.
Surprise compile times
Another surprise was the speed up in compilation time. I wasn’t expecting much as I was already light on bloaty C++ features, but after the port the compilation time went from 0.9 seconds to 0.7 in debug mode.