by pengaru · 3y ago · 0 comments
TIL, apparently all that gobject code attempting to add something resembling a type system to C in glib is redundant...
Edit: After taking a quick glance at some random listings in goaccess, I don't have the impression this was written by particularly talented C developers.
Example: https://github.com/allinurl/goaccess/blob/master/src/sort.c#...
GLib adds an object system, not a type system.
Not that C's type system is a great one, but GLib does not fundamentally change or add to it (though it aliases it, a lot, for reasons I never understood).
In service of GObject, glib implements GType, and GLib's goals necessitated adding a (dynamic) type system to C:
https://docs.gtk.org/gobject/concepts.html#the-glib-dynamic-...
We've had literally decades of glib-utilizing free software developers mocking C devs reinventing their own bespoke type systems (and/or object systems) in their projects in lieu of simply adopting glib.
It most definitely adds a type system, at least as much as one could manage something called that in C. It just doesn't end there, and obviously your object system will dovetail with your type system.
C's type system is different enough in scope and goals from many other type systems that it leads to confusion to lump them together. That's really what this article is about. The author has miscalibrated expectations.
But nobody apparently cares about the in-context meaning of these words anymore.
Operating system, UNIX system, the system() function, system calls are costly, try find any mention of type system in the K&R C book [0]. Search for the word system, it's always in the context of something relatively huge, complex and usually runtime-dynamic vs. the C language.
To call C's type checking a type system is to completely misunderstand something fundamental about the language.
[0] https://ia803407.us.archive.org/35/items/the-ansi-c-programm...