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

> Of course the one time I attempted to write something with Gtk+, it very much felt like a "We hate C++, so we're going to implement everything C++ does as conventions and macros on top of C" project.

The original reason for that was ABI compatibility, and being able to provide bindings for various languages which was considered a primary goal. As I recall at the time, there was no C++ ABI standard (or GCC didn't implement it), and it was considered hard to provide bindings of the library to various other languages.

GTK was written in C mainly for that reason.

This also explains why common object-oriented concepts are reimplemented in C in GTK, because them rejecting C++ for ABI reasons didn't mean they rejected the concepts.

This also explains Vala, Gnome's OO language that pre-processes to C, in order to get the best of both worlds. (anyone getting CFront flashbacks?)

History puts everything in context...



Writing bindings for Qt is still a major undertaking compared to writing bindings for Gtk. There are okish gtk bindings for lots of languages, but Qt bindings are only available for massively popular languages.


There isn't and has never been a standard C++ ABI. To interface with a C++ dll, you need to compile the executable with the same compiler version and the same flags.


You're right, it turns out what I was thinking of was just the Name Mangling convention, which looks like it isn't standardized either.


The name mangling is part of the ABI. It's super complicated in C++ because the functions can be overloaded and have variable amount of arguments. The rules are compiler and version and flags specific.

P.S. Name mangling is what define that the function "int print(char*)" will become "___4print@4" in the compiled DLL. All the functions in a DLL are listable and have a name, that's how they are found.




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

Search: