GTK+ and Object Oriented Programming in C - Not worthwhile?

I was reading the Monologue this morning, and a blog post from Laurent Debacker came across the wire. He was writing about the Ribbon Sharp library he’s been working on, and his own feelings about the GNOME project from a GNOME outsider. Now, personally, I don’t much care about the Ribbon support he’s been working on, as that is probably my most single hated change in Microsoft Office 2007. That may just be because of how severe a paradigm shift ribbons are compared to the classic menu view.

However, his comments about GNOME were interesting to me. Laurent admits that he is pretty new to the GNOME community, and he appears to be fairly young (though probably close in age to myself), which may well explain a lot about his views on software development. The specific comment I’m referring to this

I think that the main problem with GNOME for a new developer, is that programming in OO in C using Gtk+, is a bit like programming in COBOL.

I can definitely see where he’s coming from this comment. However, I view this primarily as a problem with the education provided by most Programming courses. Object Orientation is not a technology. It’s a paradigm.

Certainly, it is much easier to perform Object Oriented Programming in a language which was built around the paradigm (C#, Java, C++). Once the Paradigm in understood, migrating it to a traditionally procedural language such as C is trivial, and will bring about the same design benifits. If anything, being written in C is a huge benifit for GTK+/GNOME, as it’s C roots have facilitated the porting of the libraries to a vast number of platforms, and bindings have been written in a large number of languages. (To be fair, Laurent does mention the success of the bindings).

However, the largest reason GTK+, and by extension GNOME, are written in C is history. GTK+ was designed as a replacement for Motif, when the GIMP project decided they needed to migrate away from Motif to be a truly open piece of software. Motif was a C library, GIMP was a C program, C was the only obvious choice. Then, ten years ago Miguel de Icaza decides to start the GNOME project, in response to KDE using QT and QT being non-free software. At the time, Miguel didn’t view GTK+ as ideal, but it was far better than programming straight X11, and it was available. (For more on the founding of GNOME, check out Chris Dibona’s interview of Miguel on FLOSS Weekly).

So, C was the language of choice, and by now, so much of the backend is written in C that I don’t think that’s going to change. The only potential ‘disadvantage’ I can see of GNOME remaining in C, is that in order to add a widget to GNOME such that it will be available to all bindings, is to write it in C. I don’t really see this as a problem as I don’t think C is going anywhere anytime soon, and GNOME performs very well having been written in C. Plus, the alternative proposed by Laurent carries with it several distinct disadvantages.

  1. If GTK+ 3.0 were to be ported completely to .NET, it would only run on platforms where Mono was supported. Currently, that list is comparatively short.
  2. C code would still be required to bind to the underlying system APIs (X11 on Unix, Win32 on Windows).
  3. If the language isn’t .NET compatible, it can’t be bound.
  4. It would require reimplementing an enormous amount of code, for minimal return.
  5. Some people would drop GNOME altogether if this were to be done. A lot of people don’t trust Microsoft or .NET, and by extension the Mono project.

I think .NET and Mono are great technologies, and I use .NET when I can. I have extended just enough trust to Microsoft to be willing to follow and work with Mono (hopefully on, as well), but that doesn’t mean that a lot of people are willing to do the same thing. Until Microsoft can prove that they aren’t a wolf in sheep’s clothing (which many Free Software people will probably never believe), basing a platform like GNOME on a technology so encumbered by Microsoft patents (regardless of ECMA standardization and Novell agreements), is dangerous and would be seen as highly alienating to a good number of users. It’s a risk not worth taking for GNOME at this time.

In short, I see far more disadvantages to attempting to convert GTK+ away from C, than advantages. I like .NET, I love Mono, but neither they, nor any other language provide any strong incentive to porting GNOME.