cwbrowser โ€” a browser engine written from scratch in Zig

๐Ÿ”ฅ Discover this awesome post from Hacker News ๐Ÿ“–

๐Ÿ“‚ **Category**:

๐Ÿ“Œ **What Youโ€™ll Learn**:

A web browser with a rendering engine
written completely from scratch in Zig, paired with
Googleโ€™s V8 for JavaScript. Two years of solo work โ€”
extremely lightweight, and about 2ร— faster than
Chrome
in early testing.

No Chromium, no WebKit, no Gecko. The HTML parser, CSS cascade, layout
engine, and paint pipeline are all hand-written in Zig; only the
JavaScript virtual machine is borrowed from Googleโ€™s V8.
The result is a browser small enough to reason about end to end, and fast
enough to beat the mainstream engines on the same hardware.

100โ€Š/โ€Š100

Acid3 conformance
test โ€” a perfect
score

~2ร—

faster than Google
Chrome in early
benchmarking

From scratch

parser, CSS, layout,
paint โ€” all
hand-written in Zig

2 years

of solo engineering
on the rendering
engine

Acid3 100/100

As of today, cwbrowser passes the Acid3 test with a perfect
100/100
โ€” the same conformance bar the mainstream
engines cleared, met by a from-scratch engine.


โค“ย  Download โ€” coming soon

cwbrowser running the Acid3 test at acid3.acidtests.org and showing a perfect 100/100 score, with the coloured animation rectangles rendered correctly and a status bar reading 'Loaded http://acid3.acidtests.org/ โ€” 2265 ms, 481 px'
cwbrowser on acid3.acidtests.org โ€” a clean
100/100, rendered by its own engine. Note the status bar: full page
loaded and laid out in 2265ย ms.

What it is

cwbrowser is a desktop web browser built on a rendering engine I wrote
from nothing over the last two years. Where Chrome ships Blink, Safari
ships WebKit, and Firefox ships Gecko, cwbrowser ships an engine of its
own: the tokenizer, DOM, CSS parser and cascade, the box-model layout
pass, and the painting stage are all original code in
Zig โ€” a small, fast, memory-careful systems
language.

The one piece it doesnโ€™t reinvent is the JavaScript engine.
Re-implementing a modern, JIT-compiling JS VM is a decade-scale project,
so cwbrowser embeds Googleโ€™s V8 โ€” the same
engine inside Chrome and Node โ€” and wires it to the from-scratch DOM.
You get a real, standards-following browser where the parts that decide
how the web looks are entirely hand-built.

How itโ€™s built

LanguageZig for the whole rendering engine โ€” manual memory management, no garbage collector, no hidden runtime.

HTML & DOMA from-scratch tokenizer and tree builder producing a live DOM the engine and V8 both operate on.

CSSOriginal parser and cascade โ€” selectors, specificity, inheritance, the box model โ€” feeding the layout pass.

Layout & paintHand-written block/inline layout and a paint pipeline that renders pixel-for-pixel to match the Acid3 reference.

JavaScriptGoogleโ€™s V8, embedded and bound to the DOM โ€” the same VM that powers Chrome and Node.

PerformanceRoughly 2ร— Chrome on the same machine in early tests; the whole engine is lightweight by design.

Why build a browser from scratch?

The modern web runs on three rendering engines, all enormous, and all
descended from code written more than twenty years ago. cwbrowser is a
bet that a browser engine can be rebuilt today โ€” smaller, faster,
and understandable by one person โ€” using a modern systems language
and only borrowing the one component (the JS VM) that genuinely
isnโ€™t worth reinventing. Passing Acid3 at 100/100 is the first
proof the approach holds up against real standards.

Download

A public preview build for macOS on Apple Silicon is on the way.
It isnโ€™t posted here yet โ€” when it is, this is where
itโ€™ll live.


โค“ย  Download โ€” coming soon

๐Ÿ’ฌ **Whatโ€™s your take?**
Share your thoughts in the comments below!

#๏ธโƒฃ **#cwbrowser #browser #engine #written #scratch #Zig**

๐Ÿ•’ **Posted on**: 1785552928

๐ŸŒŸ **Want more?** Click here for more info! ๐ŸŒŸ

By

Leave a Reply

Your email address will not be published. Required fields are marked *