Live data from Hacker News

Why is D3 so Verbose?

theheasman.com

11–20 of 75 posts

Re: Why is D3 so Verbose?

#11
post #8

I'd say because JavaScript is insufficiently expressive. No macros, no arrow (pipe) operator, and the premier way of writing it is 4x as verbose than what I'd consider reasonable. D3 is a great library though.

what do you mean by "arrow operator"?

Maybe overloadable operators like in C++, where -> usually demotes some kind of deeper access into the object or abstraction? Or, the opposite, and abstracted access.

Re: Why is D3 so Verbose?

#12
post #10
post #2

I feel like D3 ought to be the for-computer substrate for libraries that are actually for humans. I suppose it matters less now in the LLM age.

If your LLM is the only one that can reasonably maintain your software, you essentially created a new kind of lock-in, similar to what we already solved with open source a long, long time ago. Once your LLM gets too expensive, goes out of business, and the competitors just don't quite do it the way your favorite LLM does it, you have a problem.

Speaking for myself, when it comes to D3 the problem is being locked out :)

Re: Why is D3 so Verbose?

#13

This is why I've always found it weird that people consider D3 to be a charting tool. Yes, people have used it to build a lot of charts, but it's really just a streaming data processing tool. It doesn't provide anything specific to charting[0]. All of that part, you're still left to figure out on your own. [0] At least in the core, I'm not too familiar with the full ecosystem and what is considered official in terms…

This is the answer. People need to consider D3 more as a graphics/dom manipulation library than a charting library.

Re: Why is D3 so Verbose?

#14

This is why I've always found it weird that people consider D3 to be a charting tool. Yes, people have used it to build a lot of charts, but it's really just a streaming data processing tool. It doesn't provide anything specific to charting[0]. All of that part, you're still left to figure out on your own. [0] At least in the core, I'm not too familiar with the full ecosystem and what is considered official in terms…

This is the answer. People need to consider D3 more as a graphics/dom manipulation library than a charting library.

[deleted]

Re: Why is D3 so Verbose?

#15
recently i've been having a lot of success with working with d3 + solid.js. I use d3 as the data processing layer, and solid for actually rendering svgs from the data. the combination is lovely, you get all the power of d3, while the parts that usually end up verbose are written succinctly in jsx. and it's a lot less pain than doing it in react, because the mental models of solid/d3 feel much more aligned

Re: Why is D3 so Verbose?

#16
Note: the example is a misconception and not what's meant by "binding to data." In D3, binding to data refers to using the `.data()` method to supply an object (typically an array) which you can then use in a function callback in the accessors, so like `.attr('x1', d => /* access individual array item here */)`. This allows you to easily bind a dataset to a graphical representation and use its attributes to inform the properties of the visualization.

I'd also argue that D3 is no more verbose than vanilla JS (at least for this example). What's the alternative for creating a line in SVG?

    const line = document.createElementNS('http://www.w3.org/2000/svg', 'line')
    line.setAttribute('x1', ...)
    line.setAttribute('y1', ...)
    line.setAttribute('x2', ...)
    line.setAttribute('y2', ...)
    // etc
    document.querySelector('svg').appendChild(line)

Re: Why is D3 so Verbose?

#17
post #8

I'd say because JavaScript is insufficiently expressive. No macros, no arrow (pipe) operator, and the premier way of writing it is 4x as verbose than what I'd consider reasonable. D3 is a great library though.

what do you mean by "arrow operator"?

Probably a reference to Clojure's arrow operator:

https://blog.frankel.ch/learning-clojure/2/

Something like a(b(c(d(e(7)))))) in Javascript could be written (-> 7 e d c b a) in Clojure?

Re: Why is D3 so Verbose?

#19
D3 is painful, we don't have to appeal to authority to admit that.

Mike Bostock is an interesting person, and a case study in why we don't design languages from a single person's genius.

Post reply on HN