Live data from Hacker News

27.5KB language-agnostic WebGPU syntax highlighter

gpu-lexer.vercel.app

11–20 of 39 posts

Re: 27.5KB language-agnostic WebGPU syntax highlighter

#11
If anyone can get in contact with Shu, please let them know I'd really like to speak with them. I have a deterministic rendering / colorizing system in three dimensions instead of two for arbitrary UTF8 text written that is explicitly GPU bound and currently testing the last Rust + Mojo pair port, and I'd like to share some ideas. I have about 95 million glyphs rendering (monospace, atm) in a little under a second with full multi dimensional pagination and colorizing per-glyph with full addressing capabilities. There's something to be combined with these two mechanisms I'd like to try and explore.

Re: 27.5KB language-agnostic WebGPU syntax highlighter

#13

If anyone can get in contact with Shu, please let them know I'd really like to speak with them. I have a deterministic rendering / colorizing system in three dimensions instead of two for arbitrary UTF8 text written that is explicitly GPU bound and currently testing the last Rust + Mojo pair port, and I'd like to share some ideas. I have about 95 million glyphs rendering (monospace, atm) in a little under a second wi…

g@shud.in was listed as contact email on his older portfolio

Re: 27.5KB language-agnostic WebGPU syntax highlighter

#14
post #6

Earlier quoted context omitted.

The use case isn't highlighting a huge amount of code, but local re-entrant highlighting. You generally never need to highlight a whole file, only the part you're looking at. Which by definition must be fuzzy since you don't have the full source, the part you see will not parse as a complete program so you need to guess. This is actually one of the nastier parts of writing a highlighter, and it must be done for every…

Is that really the use case for the related packages mentioned on their website? highlightjs and prismjs are typically used to highlight code snippets on websites… which are at most a few hundred lines long. And are usually highlighted as a whole

you have to bundle and ship per language syntax dictionaries tho

Re: 27.5KB language-agnostic WebGPU syntax highlighter

#15
I think what's most interesting is not that this works well for common languages, but it seems to be useful for languages that don't exist yet. If you want _some_ highlighting for your SQL variant, or your language that borrows many common idioms, or just sloppy code that's close enough to the target language, this could be useful.

Re: 27.5KB language-agnostic WebGPU syntax highlighter

#18

On linux (tried FF and chromium), the live demo renders all the text as black (no highlighting). On iOS (my phone), this works great. No errors in the console (maybe it fails silently?) Is this a linux issue / support issue?

Check navigator.gpu in the console on the Linux machine. If it is undefined, that is your answer, and it explains the silence: the page has no API to fail against, so nothing throws.

WebGPU on Linux is still the exception, not the rule. Firefox ships it enabled by default in Nightly only, not Stable or Beta, with Linux expected during 2026. Chrome enables it by default on Linux only for Intel Gen12+ (from 144) and NVIDIA with driver 535.183.01+ on Wayland (from 147); everything else is behind flags, roughly --enable-unsafe-webgpu --ozone-platform=x11 --use-angle=vulkan --enable-features=Vulkan,VulkanFromANGLE. Distro Chromium builds also differ from Google Chrome here more often than people expect.

Which matches what you saw exactly: works on iOS, black text on both Linux browsers, clean console. Worth the demo printing a one-line "WebGPU unavailable" instead of rendering black on black, because right now a missing API and a broken shader look identical from the outside.

Re: 27.5KB language-agnostic WebGPU syntax highlighter

#19
post #3

I don't think it's meant as something that's useful per se because highlighting 5m lines of code at once is unusual, and doing it in a non-deterministic way probably isn't especially helpful, but to show what a browser is capable of it's awesome.

> highlighting 5m lines of code at once is unusual

Speak for yourself, I often accidentally open 50MB JSON files, crashing my text editor as it tries to figure out the syntax highlighting :)

Re: 27.5KB language-agnostic WebGPU syntax highlighter

#20
post #3

I don't think it's meant as something that's useful per se because highlighting 5m lines of code at once is unusual, and doing it in a non-deterministic way probably isn't especially helpful, but to show what a browser is capable of it's awesome.

> highlighting 5m lines of code at once is unusual Speak for yourself, I often accidentally open 50MB JSON files, crashing my text editor as it tries to figure out the syntax highlighting :)

50MB in one line (with syntax highlighting) is a good test of a text editor.
Post reply on HN