GObject (a bit like COM in the Windows world) is a C API designed with language compatibility in mind.
This means that you can use GObjects in any language that supports C function calls, but it makes it difficult to write GObjects in a non-C language that can really be reused from any language (if you write a derived GObject class in say Python, you will need to embed a Python interpreter every time you want to use objects from this class in C).
You can automate the creation of bindings for many languages โโ(for example, Python, Perl, JS, etc.), and here lies one of the strengths of GObject. This explains the somewhat opaque API that GObject provides, which I admit is pretty hard to understand.
Unfortunately, it is also not suitable for C ++. GObjects has no trivial relationship with C ++ classes, and even if bindings are available (Gtkmm), it is not easy to write a C ++ class that inherits from GObject and expose it to the world. You must write C for this.
[What the world needs will be a kind of extension of the C ++ language, which will simplify the interaction with GObject, a bit like C ++ Cx on Windows, but 1) this is a difficult task, possibly achievable through the GCC plugin, and 2) there is no momentum to C ++ in the Gnome world, or in the Linux world in general (KDE is a notable exception). So far, we're tied to Gtkmm bindings.]
source share