Back to browse
GitHub Repository

An implementation for CSS Box Layout Engine

6 starsC++

Masharif

by alielmorsy19·Feb 18, 2026·1 point·0 comments

AI Analysis

●●SolidNiche GemWizardryShip It
The Take

Implements full Flexbox semantics in idiomatic C++ and uses an incremental dirty-bit approach to avoid full recalculations — benchmarks show sub-millisecond initial layout and ~0.07ms single-property edits. It’s an attractive alternative for folks who find Yoga’s C API clumsy, but the repo feels early: README and docs are sparse and more examples/tests are needed before it becomes a drop-in replacement.

Category
Target Audience

C++ GUI and game engine developers, toolkit authors, and systems programmers who need a lightweight, embeddable layout engine

Post Description

Hi HN,

I’ve been working on a GUI library and ran into a familiar problem: I needed a layout engine that was lightweight, predictable, and easy to integrate. I couldn’t quite find what I wanted, so I ended up building my own. That project became Masharif.

Masharif is a complete Flexbox layout engine. It supports margins, padding, gaps, and the full set of flex properties, with behavior aligned closely to how Flexbox works on the web.

Some technical notes: - Full Flexbox implementation - Supports margin, padding, gaps, and nested layouts - Designed to be simple to embed and reason about

Performance (tested with 10,101 nodes): - Initial layout: ~0.87 ms - Single property edit (width): ~0.07 ms - 100 property edits (flex-grow toggles): ~0.07 ms - Structural change (removing a child): ~0.75 ms

Why another layout engine? Yoga is the obvious industry standard, but I wanted something that feels more idiomatic C++ rather than C-style APIs. Mostly, though, I wanted to take on the challenge and really understand the problem space by building one myself.

I’d love feedback, criticism, or questions.

Similar Projects

Developer Tools●●Solid

Auto-Layouting ASCII Diagrams

Mermaid-to-ASCII converter, but Mermaid already exports SVG natively.

CozyShip It
switz
24143mo ago