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

(1993)


unlikely to be 2023, now, is it?


You'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/gs...

[2]: https://docs.gtk.org/gobject/


This. 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.


I'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.


What's the point of refactoring C++ to C? That sounds weird and regressive.


No C++ compiler for the target architecture?


For 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.


There 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.


Would be interesting if it was actually. Kinda feel like playing with this for fun.


Here's a new library that provides OOP in C: https://github.com/gyrovorbis/libgimbal


Cool, will look at it for inspiration :)


I'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.


Hey 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!


Thanks!




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

Search: