Using C++ instead of GObject/C

There’s a great post on why to use C++ instead of GObject/C over at BMP CodeBlog, the blog for developers of beep media player (my preferred MP3 player on Linux). I have to agree with most of what the author says. Using GObject/C is quite cumbersome, I’m almost surprised so many GTK+ developers do it. Especially considering the fact that C++ doesn’t incur overhead unless it has to, nicely expressed here:

The ultimate feature is that all of these are optional. We incur no overhead when we do not use a language feature (with the exception of… exceptions). In fact, cxx_conversion is currently in perfectly valid C++ and uses none of the features or C++ libraries mentioned above yet. The C++ language follows the philosophy of ‘pay for you use’ (better rephrased as ‘don’t pay for what you don’t use’). As it is right now, cxx_conversion is no less (or more) CPU or memory efficient than its C original.

GTKMM keeps getting more and more mature, so now that I’m finally learning C++ properly, I think moving over to GTKMM will be quite nice for a future project that needs a cross-platform UI.

Leave a Reply