this post was submitted on 08 Jun 2025
520 points (97.6% liked)

Programmer Humor

36350 readers
401 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] xiii@lemmy.world 7 points 1 day ago* (last edited 1 day ago) (1 children)

I was working on a C code base with classes, inheritance, and polymorphism, all done by hands and macros.

Something like

typedef struct s_some_class {
    void (*method)(this *s_some_class);
} t_some_class;

Overall, learning C was the best enabler in my whole career. For instance I was learning Python by tinkering with CPython VM, so when I see these ‘WAT’ quircks I know exactly what’s up.

[–] bestelbus22@lemmy.world 3 points 1 day ago (1 children)

Interesting, how did they do inheritance? Something like void *super? Also why not switch to CPP if you wanna do OOP?

[–] xiii@lemmy.world 2 points 16 hours ago (1 children)

In general, 'classes' declarations were done with macro. I don't remember the exact code — something akin to

BEGIN_CLASS(A, Parent);
CLASS_MEMBER(a...)
END_CLASS();

The project had started before C++ existed, and the switch would be too costly. It's not just OOP part, also reflection mechanism with bindings to the homemade scripting language, and multi-platform UI library. It was a gem of its time.

[–] bestelbus22@lemmy.world 1 points 15 hours ago (1 children)

That sounds like quite a challenge to maintain, to speak in euphemisms ;)

[–] xiii@lemmy.world 2 points 12 hours ago

Revolutionary technologies of the '80 make me appreciate modern programming languages and especially tooling much more.