5 ms·
unlikely to be 2023, now, is it?
by gjvc 3y ago
unlikely to be 2023, now, is it?
- omgmajk 3y agoWould be interesting if it was actually. Kinda feel like playing with this for fun.
- wtetzner 3y agoHere's a new library that provides OOP in C: https://github.com/gyrovorbis/libgimbal https://github.com/gyrovorbis/libgimbal
- omgmajk 3y agoCool, will look at it for inspiration :)
- gyrovorbis 3y agoI'm the author of the libGimbal project linked to there. It's a massive object-oriented C codebase with an entire cross-language type system that was inspired by GTk's GObject, Microsoft COM, and the Objective-C language. I've studied everything out there on achieving OOP in C, and actually the OP's book reference was my original inspiration. There's a fine art to doing it and a few good codebases are out there that do it well... The entire GNOME stack is based on this kind of stuff. Anyway let me know if you have any questions. lol.
- omgmajk 3y agoHey dude, awesome work and thanks! I'm mostly interested in a curious kind of way, I really enjoy programming procedurally mostly but sometimes being able to utilize OOP for certain things is very nice. Really in the end I should just make my own language but who has the time right. In any case, fascinating stuff and thanks again!
- JohnFen 3y agoI'm doing OOP in C right now in my work. I'm porting a C++ program to a new platform and, for reasons, the most feasible language to use for it is C. Re-engineering the code to be not object oriented is not practical, so we're keeping its OO nature.
- proxyon 3y agoWhat's the point of refactoring C++ to C? That sounds weird and regressive.
- gyrovorbis 3y agoThere are a few niche reasons. The entire GNOME/GTk stack benefits greatly in the realm of language interop from being C at its core. This is why it easily has bindings to every language ever.
- acuozzo 3y agoNo C++ compiler for the target architecture?
- JohnFen 3y agoFor subtle technical reasons relating to the toolchain, it's not possible to use C++ for this platform. Well, it is possible, but it would easily take four times the amount of time it would take to port the C++ code to C. So porting makes the most sense.
- j1elo 3y agoYou'll do object-oriented programming with C in 2023 if you want to use the main official API of the GStreamer multimedia framework [1], which is C-based and heavily using GObject object model [2], which itself is part of GLib (the underlying library of GTK) [1]: https://gstreamer.freedesktop.org/documentation/gstreamer/gstobject.html https://gstreamer.freedesktop.org/documentation/gstreamer/gs... [2]: https://docs.gtk.org/gobject/ https://docs.gtk.org/gobject/
- gyrovorbis 3y agoThis. The entire GNOME stack is based on a steroided-out C-based OO type system in the same vein as the OP's PDF... and it's actually how it gets bindings to every language ever so easily... Anyway, I was sent down a rabbit hole of wanting to do object-oriented C for a language independent core as well, starting off with buying the physical copy of this PDF, because I liked it so much... I have to say GStreamer is probably the absolute best, most ambitious, shining example of such a type system, as it's already built upon GObject, fixes a lot of its shortcomings, and just really takes the whole thing to the next level with a complex, highly OO architecture. Fantastic reference and inspiration for this kind of stuff.