[HN Gopher] Object-oriented Programming with ANSI-C (1993) [pdf]
       ___________________________________________________________________
        
       Object-oriented Programming with ANSI-C (1993) [pdf]
        
       Author : Tomte
       Score  : 48 points
       Date   : 2023-06-21 18:10 UTC (4 hours ago)
        
 (HTM) web link (www.mclibre.org)
 (TXT) w3m dump (www.mclibre.org)
        
       | zabzonk wrote:
       | > I could not forge a portable implementation in C++.
       | 
       | i would like to know why not.
        
       | jjgreen wrote:
       | (1993)
        
         | Tomte wrote:
         | Thanks!
        
         | gjvc wrote:
         | unlikely to be 2023, now, is it?
        
           | JohnFen wrote:
           | 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.
        
           | omgmajk wrote:
           | Would be interesting if it was actually. Kinda feel like
           | playing with this for fun.
        
             | wtetzner wrote:
             | Here's a new library that provides OOP in C:
             | https://github.com/gyrovorbis/libgimbal
        
       | aninteger wrote:
       | And for people who took this to the "next level" just look at
       | GTK.
        
         | [deleted]
        
         | pjmlp wrote:
         | That would have been Motif and CDE, which Gtk is based on as
         | idea.
        
           | jandrese wrote:
           | No seriously, the GTK C bindings are basically written in a
           | half-formed version of the old C++ "C with preprocessor
           | macros" syntax.
           | 
           | It looks like this when you program it:
           | GtkWidget* grid = gtk_grid_new();         GtkWidget* label =
           | gtk_label_new("Hello World");
           | gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
           | 
           | That GTK_GRID bit is a macro that evaluates at runtime and
           | will chuck out runtime errors if the widget doesn't match. It
           | supports inheritance. If you have for example a
           | gtk_combo_box_text, you can use
           | gtk_combo_box_set_active(GTK_COMBO_BOX(my_combo_box_text), 0)
           | and it will select the first entry in the gtk_combo_box_text
           | because gtk_combo_box_text inherits from gtk_combo_box like
           | any good object oriented system.
        
             | dfox wrote:
             | Motif/libxm is very similar to that. With two important
             | exceptions: the user code does not use type-checking macros
             | and "stringly-typed" API for set a property to something is
             | more or less a part of the overall ecosystem (well, Xm is
             | just an layer built on top of Xt).
             | 
             | Gtk+ was originally an implementation of whatever parts of
             | Motif were used by Gimp, built on an underlying object
             | model that has nothing to do with Xt (which has both good
             | and bad implications).
        
       | chmaynard wrote:
       | This reminds me of a course I took at Stanford around 1991. The
       | course title was UNIX C Programming and the instructor was Dr.
       | Eric Roberts. The programming part was to build a library of
       | simple tools and the UI was the command-line. We didn't call it
       | object-oriented but it involved programming with ADTs that had
       | well-defined APIs.
        
       ___________________________________________________________________
       (page generated 2023-06-21 23:00 UTC)