News for hackers. Stuff that matters.
Re:Using Altair for most of my visualization in Python by sleavey on Tuesday May 07, 2019 @02:35AM (#19847109)
In the grand scheme of things it's a minor gripe, but I really dislike APIs that encourage chaining of calls like `alt.Chart(data).mark_circle(size=200).encode(...)` from the article. This is found in many other libraries, especially JavaScript ones like e.g. jQuery. I know it's compact, but it makes it harder to see what's going on and hides the fact that all of the operations are actually being applied to the leftmost object.
Re:Using Altair for most of my visualization in Python by arnsholt on Tuesday May 07, 2019 @02:50AM (#19847158)
SmallTalk has the correct answer here, with its method chaining operator `;`, I feel. For cases like this where you build complex state on an object via method calls, it gives some pretty nice code. And since it's a separate construct, the individual method calls can have return values that make sense too, as opposed to this style of interface where the methods all have to return the object again for chaining.