Skip to content
HN On Hacker News ↗

On Rendering Diffs

▲ 210 points 69 comments by amadeus 4w ago HN discussion ↗

Pangram verdict · v3.3

We believe that this document is primarily human-written, with a small amount of AI content detected

11 %

AI likelihood · overall

Human
95% human-written 5% AI-generated
SEGMENTS · HUMAN 7 of 7
SEGMENTS · AI 0 of 7
WORD COUNT 1,478
PEAK AI % 14% · §2
Analyzed
May 29
backend: pangram/v3.3
Segments scanned
7 windows
avg 211 words each
Distribution
95 / 5%
human / AI fraction
Verdict
Human
Pangram v3.3

Article text · 1,478 words · 7 segments analyzed

Human AI-generated
§1 Human · 8%

PIERRE COMPUTER COMPANY █

Posted on May 29, 2026 by @amadeus

██████╗ ██╗███████╗███████╗███████╗ ██╔══██╗██║██╔════╝██╔════╝██╔════╝ ██████████╗ ██║ ██║██║█████╗ █████╗ ███████╗ ╚═════════╝ ██║ ██║██║██╔══╝ ██╔══╝ ╚════██║ ██████╔╝██║██║ ██║ ███████║ ╚═════╝ ╚═╝╚═╝ ╚═╝ ╚══════╝

██╗ ██████╗ ██╗███████╗███████╗███████╗ ██║ ██╔══██╗██║██╔════╝██╔════╝██╔════╝

§2 Human · 14%

██████████╗ ██║ ██║██║█████╗ █████╗ ███████╗ ╚═══██╔═══╝ ██║ ██║██║██╔══╝ ██╔══╝ ╚════██║ ██║ ██████╔╝██║██║ ██║ ███████║ ╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═╝ ╚══════╝

You open a pull request expecting to understand what changed. For small and medium changes, everything works. The code is readable, the files are there, you scroll around, add comments, and it’s all pretty seamless. Then you open something larger. Maybe an agent generated the implementation, tests, fixtures, and snapshots. Maybe the branch just touched more files than expected. Either way, the review surface starts to degrade. It might only show you one file at a time, or require each file to be loaded separately before you can read it, or even make basic navigation feel sluggish. Some of these are reasonable trade-offs for genuinely hard problems. But they still have a cost: reviewers feel the limits of the tool, and product teams have to build workarounds for these limits. Diff rendering matters, but for most tools it is not the product. The product is what happens around the code: review workflows, automation, agent output, CI results, and collaboration.

§3 Human · 2%

Code review should support that work, not become something every team has to build from scratch. That is why, about 6 months ago, we released Diffs. Our goal was to make the code and diff rendering part just work, so teams could spend their time on the product around it. Originally we launched with just the basic pieces: File and FileDiff components. We quickly got feedback about performance issues, so we followed up with a simple virtualizer that avoided rendering code when it was out of view and an API to move syntax highlighting into worker threads. The simple virtualizer helped, but it was a stopgap. There was still a lot of O(n×m) complexity, high memory usage, and virtualization blanking. What was missing was a higher-level component that could manage an entire review surface and handle the hard problems related to scale. That missing layer became CodeView: a virtualization-first component for reviewing code and diffs. And we built it around a deliberately impossible goal: You should be able to just render any diff. Not literally, of course. There are physical limits to browsers, compute, and memory. But practically speaking, I think we’ve come pretty close, and I’d like to share a bit about how we got there. If you find long-form blog posts boring, go check out the CodeView playground at DiffsHub.com where you can pretty much view any PR or diff that GitHub will send our way. Nearly any diff, at any scale, nearly instantly. diffshub[dot]com Take any public diff from GitHub and virtualize it nearly instantly, no matter how large, with DiffsHub. Built to show off our brand new CodeView component. To try it out, replace `github` with `diffshub` in your address bar.

§4 Human · 4%

pic.twitter.com/5X30YwbpHn — Pierre (@pierrecomputer) May 20, 2026 You can check out the CodeView component and more in the latest version of the diffs package on npm: @pierre/diffs, or read the docs.

DIFFS LOOK SIMPLE UNTIL THEY ARE NOT On the surface, rendering diffs in a browser may not seem very hard. It’s just text, right? Browsers are purpose-built to take raw HTML and turn that into something you can look at and interact with. Code is just text, after all. But a good review surface needs more than text. It needs syntax highlighting, line numbers, annotations, comments, theming, split and unified layouts, wrapping modes, and enough customization to fit into someone else’s product. Each of those features adds cost and complexity. Syntax highlighting adds processing time and inflates DOM count. Comments involve additional layout complexity that we can’t fully control, and they still have to work seamlessly with your existing design system. With CodeView, we take that per-file complexity and scale it up; work that was cheap for a single diff now has meaningful cost across a large review. We can roughly break down the problems into three categories: Rendering — DOM complexity grows quickly, and the browser can become overloaded while scrolling or interacting with the page. Processing — Every file or diff operation gets multiplied, so work that was fast in isolation can become expensive when repeated thousands of times. Memory — Large files and diffs get transformed into rendering data structures, which can push against browser memory limits and make garbage collection more frequent. Our simple virtualizer helped with some rendering problems, and moving highlighting off the main thread helped with parts of the processing problem.

§5 Human · 12%

But CodeView needed to treat rendering, memory, and processing as connected parts of the same problem.

VIRTUALIZATION Virtualization, or windowing, is a way of tackling the rendering problem. In its simplest form, the idea is to only render the part of the content near the viewport. As you scroll, the virtualizer renders the new content coming into view and removes content that has moved off screen. Keeping the DOM small has a lot of benefits: lower memory usage, less layout work, less paint work, and fewer elements for the browser to manage. The trade-off is that the virtualizer has to estimate or measure how tall everything is, and it must coordinate those changes dynamically. One thing that adds to this complexity is that browsers generally manage scroll compositing separately from JavaScript execution. This can help scrolling feel more responsive to user interactions, but it also means that JavaScript can easily lag behind scroll updates. This is often most noticeable when using the scrollbar to make large jumps or scrolling extremely quickly — the virtualizer can’t keep up and you’ll scroll into blank regions before the JavaScript has time to render the updated content. Click to see blanking in the old virtualizer

Common Virtualization Techniques There are a few common ways to virtualize content in a browser, and each comes with its own set of trade-offs. The most common approach is to create a real scrollable region with the full estimated height of the content, then position the visible items where they belong. This keeps scrolling native: the scrollbar, momentum, input handling, and accessibility all stay with the browser. The trade-off is that the rendered window can fall behind the visual scroll position. Fast scrolls and large scrollbar jumps can expose blank space before JavaScript has a chance to render the next range.

§6 Human · 14%

You can reduce that by rendering a larger buffer outside the viewport, but that gives back some of the DOM, layout, and memory savings that virtualization was supposed to buy you. Another approach is to keep the visible content in a sticky or fixed container and update what it shows with requestAnimationFrame. In this model, blanking is impossible: the content container cannot scroll out of view because it’s not moving with the scroll position; it just looks like it is. However, if JavaScript cannot keep up, then scrolling can hitch or stutter because JavaScript is now part of the render update path. Browser behavior matters here too. Safari, for example, currently caps requestAnimationFrame at 60Hz even on higher refresh-rate displays, which makes this approach feel worse than native scrolling on those devices. A more extreme version is to emulate scrolling entirely: no native scrollable region, just a custom viewport, a fake scrollbar, and content updated via requestAnimationFrame as the user moves through the document.

§7 Human · 1%

This can avoid browser scroll-size limits because the scroll position is now your own state, not the browser’s. But the cost is larger: you now own the details of making scrolling feel native, accessible, and correct across different operating systems and browsers.

The Inverse Sticky Technique For CodeView, many of those virtualization trade-offs were not acceptable. Native browser scrolling mattered. WebKit-based environments needed to feel good because Tauri is a common target for developer tools. And blanking was not an option. This left us stuck between different approaches that weren’t quite right. After some experimentation and frustration, we figured out a hybrid approach that could keep scrolling native, mostly decouple positioning from requestAnimationFrame updates, and make blanking effectively impossible. We’ve called our new technique the Inverse Sticky Technique, but before we talk about how it works, first a quick primer on how sticky positioning works. The typical use case for sticky positioning is ensuring that section headers in a scrollable list stay in view as you scroll through it. You set position: sticky; top: 0 on your section headers and then when they should normally be scrolled out of view, they stay fixed to the top of the scroll view as the content below scrolls underneath. Section Title 1 (stuck) Item 1 Item 2 Item 3 Item 4 Item 5 Section Title 2 (stuck) Item 6 Item 7 Item 8 Item 9 Item 10