Article may be outdated

This article is 66 days old. Some details may have changed since publication.

Hacker News·5 min read·medium

How AST-grep Rewrote Tree-sitter in Rust and Made It 30% Faster

H
herrington_d
✦AI Summary

The developer of the structural code-search tool ast-grep has successfully rewritten the core of the Tree-sitter parser from C to Rust using AI-assisted development. This optimization results in a 22% end-to-end performance increase for the tool by stripping away editor-specific machinery unnecessary for static analysis.

Why it matters

This project demonstrates how AI-assisted refactoring can make complex, high-stakes systems engineering tasks feasible for individual developers, potentially accelerating the performance of developer tooling and AI coding agents.

✦Dive DeeperCreate a free account to unlock

ast-grep rewrote Tree-sitter's C core in Rust, with AI writing the code. The new core is faster at parsing, faster at reading the completed tree, and faster in ast-grep itself. (The title's “30%” is the parser-only number; end-to-end, ast-grep runs about 22% faster.)

Source repository: HerringtonDarkholme/tree-sitter .

Two quick introductions before the numbers. ast-grep — the structural code-search tool this blog belongs to — searches code by syntax rather than by text, so every file it touches must first become a syntax tree. Tree-sitter is the parser framework that builds that tree: you give it a grammar definition, and it generates a fast parser for that language. Born in the editor world, it now powers an enormous ecosystem of grammars and tools.

Continue reading on Headlinne

Create a free account to read the full article.

Read full article →
technologyscience
✦

Get smarter about the news

Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.

Create free account

Already have an account? Sign in