Re:Plotnine
by CuriouslyC on Tuesday June 23, 2026 @12:06PM
(#48647152)
Honestly operator overloading is almost always a bad choice IMO. There are cases (e.g. matrix math) where it's the right choice because of semantic clarity, but the indirection it creates in exchange for readability is costly. It's always obvious when a function is being called, and how to navigate to the implementation, but the same is not true of overloaded operators.
Re:Plotnine
by AnimalMuppet on Tuesday June 23, 2026 @12:14PM
(#48647271)
Well, it's like most tools. For this particular use, does it give more than it takes? If so, use it.
Matrix multiplication? Yeah, everybody knows there's a function being called. And, if it was implemented right, the users almost never have to look at the implementation.
Many other possible uses? Nope. Just nope. Not worth it.
And how do you express that as arithmetic?
I can get as far as `plot() / 3` but then no idea how to proceed. I don't think overloading arithmetic is a very good way to express this.
Re:Plotnine
by bittumenEntity on Tuesday June 23, 2026 @10:53AM
(#48645969)
Isn't this somewhat the point of python's override capability? You can exactly define what addition means here, just like you have to define what addition means for a matrix or another data structure.
Separately you might find this to be smelly design, but then you should remember that this at least has precedence ¯\_(ツ)_/¯
kwargs exists, and is rather more pythonic. Just pass the kwargs dict to a standard formatting function, et voila.
Re:Plotnine
by bittumenEntity on Tuesday June 23, 2026 @10:55AM
(#48646000)
Sadly, this drive towards the API design that matplotlib resembles, the raison d'etre of this library is the unusual (imho, great) API
On the other hand, declaring the options through composition means that the API for "plot" remains static, and adding/removing options can be done trivially without an API change.
Composition (rather than parameters) is also more flexible. Let's say you want to divide your plot into three sub-plots, two of which are 200x200, and another which is 200x400. How do you express this as a keyword parameter? In composition, you could do something like:
plot( ggsubplot(ggvsplit(ggsize(200,400), gghsplit(ggsize(200,200), ggsize(200,200)))) )