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.