this post was submitted on 12 Feb 2026
42 points (93.8% liked)

Programming Humor

3387 readers
1 users here now

Related Communities !programmerhumor@lemmy.ml !programmer_humor@programming.dev !programmerhumor@kbin.social !programming_horror@programming.dev

Other Programming Communities !programming@beehaw.org !programming@programming.dev !programming@lemmy.ml !programming@kbin.social !learn_programming@programming.dev !functional_programming@programming.dev !embedded_prog@lemmy.ml

founded 2 years ago
MODERATORS
 
top 17 comments
sorted by: hot top controversial new old
[–] one_old_coder@piefed.social 8 points 3 weeks ago

I did this in the past except that the constructor would be called Point_new, and the first parameter would be Point *self. The lack of automatic destruction is a bit annoying, but everything else is fine. A few books have been written on that topic too.

[–] jerkface@lemmy.ca 7 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

now show the pointer hell that would be polymorphism in C. my brain segfaulted just thinking about it.

[–] Gutek8134@lemmy.world 4 points 3 weeks ago (1 children)
struct sockaddr_in server_address;
bind(server_socket, (struct sockaddr *) &server_address, sizeof(struct sockaddr_in));
[–] jerkface@lemmy.ca 2 points 3 weeks ago
[–] Treczoks@lemmy.world 6 points 3 weeks ago (1 children)

Anything I built in the last 15 years of working on our companies flagship products is made like this. Everything belonging to one "object" is in one file. "Private" variables are set to "static".

[–] Patrikvo@lemmy.world 6 points 3 weeks ago (1 children)

Makes sense. Most "best practices" and "standards" are just someones idea of structure written down.

[–] Treczoks@lemmy.world 2 points 3 weeks ago

And if you follow good standards like MISRA, you can reduce errors and issues even further.

[–] negativenull@piefed.world 5 points 3 weeks ago

OOP is dumb and wasteful

/ducks

[–] bluGill@fedia.io 4 points 3 weeks ago

I can do anything in any Turing complete language. However some languages provide some nice syntax advantages, or are less error prone. If you are need to do OOP C++ is a better choice than C because the syntax is much better than the mess needed in C. (D or Ada come to mind as better choices than C++ - you might have your own opinion)

[–] xep@discuss.online 3 points 3 weeks ago

In C and C++ the idea is that the programmer only pays for what they use. I'm not saying that it doesn't cause its own set of issues (strings, for example) but it isn't bloated.

Unless you mean the C++ standard, then have at it.

[–] Agility0971@lemmy.world 2 points 3 weeks ago

Why not create methods in the struct? Type would be just a pointer to a function. Ez

[–] lambalicious@lemmy.sdf.org 2 points 3 weeks ago

using pointers and allocation instead of just using the struct natively

I see we are at the point where we are vibecoding programming memes...

[–] blarghly@lemmy.world 1 points 3 weeks ago* (last edited 3 weeks ago) (1 children)
[–] 33550336@lemmy.world 1 points 3 weeks ago

Dunno, I just stole the meme, I suppose ancaps can like corporate OOP langauges

[–] lurch@sh.itjust.works -3 points 3 weeks ago (2 children)

It's nice and clean, but it's not OO.

One big difference is: You have to pass the "object" as parameter for everything that modifies it. You could use globals, but then you can only have one "object".

Still better than undescriptive naming.

[–] jerkface@lemmy.ca 5 points 3 weeks ago* (last edited 3 weeks ago)

explicitly passing the self variable doesn't make it not OOP.

[–] Wolfizen@pawb.social 4 points 3 weeks ago

I disagree. I believe this is object oriented and the object is Point.

You're right that the syntax looks different. But whether the object is before the function name: obj.fn(p) or after the function name: fn(obj, p) does not change its status as a parameter. It is still required to be present in the invocation in both cases.

Object oriented isn't about where the parameters go, it is about how the program is organised and designed.