News for hackers. Stuff that matters.
Re:The use of `class` for things that should be simple free ... by nitrogen on Thursday May 28, 2020 @09:51AM (#23337204)
I don't find all that much of a difference between notations like set.map{...} and map(set){...}, so at that point I suppose it really is just aesthetic preference.
Re:The use of `class` for things that should be simple free ... by totony on Thursday May 28, 2020 @10:03AM (#23337321)
Classes usually have a more complex state than the state passed to utility functions, which is a reason I'd be incline to use e.g. a struct as a state vs a C++ class. Makes it harder to write bad code.
Re:The use of `class` for things that should be simple free ... by kyralis on Thursday May 28, 2020 @12:12PM (#23338979)
So, let's say what you actually mean here: overly complex state is a problem, regardless of the syntactic sugar around passing it.

I've seen monstrous state variables passed around to "pure functions" at least as much as I've seen monstrous god objects; the problem is around complexity and data flow design and has very little to do with function vs object.

Re:The use of `class` for things that should be simple free ... by totony on Thursday May 28, 2020 @05:50PM (#23343180)
Yes that's my thinking. Everything can be done both ways, but in my experience structs have a better track record. Also different languages implement objects differently which adds mental overhead. Copying structs or marking them read-only is also usually easier vs an object which manipulates its own state.
Re:The use of `class` for things that should be simple free ... by Tomis02 on Friday May 29, 2020 @03:14AM (#23347106)
Upvote for the comment, but the reality is OOP (at least in C++) encourages people to write code this way. When you have a sufficiently large code base and an unforeseen requirement comes in, one that wasn't planned for in those architectural committees, you have a problem. And that problem is solved by either a man-century of refactoring, or by taking some shortcuts that destroy the purity of the code and eventually lead to these monstrous god objects that you mentioned. This happens over and over, to the point where you can't just say "oh it was an accident, happened just one time".
Re:The use of `class` for things that should be simple free ... by samatman on Thursday May 28, 2020 @11:21AM (#23338379)
Sounds like you would enjoy Uniform Function Call Syntax!

https://en.wikipedia.org/wiki/Uniform_Function_Call_Syntax