Skip to content
NewA calmer, faster ZeroHour

27.5KB language-agnostic WebGPU syntax highlighter

Hacker News · securityby bpierre ()2 min read4 · 2 reads
AI summary · glm-5.3-flashSummaries by Vani AI

A developer released gpu-lexer, a 27.5KB language-agnostic syntax highlighter that uses a tiny WebGPU model to label code tokens in the browser.

gpu-lexer splits source into words, whitespace, and symbols, then a small WebGPU model uses local and whole-file context to assign nine token classes, working on languages never seen in training. On held-out files, 12.57% of token labels differ from Shiki, though this measures agreement with Shiki rather than objective correctness. In benchmarks against Shiki 4.4.3, Prism.js, Highlight.js, Sugar High, and Starry Night, it highlighted 10 concatenated copies of three.min.js (5.56M characters) about 10x faster on an Apple M4 Pro in Chrome 152. The author frames it as an experiment, not a grammar-equivalent highlighter.

Key facts
  • Single 27.5KB bundle handles any language without grammars
  • Labels plain, comment, string, keyword, type, and other token classes
  • 12.57% label disagreement with Shiki on held-out files
  • ~10x faster than Shiki on 5.56M-character benchmark input
Explain this AI news with Vani AIWhat was announced, what is new and why it matters, in a new chat

From the original article

2 min read at gpu-lexer.vercel.app

// type: 'plain' | 'comment' | 'string' | 'number' | 'keyword' | 'type' | 'function' | 'constant' | 'operator' // }[] gpu-lexer splits source code into simple parts—words, whitespace, newlines, and symbols. Then a tiny WebGPU model combines local and whole-file context to label each part.

Hacker News · security

By bpierre · gpu-lexer.vercel.app

Read the full article at Hacker News · security

A short excerpt; the article and its images belong to the publisher. Summary, key facts and assessment above are AI-written from the article and can be wrong.