RU version is available. Content is displayed in original English for accuracy.
Advertisement
Advertisement
⚡ Community Insights
Discussion Sentiment
72% Positive
Analyzed from 2126 words in the discussion.
Trending Topics
#diffs#scrolling#diff#rendering#more#browser#code#large#should#https

Discussion (65 Comments)Read Original on HackerNews
If I were to pick one problem with the presentation, it would rather be the font-size (12px is unequivocally too small), or the use of monospace (simply unsuitable for body text).
And incidentally, HN suffers from two of these three problems.
When it was common, columns weren't so thin I think
At the end, I admire the craft and patience to try to solve code diff rendering, and wish the folks at GitHub could put the same effort to improve their platform.
On a side note, I feel that we’re going to see more and more of this type of agentic usage, in well defined sub tasks, and the ability of a model to try many possibilities is a huge gift here.
Also ... shouldn't browsers just be able to render the diff without any of the trickery? Is the browser's job actually that hard for long pages, or are they just not optimising for this? Or is there some other reason for the virtualisation (e.g. memory usage)?
The only time you will is if you’re scrolling at a rate where the jumps are quite large — large and fast enough typically where you’re not going to have a frame of reference for what you should see vs what you are seeing to notice you are behind.
Ultimately scrolling is managed on a separate thread from JS, which means if you do like an opt+click on the scroll bar, you’re going to make a jump that JavaScript can never keep up with, even if you’re under your frame times.
And with regards to safari, if your requestAnimationFrame is capped at 60hz but your scrolling is GPU composited at 120hz, this is the only way to keep scrolling at 120hz with 60hz dom updates and never see any blanking.
And yes, browsers should be just able to render the diffs, if the styling is somewhat minimal and there is no JS: I have a 6.3-MiB large HTML file with complete transcript of a certain TV series, formatted like
(the </dl><dl> produces a small paragraph break, to indicate scene transitions), and it scrolls and searches just fine.My main bottleneck is that I do a complete diff on all open + changed documents in the repository up front, because due to how document properties are stored, I won't know if the file has meaningful changes until I compute the full diff (FreeCAD may save the document, but not have anything meaningful change.)
[0] https://github.com/eblanshey/HistoryWorkbench
IMO (as someone who doesn't have to deal with the actual rendering) it would go a bit deeper into talking about deciding how to show what has changed. There's a lot of improvements that could be made there. e.g. "whitespace has changed here" so there's no real code changes involved.
Or "this big list of imports has changed, and code formatting has line-wrapped the list into different lines" - gitlab for example copes poorly with this. I'd love to just see a clean diff that highlights the additional import, and not just ten lines of changes caused by adding one line to a big list of imported symbols/functions.
difftastic, semanticdiff.. lots of projects like that. Obviously they can offer stuff like "function name changed" instead of showing you 30 lines of +newName -oldName
Any views they have on this topic is going to come across as quite opinionated given their choices for text rendering for this post and general aesthetics of website.
On mobile it kinda does. Scrolling diffs on mobile just kinda feels crap.
I have been spoiled by years of engineer hours spent getting scrolling to be 60- or even 120Hz smooth to match my finger, and diffs just.. isn't.
I know this is frustrating to hear, and that this is technically compounded by mobile probably having the lowest device performance to be playing with too, but.. There you go.
It's possible you might be misunderstanding what I was trying to say here because 120hz scrolling on a 120hz device was the goal and why one of those virtualization techniques was not acceptable to me which lead me to coming up with a novel workaround to this problem (Inverse Sticky Technique).
CodeView uses a system that allows scrolling to update at your native framerate (120hz) WITHOUT needing Javascript needing to keep up at 120hz. If you're seeing stuttering while scrolling on https://diffshub.com would love to know more context (device/diff link/etc) because that is very much NOT our experience.
It's not unuseable, but it definitely feels like 'js hacking my scrolling' and not a native surface flinging around.
The experience is actually worse with smaller movements, i guess because my brain is more conscious when breaking the 'finger physically moving the text' illusion.
I don't mean to be dismissive - you're working on a really hard problem, and you're clearly approaching it with a mindset of perfection. I'm posting because I know you're probably able to solve this too :)
Edit: as a point of (unfair) comparison, the codemirror Huge File demo works fine: https://codemirror.net/examples/million/ It does suffer from the occasional partial paint when quickly coasting, but I'm not bothered by this at all, it's far less intrusive than dropping frames / stuttering / etc.
Just to be clear tho, we don't actually scroll jack, native scrolling works as it should and content should move with normal gpu composited scroll. That said, it's possible that loading that much data into memory may be causing causing knock on effects somehow that are just slowing everything down.
(I say this, having done a vibe-port of the code to a browser extension, so the underlying concept works.)
I'm still stuck with (k)diff3, and, while they work, I would really like to a more integrate web interface for my projects
https://repo.autonoma.ca/repo/treetrek/commit/3fe9360599ae23...
The diffs rendering library looks amazing: https://diffs.com/
Presumably the red-green issue is a simple CSS update?
Of course. It’s often Safari.
something i'd really want to see from forges is alternate diff techniques: like AST diffing.
That said though, and maybe I didn't say it well in the post, the more performant and optimized your tool is, the less burden you put on developers and users.
Sure you won't review 100k lines, but maybe the diff includes a ton of testing snapshots, or maybe it's a long running feature branch and you need to just quickly jump in and look at a specific change from a specific file. The less the developer or the user needs to think about `how` to render the diff or `how to navigate the diff`, the better we did our job.
For a brief hopeful moment, I thought this was the .io kind of sandstorm
However passing a million lines of code through pretext is unlikely to be very efficient, so a lot of the work around estimation is still very important.
That said, while I don't want to make pretext a direct dependency of the library, there's a good chance I'll explore the possibility of allowing devs to pass it in as an additional argument perhaps improve performance a bit.
It should also be noted that we have a full API to support things like line annotations (comments, etc) that are entirely controlled by the user, so there's always a bit of a dynamic aspect there that would come into play
Computers are very powerful these days and have a done of resources that they can use. We should be able to handle large diffs without any crazy tricks.
How would you handle it?
You can't say "only rendering what is visible should be handled by the browser" and call that a solution unless you have a magic wand to make Chrome/other browsers do this.
The browser doesn't do this, and so you can either do what you say and have your browser freeze when you load up a million line diff, or you can fix things within your control which is what the author is doing.
I believe we're just making everything harder than it needs by constraining it to a browser interface. This would be trivial as a terminal application written in native code.
Whether or not it would be "trivial" in a native terminal application is irrelevant.