News for hackers. Stuff that matters.
Re:Rewriting Libimagequant in Rust for Portability by nine_k on Tuesday January 04, 2022 @12:19PM (#29797208)

  musicPart.play(drum, sticks);
Basicslly you can replace the module namespace with a class namespace if desired. What module could that be?
Re:Rewriting Libimagequant in Rust for Portability by lostcolony on Tuesday January 04, 2022 @02:57PM (#29799433)
Right. But that's just it. "musicPart" is an object. A noun. What the hell is a "Music Part"? It's a completely synthetic object you've had to create solely to namespace functions. It's like how so many large Java projects have static "Utils" classes.

What you've done is not OO; in fact, it's an anti-pattern in OO. You've created, as you correctly note, a namespace or module around static functions; there is no meaningful encapsulation of data.

My point isn't that it can't be done, it's that trying to follow best OO practices, you run into this sort of problem (which has had a lot of digital ink spilled on it). The fact there is a pragmatic solution isn't in any doubt; it's that such a solution intentionally eschews the data encapsulation that OO demands (but not imperative or functional approaches, which instead say it's the right approach to do that).

Re:Rewriting Libimagequant in Rust for Portability by nine_k on Tuesday January 04, 2022 @06:34PM (#29802559)
If you ever played music, you know it consists of parts. Say, a percussion part, a bass part, a rhythm guitar part, a lead guitar part, a vocal part, etc.
Re:Rewriting Libimagequant in Rust for Portability by lostcolony on Tuesday January 04, 2022 @08:37PM (#29803800)
Why would 'play' hang off of the (presumably static) "MusicPart" then, rather than, "Player", "Musician", "Composition", etc?

Also, you realize that this whole discussion is proving the point, right?

Re:Rewriting Libimagequant in Rust for Portability by ReleaseCandidat on Tuesday January 04, 2022 @12:34PM (#29797395)
But now the traits aren't connected with drums (or sticks) but MusicParts. Or you end up having some `drum.foo` too.