this post was submitted on 05 Sep 2024
13 points (63.3% liked)
Programming
16975 readers
1288 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Because classes kind of suck.
It amuses me that someone downvoted
classes suck
.It's an objectively true fact.
Classes can be useful for abstraction. Just because they often overused doesn't mean they're bad.
Without an explicit class, I would either:
doStuff(cast(void*)&localstate, values)
vslocalstate.doStuff(values)
).While structured programming was a godsend to the chaos preceding it, newer programming paradigms should have been instead seen as tools rather than the next dogma. OOP got its bad name from languages that disallowed its users to develop without classes, and enterprise settings making its devs to implement things that could have been simple functions as classes, sometimes complete with factories.
Same is with functional programming. There's clearly a usecase for it, but isn't a Swiss-army knife solution for all problems of programming.
Well said.
Here I am trying to wind people up and you're responding with thoughtful nuanced consideration.
You make some great points.
I'll add - for folks reading along - I do think a class is still almost always an anti-pattern, even with all the OOP class function and factory pattern stuff removed.
I also feel (as you referenced):
And also:
State data is a necessary evil in most programs.
I've found that most advanced
class object
implementations treat program state data more like a pet than a threat.Sorry for the long response - I know you don't need it - you know what kind of tool you're looking for.
I figure they extra detail above might provide food for thought for folks reading along who are surprised there's even contrasting opinions on classes.
(And I feel a little bad for not really posting anything very useful earlier in the thread.)