July 5, 2026
Chord wars hit the comments
Optimizing an Algorithm That's Quadratic by Design
This chord app’s “simple” brain sparked a full-on comments section meltdown
TLDR: A chord-naming app found that nearly all its slowdown comes from ranking multiple possible answers, not detecting the notes themselves. In the comments, readers immediately turned it into a mini-drama over confusing rule loops, tie-breakers, and the irresistible lure of speed-hacking tricks.
A music app that listens to your keyboard and tells you what chord you played has accidentally wandered into main-character energy territory. The developer says the real problem isn’t recognizing notes — it’s deciding which chord name should come first when several answers are technically valid. And here’s the twist: the app’s ranking logic is built so that one choice can beat a second, the second can beat a third, and the third can still beat the first. In normal-person terms, the app created a little rock-paper-scissors fight inside its own brain, and that made the comments absolutely perk up.
The loudest reaction was basically: “Wait, what kind of rules are these?” Commenter chaoxu jumped in like a detective, trying to untangle whether the weird loop comes from the app’s special override rules alone or from those rules colliding with the score system. It’s the kind of comment that says, “I’m not mad, I’m just drawing diagrams now,” which is honestly peak internet engineer drama. Meanwhile gopalv saw the mention of bitmasks — a speedy way to track which rules apply — and immediately got that familiar coder gleam in the eye: once I see a bit-mask loop… You can practically hear the optimization gremlins warming up.
So yes, the article is about making a music app faster. But the real show is the crowd reaction: one side treating it like a deep philosophy debate about rules and fairness, the other treating it like catnip for performance nerds. The vibe is half jam session, half courtroom cross-examination, with a little “someone is definitely opening a whiteboard” chaos on top.
Key Points
- •WhatChord names chords from MIDI keyboard input by generating, scoring, and ranking multiple possible chord interpretations rather than performing a simple dictionary lookup.
- •The article distinguishes between a voicing, which includes the exact notes and bass note played, and a candidate, which is one possible chord name for that voicing.
- •Benchmarking showed that on a cache miss the ranking stage uses roughly 99% of runtime, while scoring uses about 1%.
- •A standard sort cannot be used because WhatChord’s comparator is intentionally non-transitive due to hard musical rules and near-tie heuristics.
- •The engine instead builds a full pairwise `beats` matrix and linearizes the resulting relation, breaking cycles with a Copeland-style win-count.