3 ms·
Yes, Gtk+ and Glib do that with the catch that C has no type polymorphism, so everything is done with casts and void pointers. It's even fully object-oriented.
by guerrilla 5y ago
Yes, Gtk+ and Glib do that with the catch that C has no type polymorphism, so everything is done with casts and void pointers. It's even fully object-oriented.
- qalmakka 5y agoThe Glib approach is an immense monolith of nonsensical zealotry towards C. Reimplementing an Object-Oriented system in C using hacks and void pointers when GCC already had not one but two fully object oriented languages built-in was a completely pointless endeavor. There are a million different ways to shoot youself in the foot with Glib, and it definitely doesn't feel like writing C at all. I understand the historical context that lead to the creation of Glib (no C++ standard in the mid-'90s, no decent open Objective-C libraries, Stallman and most of the FOSS movement at the time harbouring a deep disgust towards C++ for some reason, etc), but it can't be pointed at as a good example of how to code in C - on the contrary, it's IMHO exactly what your C project shouldn't do. You've picked C because it's simple and clear, don't butcher it up with macros and weird hacks just to get a worse Objective-C.
- guerrilla 5y ago> understand the historical context that lead to the creation of Glib Well, yeah, that was 23 years ago. Back then there was no GNUstep and no free as in freedom C++ or Objective-C compiler. Now GCC's main development language is C++ and GNOME is slowly becoming somewhat language agnostic and also has Vala which at one point was supposed to cover up that mess. I guess another point is that they seem happy with it[1], so why should we care anyway. 1. http://planet.gnome.org http://planet.gnome.org
- rbanffy 5y agoI’d love to have a good excuse to program in Vala… it seems like a very nice language.
- epmos 5y ago> no free as in freedom C++ or Objective-C compiler G++ was available in 1990. I don't recall when Objective C became available in GCC, but it was present in at least gcc-2.2.2 in 1992.
- qalmakka 5y agoBoth g++ and the objective-C frontend already existed back then, so your argument isn't correct. I think the main reason back then was that Stallman and the FSF were very much against C++, and pushed very hard for everything under the GNU umbrella to be written preferably in C or Scheme. They only relaxed that after much insistence from the GCC developers, which wanted to be able to use templates and RAII. I think that Glib was born from the same mentality which considered C as the perfect language, with the end goal of getting the same functionalities of modern languages without leaving it.
- guerrilla 5y agoYou're right, g++ was there by the end of the first year but as far as I can tell libstdc++ didn't show up until around 1998. I don't know when GCC started supporting Objective-C (another commenter says maybe by 1992) but GNUStep didn't 1.0 until 1998 (it was fairly incomplete before that.) But yes, you're right, they could have developed Glib in either of those languages even if STL and *step didn't exist yet. I also found this e-mail[1] from Stallman that supports your claim. Do you know of more documentation? I'm interested in this history. 1. http://harmful.cat-v.org/software/c++/rms http://harmful.cat-v.org/software/c++/rms
- pjmlp 5y agoThe main reason why Gtk and GNOME exist was Qt's license and yes C above all. Here is one of the original versions of the GNU Coding Standards from 1994, https://www.schwedler.com/old/HTML/standards_7.html#SEC12 https://www.schwedler.com/old/HTML/standards_7.html#SEC12 > Using a language other than C is like using a non-standard feature: it will cause trouble for users. Even if GCC supports the other language, users may find it inconvenient to have to install the compiler for that other language in order to build your program. So please write in C.
- qalmakka 5y agoI found an archived copy of the GNU guidelines from 2004 that well represents what was the GNU policy of the time: https://web.archive.org/web/20041029162424/https://www.gnu.org/prep/standards/html_node/Source-Language.html https://web.archive.org/web/20041029162424/https://www.gnu.o... As you can see, it basically consisted in "use C, unless you _really_ have too". It was also well known that C++ was heavily discouraged by Richard Stallman, so picking it could well end up in your project having a hard time being adopted by GNU. The guidelines were relaxed afterwards, especially since GCC came to rely on C++ and every relevant C compiler was then written in C++, making the whole "we don't want to force people to install g++" even more nonsensical. In 2004 C++ was already way too ubiquitous to not have g++ installed.