4 ms·
> It's like trying to show how to do OOP in C. Actually, I'd think that would be a super valuable to a C developer. Learning to implement OOP patterns in C wou
by lojack 11y ago
> It's like trying to show how to do OOP in C.
Actually, I'd think that would be a super valuable to a C developer. Learning to implement OOP patterns in C would provide practical patterns that can help architect C software. For non-C developers, it'd also provide fundamentals of how OOP actually works. C developers have been implementing OOP patterns since well before C++ existed.
There's lots of resources, and practical examples of this. GObject provides an object system used by both Gnome and GTK. Check out "Object-Oriented Programming With ANSI-C" for a book on the subject.
- ectoplasm 11y agoThat GObject stuff is really complicated. You can get pretty far doing simple OOP in C without inheritance and just containment.
- stream_fusion 11y agoIt's arguably faster and of more benefit to learn OO in an OO language, and then work backwards to figure out ways to implement those strategies in C (eg. polymorphism using structs with arrays of function pointers, or win32 send_message constructs). It's similar with functional programming. Figuring out folds, pattern matching and monads is probably easiest in haskell or Ocaml/F#. The decision to apply those techniques in other languages without native support then becomes a judgement about the benefit.
- deleted 11y ago[deleted]