Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

GTK invented its own bespoke Object Oriented Programming system for C, called GObject: https://docs.gtk.org/gobject/

Naturally, it's very annoying to use this C-based OOP API in any other language, especially languages that have their own incompatible OOP type system like Java or C++.

One of the biggest reasons to use Vala is that it's OO system is GObject, making interacting with GTK and GLib code significantly more painless.



GObject is a real tragedy of the NIH syndrome in open source.

In the late 1990s there already was Objective-C. It already had open source compiler support, a battle-tested runtime, a free software desktop environment, and a corporate sponsor that became the world’s most valuable corporation.

Instead of using what was already there, the Linux GUI community extracted a poor shadow of Obj-C out of the GIMP image processing program (itself a poor shadow of a commercial market leader).


GIMP development started in 1995. The GNU Objective C frontend (the one that has stayed in use) started in 1993.

I would hardly consider the GIMP developers (who became the early developers of GTK) to be rash in their option not to adopt a language that had only been available for a couple of years in the open source world.

And all these years later, at a time when Apple has essentially abandoned Objective C, GTK and Glib continue to provide bindings for dozens of languages to create cross-platform GUI applications, and even if many of us don't agree with the direction(s) it has taken, GTK itself has continued to evolve, whereas UI libraries that came with Objective C have become frozen in time.

So in short, not really a tragedy at all.


Apple has not abandoned Objective C. It still has first class support on all their platforms, and the vast majority of their OS frameworks and applications are developed in ObjC. Swift is growing as an internal tool, but it’s nowhere near even 50% of the 1st party code on a mac or iphone.

Improvements have slowed on ObjC, as Apple’s focus switched to swift - ObjC 2.0 in 2014 was the last major change.


Also the most popular iOS third-party apps are all Obj-C[++].

The C++ interop is very important for companies like Meta. They have no incentive to rewrite anything in Swift.

If you look at minutes spent by end users on the iOS platform, I’m guessing it’s at least 95% inside Obj-C apps today.


Which is exactly why Apple showed the following at WWDC 2022, just to make it clear that the time for Objective-C is done.

https://developer.apple.com/videos/play/wwdc2022/102/

> The Objective-C language, AppKit & UIKit frameworks, and Interface Builder have empowered generations of developers. These technologies were built for each other, and will continue to serve us well for a long time to come, but over time new abstractions become necessary. For a while now, you've seen us hard at work defining the next generation of integrated language, frameworks, and tools: Swift, SwiftUI, and Xcode Previews.

> Tight integration in a development platform like this requires that all three pieces be designed and evolved together, both driving and driven by one another. Swift result builders were inspired by SwiftUI's compositional structure. SwiftUI's declarative views were enabled by Swift value types. And Xcode Previews was specifically designed for, and enabled by, both. Now, the result is the best development platform that we have ever built. And this year, Swift, SwiftUI, and Xcode all have fantastic updates that take this vision further, and make it even easier for you to build great apps for all of our platforms. And it all starts with Swift.


Nah. I’ll believe it when I see it.

Only when Apple comes out with a flagship app written in Swift (I would require SwiftUI too, but I don’t want to be that cruel…) will I entertain the idea that ObjC can be replaced. If they were eating their own dogfood internally, they should be aware that it is nowhere near ready for AAA app development.


watchOS comes to mind.

On Ventura several systems apps have been rewritten, including the preferences panel.


Those are not exactly the flagship apps I was talking about.


A complete platform used by millions of people, and apparently has saved several lives as per this week's announcement, doesn't count as flagship, got it.


It's like saying Tizen is flagship because it's used in millions of Samsung TVs.


> I would hardly consider the GIMP developers (who became the early developers of GTK) to be rash in their option not to adopt a language that had only been available for a couple of years in the open source world.

I think you misunderstood the criticism. They didn't say GIMP used the wrong model when it started, they said the greater community was wrong for copying GIMP later on.

> And all these years later, at a time when Apple has essentially abandoned Objective C, GTK and Glib continue to provide bindings for dozens of languages to create cross-platform GUI applications, and even if many of us don't agree with the direction(s) it has taken, GTK itself has continued to evolve, whereas UI libraries that came with Objective C have become frozen in time.

The suggestion is that Objective C should have been used instead of GObject. That doesn't mean having to use any particular libraries. And the same work to bind and evolve could have been poured into any reasonably solid library.


They did not copy GIMP, they literally extracted the widget code out of GIMP (and with it the object model) and made it into an independent toolkit. At the time there was no decent free toolkit at all, people were trying to reimplement Motif (Lesstif) or Qt (Harmony) but GIMP's was the first free software toolkit for X11.

Then over time it was extended beyond widgets, and the tooling around it grew to focus on exporting introspection information for language bindings.


My guess is that you can't point to a single example of a library written in ObjC that has any other language bindings, and if you can, it is barely used by anyone. The GTK community always made the idea of language bindings a central part of their development ethos.


> GIMP development started in 1995. The GNU Objective C frontend (the one that has stayed in use) started in 1993. I would hardly consider the GIMP developers (who became the early developers of GTK) to be rash in their option not to adopt a language that had only been available for a couple of years in the open source world.

Early in 1997, Guillaume Laurent and I spent some time looking into Objective C as a possible language for the "next version" of the Rosegarden sequencer on Unix/X11. At the time Rosegarden was a C application[1] using Athena widgets with my own little styling library, and we were sure there must be better options and were prepared to rewrite the UI entirely if we had to.

We ended up ruling it out for a few reasons, which I've just looked up in old email archives. I had some trouble getting the then-new gcc Objective C runtime working across Unix systems (we didn't only target Linux) and feared that we wouldn't be able to give our code to someone else and have them compile it easily. We couldn't find a working graphical toolkit: we thought GNUstep wasn't ready and also that it was probably going to be overkill. Other possibilities like NSXKit[2] weren't there either. Guillaume experimented with writing a toolkit himself but quickly ran into various obstacles that I don't have a record of.

(What is striking in hindsight is how hard it was to find reliable information to help us make a decision like this. There was documentation, and there were opinions, but there was very little of the form "we used this for our project and here's how it worked" that you would begin to see after blogging had become commonplace. We worked mostly on supposition and projection - install something, see if we could get it to build at all, spend a couple of hours with it and make guesses based on that, as well as on external info such as how much we knew about the developers that worked on it.)

So we switched to C++ instead. Considered Qt, argued about it, looked at LessTif, then GTK, then contributed a bit to gtkmm, then after a couple of years of nominally using gtkmm and getting nothing done, we switched to Qt after all and were happy. Happy-ish.

Even for people who really liked Objective C in 1997, it was pretty hard to make a case for. Maybe an open source company with staff and capital could have, but they barely existed.

[1] https://all-day-breakfast.com/cannam/x11-rosegarden/rosegard...

[2] http://www.hardcoreprocessing.com/home/anoq/Programming/GNUS...


How so?

You probably don't understand the context of mid-90s free and open software. Nothing is free, nothing open, relevant business models do not yet exist. Few things that are open barely work: linux takes hours to compile-tweak-recompile, all the tools are half-baked and semi-broken. You had to fix most things yourself.

Anyways, the only tools that do work reliably and have no license issues are coming from FSF: Emacs, gcc, unix utils, etc. Note that objC was not free, and the free version sucked most of the time. GCC did have world-class support for C though.

C was and still is a good choice for a core portable cross-language library. But UIs are probably the only programming context where OOP fits well. So people came with Gobject.

It all makes total sense, and that's why the whole thing survives to this very day.


> “C was and still is a good choice for a core portable cross-language library. But UIs are probably the only programming context where OOP fits well. So people came with Gobject.”

That’s my exact criticism: they came up with GObject instead of using the C-based solution that already existed, had open source compiler support, and was actively developed by Apple.

The GTK community made a huge mistake in trying to turn GIMP’s poor design into a generic GUI framework rather than collaborating with GNUstep on creating a next-generation framework.


Apple would never collaborated with GNUStep, first of all, when GNUStep started NeXT was still around.

Secondly, Steve Jobs wasn't an happy fellow about the whole story regarding GCC request to get back the frontend changes into upstream.

Gtk OOP is actually a clone of Motif OOP, which Gtk was cloning in first place.


They wouldn’t have needed Apple’s collaboration to build a new UI framework on Obj-C, just like nobody needed SCO’s permission to build Linux.

GTK’s two original sins were 1) cloning Motif in the first place, 2) doubling down on that design instead of throwing away GIMP as the prototype that it was.

They’ve been forever reliving the 1990s due to these bad choices.


Yet here they are, alive and kicking, while objc is gone, motif gone, etc. Long live gnome, long live gimp, long live gtk!


Gone? There are several orders of magnitude more users of Obj-C software than there are users of Gnome.


If you’re happy with this also-ran forever-4th-place-in-everything outcome, good for you. Long live the king of the desert island.

It could have been a lot more though.


> Gtk OOP is actually a clone of Motif OOP

And it has the characteristic GNU Lisp-envy-in-C (gnu_lisp_envy_in_c ()) flavour.

And the GNU Network Object Model Environment (GNOME) developers were (with Bonobo et al.) copying COM, if anything.

How did that even happen?


All ways of doing OOP in C will tend to resemble each other, if they are reasonably easy to use for a C programmer, without heaps of macros or code generation.

Anyway, COM is based on Microsoft RPC which is an implementation of DCE/RPC with extensions.

https://en.wikipedia.org/wiki/Microsoft_RPC


I don’t know. I mean, even classic Win32 has around two and a half object systems: windows+messages, standard COM, and IDispatch{,Ex}; and they are all rather different. (IDispatch and IDispatchEx, while a bit different from each other, are also neither particularly easy to use from C nor particularly good at their original purpose[1], so I’m counting them as half a system.)

Then there is Objective-C... OK, I don’t know that it’s that usable without a preprocessor, but there are Piumarta’s id[2] and Finch’s cobj[3], which are reasonably different from either of the Win32 systems.

(I don’t know to which degree DCE is relevant to COM in this comparison, given that in the intraprocess case all it inherits from there is the IDL and the non-exposed wire format when marshalling between apartments. Technically RPCRT4.DLL does contain obvious counterparts of DCE functions, but I haven’t yet found any Microsoft documentation suggesting you actually use those for anything.)

[1] https://ericlippert.com/2003/09/16/why-do-the-script-engines...

[2] https://piumarta.com/software/id-objmodel/

[3] https://dotat.at/@/2007-04-16-awash-in-a-c-of-objects.html


Miguel de Icaza has always been a fan from Microsoft technologies, that is how Bonobo happened.


But see also what happened with Qt and its license issues. That didn't happen with Objective-C, but nobody could predict the future at the time. There are some advantages to controlling your stack.

Also, pointing at GIMP's UI seems a little exaggerated, when the primary difficulty was keeping track of all the floating windows. GIMP seemed to have been designed in anticipation of a major advancement in window managers (not just tiling, but size-aware) that never materialized (the irregular packing problem is NP-Hard). Other Gtk apps never had this problem, and GIMP eventually switched to panes, thankfully.


1st, you're ignoring the fact that this c-based solution was not well-supported back then.

2nd, objective c is dead now. It was not a good long-term solution.

3rd, everybody and their cat knew C, while objc was a niche back then.

How is that a good choice for anything non-mac?!


> 2nd, objective c is dead now. It was not a good long-term solution.

How much is GObject used outside of GTK? Isn't that a hundred times deader?

The current number of Objective C users is not directly relevant to this comparison. The comparison pavlov made is to a hypothetical situation where GTK (or whatever you call it) was based on Objective C. If that had happened, GTK's object model would be much less 'dead'.

In that hypothetical world, it would still be sad to see Apple leave, but that world would have far more Objective C users than the current world has GObject users.


I've always wondered why GNUstep didn't work out; would've been a fantastic way of porting Mac OS apps, in theory at least. I guess that is what you're saying as well.


> In the late 1990s there already was Objective-C.

Objective-C is closer to the original, or at least early, Alan Kay and Smalltalk flavor of object oriented languages. In the late 1990s, we had already had 10 years of C++, so the C++ flavor "C with classes" type of object oriented programming was more familiar to most people.

I'd guess already then, the Smalltalk flavor of Objective-C felt a bit alien to many, who had grown familiar with the C++ flavor.


> GObject is a real tragedy of the NIH syndrome in open source.

It is, but I wouldn't look at Objective-C as the previous invention. X11 already hat the Toolkit Intrinsics (Xt), and it's not like they were unknown to the developers, the first version of Gimp having been written in Motif.

A new toolkit in the vein of Xaw/Motif/OLIT would've been a more immediate choice, but then again, no two persons seem to have the same preferences when it comes to object-orientation.

(I'm sitting in the proverbial glasshouse here, having switched my own "let's make some widgets for Qt 0.x" project to "let's reinvent X11 toolkits" in the mid to late 90s)


I've been writing C++ GUI apps with gtkmm for more than 22 years. I rarely notice GObject, other than in a few minor cases where the gtkmm wrapper didn't fully provide everything from the C level. In almost all those cases, the only reason I am still aware of them is because I use an ancient version of both gtk and gtkmm.

I would say that it is essentially completely painless to interact with GTK and Glib via gtkmm and glibmm.


> I've been writing C++ GUI apps with gtkmm for more than 22 years

How did you resist Qt?


When I started, Qt required a preprocessor (moc) for the build process. Gtkmm did not do, and use libsigc++. This seemed like a clear sign to me that it was technically superior.

22+ years later I would say that both Qt and Gtkmm have their own pros and cons. They have both run into pretty deep issues with integrating their own drawing model into the windows, macOS and X11 models. They both provide things that the other does not.

At this point, I don't see one as better than the other, and for a long established application like mine, the idea of switching is essentially unthinkable.


I did the same as PaulDavisThe1st; gtkmm is an excellent C++ interface for Gtk, such that I wonder why they even bothered to create Vala except for NIH syndrome. Qt had similar issues in the past: it wasn't pure C++, it was C++ "with extensions"; you had to use a custom compiler (moc), and you had to use Q-versions of everything the STL provides (QString, QVector, and so on).

Of course things were different more than a decade ago: C++11 did not exist yet or compiler support was lacking, and Gtk and Qt couldn't wait for it to catch up.


Yes you had to use qmake. 99% of the developers never even touched moc, it was baked into the build system and gave you things like signals and slots.

I remember doing this https://github.com/nurettin/trendline_analysis_qt/blob/maste... (Qt gave me graphicspathitems that I could do rubberband select on an accelerated qgraphicsview more than 15 years ago. I loved gtkmm and standard c++, but Qt was simply amazing. And nobody forced you to use Q*containers. I always found that argument a bit moot.

And it had none of these "problems" after 2012.


It's very pleasant to use in Python, though.

The object model is very close to C++ and Java, and I wonder if they could have made the memory layouts slightly different so that they were compatibile with C++, like in COM. But anyway gtkmm for C++ seems to work well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: