frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Why is D3 so Verbose?

https://theheasman.com/short_stories/why-is-d3-code-so-long-and-complicated-or-why-is-it-so-verbose/
53•TheHeasman•7h ago

Comments

esafak•3h ago
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.

lionkor•2h ago
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.

esafak•2h ago
Speaking for myself, when it comes to D3 the problem is being locked out :)
lenerdenator•3h ago
More granular control, more verbosity.

I am still proud of the D3 gadget I made about 8 years back as a green web dev. Couldn't have made it any other way, not sure if I could with any other library today. Wouldn't want to do it again, though, unless I was a dedicated front-end guy.

moron4hire•3h ago
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 of plugins. Everytime I've tried to use it, I've not found the documentation leading me to using anything more specifically oriented towards charting.

digitalWestie•2h ago
This is the answer. People need to consider D3 more as a graphics/dom manipulation library than a charting library.
gedy•1h ago
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.
TheHeasman•1h ago
Yaaasss. I think of it as being able to use a pencil to draw charts (and do creative stuff like Florence Nightingale's original polar area graph), instead of having a stencil that can draw things for you. It's a way to visually manipulate the DOM in a way if you're comfortable with data.

You can simply just use Tableau or Power BI and take screenshots otherwise.

joshcartme•1h ago
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.
tmcw•3h ago
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...
TheHeasman•1h ago
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.
fwip•47m ago
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.

balamatom•3h ago
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.
DanielHB•2h ago
what do you mean by "arrow operator"?
lionkor•2h ago
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.
DanielHB•1h ago
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

amiga386•2h ago
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?

balamatom•1h ago
Bingo.
TheHeasman•2h ago
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).

balamatom•1h ago
And I know more about JavaScript than I'd like to, so don't trust me.
tomku•1h ago
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

biowaffeln•2h ago
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
TheHeasman•1h ago
I'll check that out. At the moment I'm just building up a bunch of template code which I'll re-use. But might check out solid.js.
text0404•2h ago
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)
TheHeasman•2h ago
This is very fair: I went for a metaphorical explanation, rather than a literal one. (For instance, I'd actually have had to write down the code for an SVG, and I was quickly writing this on my lunch break).

The `.selectAll().data().join()` data binding method (or `.enter()` on older versions) is very intuitive once you understand it, but for the layman coming in, it's inaccessible AF. I fudged a little in my explanation to make it more accessible. But hey. That's learning.

text0404•1h ago
For sure, data joining (and enter/exit) is arguably the learning curve wrt D3. TBH since I've started using FE frameworks which handle the DOM, d3-selection (and having to think about data binding) has almost completely fallen off my radar. Now it's mostly using functions from d3-scale, d3-geo, d3-shape, etc then mapping over that output to manually render DOM nodes.
bapak•59m ago
> 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.

yieldcrv•2h ago
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.

z3ratul163071•2h ago
the author was inspired by early directx apis
thrown-0825•2h ago
I love D3, but its a library not a language.
TheHeasman•2h ago
Agreed. I fudged quite a lot in my post to make it accessible to the layman. Triee to explain to a UX designer I know that "D3 is a library for JavaScript that..." And I saw their brain switch off live in front of me.

Semantics matter more than literals sometimes.

*EDIT: Grammar. I was typing on my phone. Soz.

moron4hire•34m ago
D3 is a good example of inventing a language without inventing a syntax for that language. It very much is a DSL implemented in JavaScript.
thrown-0825•31m ago
ok, I'll buy that, definitely feels like it
ramesh31•1h ago
Because the alternative is big config files or a declarative DSL. Builder pattern works really well here to keep things simple.
trjordan•1h ago
Man, my first startup in 2010 used protovis, the charting library Mike Bostock built before deciding d3 was the better approach. It was rough to have an 8 month old startup with a core piece of tech that suddenly stopped improving.

My main takeaway from so much of this is that "just a chart" is one of the biggest sources of hidden complexity in displaying useful information to people. It's right up there with "a simple web form" and "a web page with some simple interactivity."

Everybody has a wildly different idea of what good looks like. Defaults will never be right. Personal and global taste changes annually. We clown react (rightly) for constantly reinventing the same 4 wheels, but customers gleefully use new stuff all the time.

It's kind of amazing that d3 has been so durable in the frontend world. It really is a wrapper over a pretty solid approach. And yeah, that approach is complex, but that's the reality of visualization. It's hard to imagine another one that's that good.

time4tea•47m ago
Observable plot.

https://observablehq.com/plot/

dleeftink•27m ago
Verbosity is readability. I'd wager some of the terser libraries take more effort picking up again after leaving them for a while.

Whereas once th3 D3 training wheels come off, its muscle memory is hard to shed.

sitzkrieg•17m ago
came to post this. verbose good (to an extent)
jwilber•19m ago
Love all D3 content, but I'd add that the data binding just to create svg is not the real reason - after all, you can do this declaratively using most modern frameworks by directly iterating over the data and returning a positioned element (fwiw this is how I prefer to use it today). The reason is because of the complexity within d3 selection, namely the enter/update/exit + transition capabilities: https://www.d3indepth.com/enterexit/

Another thing worth mentioning that newcomers seem to take for granted - the margin boilerplate required for correct positioning (see https://observablehq.com/@d3/margin-convention).

Apple Watch wearable foundation model

https://arxiv.org/abs/2507.00191
104•brandonb•2h ago•12 comments

AWS CEO says using AI to replace junior staff is 'Dumbest thing I've ever heard'

https://www.theregister.com/2025/08/21/aws_ceo_entry_level_jobs_opinion/
960•JustExAWS•4h ago•342 comments

95% of Companies See 'Zero Return' on $30B Generative AI Spend

https://thedailyadda.com/95-of-companies-see-zero-return-on-30-billion-generative-ai-spend-mit-report-finds/
272•speckx•1h ago•258 comments

Unity reintroduces the Runtime Fee through its Industry license

https://unity.com/products/unity-industry
87•finnsquared•2h ago•25 comments

Weaponizing image scaling against production AI systems

https://blog.trailofbits.com/2025/08/21/weaponizing-image-scaling-against-production-ai-systems/
170•tatersolid•5h ago•45 comments

Using Podman, Compose and BuildKit

https://emersion.fr/blog/2025/using-podman-compose-and-buildkit/
169•LaSombra•6h ago•37 comments

Cua (YC X25) Is Hiring Founding Design Engineers in SF

https://www.ycombinator.com/companies/cua/jobs/a6UbTvG-founding-engineer-ux-design
1•frabonacci•20m ago

Unmasking the Privacy Risks of Apple Intelligence

https://www.lumia.security/blog/applestorm
31•mroi•1h ago•3 comments

D4d4

https://www.nmichaels.org/musings/d4d4/d4d4/
370•csense•4d ago•44 comments

Show HN: OS X Mavericks Forever

https://mavericksforever.com/
198•Wowfunhappy•3d ago•79 comments

Adding my home electricity uptime to status.href.cat

https://aggressivelyparaphrasing.me/2025/08/21/adding-my-home-electricity-uptime-to-status-href-cat/
10•todsacerdoti•1h ago•4 comments

Launch HN: Skope (YC S25) – Outcome-based pricing for software products

17•benjsm•2h ago•10 comments

Bank forced to rehire workers after lying about chatbot productivity, union says

https://arstechnica.com/tech-policy/2025/08/bank-forced-to-rehire-workers-after-lying-about-chatbot-productivity-union-says/
67•ndsipa_pomu•1h ago•10 comments

Show HN: ChartDB Cloud – Visualize and Share Database Diagrams

https://app.chartdb.io
52•Jonathanfishner•4h ago•7 comments

Mark Zuckerberg freezes AI hiring amid bubble fears

https://www.telegraph.co.uk/business/2025/08/21/zuckerberg-freezes-ai-hiring-amid-bubble-fears/
439•pera•6h ago•423 comments

Show HN: Using Common Lisp from Inside the Browser

https://turtleware.eu/posts/Using-Common-Lisp-from-inside-the-Browser.html
67•jackdaniel•5h ago•8 comments

Forced every engineer to take sales calls.They rewrote our platform in 2 weeks

https://old.reddit.com/r/Entrepreneur/comments/1mw5yfg/forced_every_engineer_to_take_sales_calls_they/
73•bilsbie•1h ago•37 comments

How Well Does the Money Laundering Control System Work?

https://www.journals.uchicago.edu/doi/10.1086/735665
127•PaulHoule•4h ago•112 comments

You Should Add Debug Views to Your DB

https://chrispenner.ca/posts/views-for-debugging
35•ezekg•3d ago•12 comments

Why is D3 so Verbose?

https://theheasman.com/short_stories/why-is-d3-code-so-long-and-complicated-or-why-is-it-so-verbose/
54•TheHeasman•7h ago•39 comments

Margin debt surges to record high

https://www.advisorperspectives.com/dshort/updates/2025/07/23/margin-debt-surges-record-high-june-2025
148•pera•5h ago•192 comments

Unification (2018)

https://eli.thegreenplace.net/2018/unification/
66•asplake•3d ago•13 comments

AI crawlers, fetchers are blowing up websites; Meta, OpenAI are worst offenders

https://www.theregister.com/2025/08/21/ai_crawler_traffic/
162•rntn•5h ago•75 comments

Home Depot sued for 'secretly' using facial recognition at self-checkouts

https://petapixel.com/2025/08/20/home-depot-sued-for-secretly-using-facial-recognition-technology-on-self-checkout-cameras/
307•mikece•1d ago•417 comments

A summary of recent AI research (2016)

https://blog.plan99.net/the-science-of-westworld-ec624585e47
4•mike_hearn•1h ago•0 comments

Show HN: I replaced vector databases with Git for AI memory (PoC)

https://github.com/Growth-Kinetics/DiffMem
158•alexmrv•11h ago•36 comments

A Conceptual Model for Storage Unification

https://jack-vanlightly.com/blog/2025/8/21/a-conceptual-model-for-storage-unification
18•avinassh•4h ago•1 comments

Epson MX-80 Fonts

https://mw.rat.bz/MX-80/
156•m_walden•4d ago•57 comments

Sixteen bottles of wine riddle

https://chriskw.xyz/2025/08/11/Wine/
43•chriskw•4d ago•23 comments

A statistical analysis of Rotten Tomatoes

https://www.statsignificant.com/p/is-rotten-tomatoes-still-reliable
206•m463•17h ago•126 comments