Live data from Hacker News

Why is D3 so Verbose?

theheasman.com

31–40 of 75 posts

Re: Why is D3 so Verbose?

#31
post #11
post #8

Earlier quoted context omitted.

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.

That is what I thought, but that doesn't make sense for a language without pointers

According to the other comment it seems he meant the |> pipe operator that is under proposal in js

Re: Why is D3 so Verbose?

#32
post #8

Earlier quoted context omitted.

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?

Bingo.

Re: Why is D3 so Verbose?

#33

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.

Uh, there are arrow operators in JS. D3.JS in Action Third Edition exclusively uses arrow operators. (Trust me. I don't know jack about JavaScript, I had to get through the MDN docs to understand what they were, and once I did, made a whole lot more sense).

And I know more about JavaScript than I'd like to, so don't trust me.

Re: Why is D3 so Verbose?

#34

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.

Yeah I used to pull my hair when a team would start down the D3 path for some non-interactive graphic, and then push back when I'd explain you can just use SVG for this simple case.

Re: Why is D3 so Verbose?

#35

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…

At least these days I think Plot, https://observablehq.com/plot/getting-started, which uses D3 under the hood and is from the makers of D3, is probably the closest thing to an official charting tool built on top of D3.

Re: Why is D3 so Verbose?

#36

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.

Uh, there are arrow operators in JS. D3.JS in Action Third Edition exclusively uses arrow operators. (Trust me. I don't know jack about JavaScript, I had to get through the MDN docs to understand what they were, and once I did, made a whole lot more sense).

The feature the person you're replying to is talking about is not arrow functions (`=>`), but what are called "threading macros" in other languages. In Clojure[1], the main one is named `->` and used as a way to thread a value through a series of functions that take it as a first argument, using the return value from the first function as the first argument to the second, and so on. It allows you to compose a series of plain functions to transform a value instead of (stateful) method chaining or nesting functions.

JS does not have a straightforward equivalent. The old and deprecated `with` keyword might seem similar but it's only a surface resemblance as it does not perform the return-value threading that makes the above pattern useful, it was meant for methods that mutate object state. There's a TC39 proposal[2] to add a pipe operator that would accomplish a similar thing to threading macros via an infix operator but it's still a draft.

[1]: https://clojure.org/guides/threading_macros

[2]: https://github.com/tc39/proposal-pipeline-operator

Re: Why is D3 so Verbose?

#37

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 th…

> I'd also argue that D3 is no more verbose than vanilla JS

Right? So why load a bunch of JS to do the same thing? One step further, why load any JS at all since you're just generating an SVG? People have forgotten that HTML and SVG are meant to be DATA containers, you don't have to use JSON + JS.

D3 is cool for the advanced visualizations and the interactivity. If you're sticking to static graphs, for the love of god just have the server serve a static SVG.

Re: Why is D3 so Verbose?

#38
post #37

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 th…

> I'd also argue that D3 is no more verbose than vanilla JS Right? So why load a bunch of JS to do the same thing? One step further, why load any JS at all since you're just generating an SVG? People have forgotten that HTML and SVG are meant to be DATA containers, you don't have to use JSON + JS. D3 is cool for the advanced visualizations and the interactivity. If you're sticking to static graphs, for the love of go…

[deleted]

Re: Why is D3 so Verbose?

#40
post #6

All right, I got nerdsniped into writing a "yes and" sort of thing even though I agree with the gist of this article :) https://macwright.com/2025/08/21/why-d3-is-so-verbose-anothe...

Ahhhhh. Thanks man. And totally nerding out here because YES. ANIMATIONS. Animations is why I fell in love with wanting to learn D3 in 2019. You can do things as you transition between data steps, that honestly, has been such a pain in the behind to try with anything else. I'm not a web developer. I'm a data guy.

Speaking of animations, I used D3 to build my first web video game, a little match-3 game: https://fwip.github.io/colormatch/ The whole game board is a single SVG.

It clearly has some bugs (like the score sometimes being NaN - no idea how I messed that up), but I haven't touched the code in over a decade, so it's a little time capsule.

Post reply on HN