Another NitroUI experiment. I know it's not healthy anymore haha but this one was so fun ๐ (i promise i'll stop soon)
Last time Taffy did the layout. This time I was thinking, what if Rapier, a physics engine written in Rust, took it over? ๐คฃ
Shake your phone and the whole UI falls apart. Sound on ๐
The code and the demo:
https://t.co/qNOHZyJaCL
And the Taffy one, if you missed it:
https://t.co/dpeZH9SDzX
It's just an experiment, so please don't drop your real app's screens ๐
Looks promising on low-end Android as well, will try to show it off tomorrow ๐
Apparently NitroUI lets you plug in your own layout engine, which is kind of crazy ๐๏ธ
I saw Taffy, the Rust layout library, a while ago but never had a chance to try it. So I did: same frames as Yoga, up to 6ร faster on an iPhone, and beaten on a cheap Android.
@nicoburns First results with your port, very sloppily plugged in by me ๐ Looks insanely promising! Will try to make it nicer in the upcoming days :)
Apparently NitroUI lets you plug in your own layout engine, which is kind of crazy ๐๏ธ
I saw Taffy, the Rust layout library, a while ago but never had a chance to try it. So I did: same frames as Yoga, up to 6ร faster on an iPhone, and beaten on a cheap Android.
@nicoburns Whhhaaaat??? Wow, a full port of Yoga's algorithm, checked against real Yoga on hundreds of random trees, that's wild ๐คฏ Mine's the lazy version: Taffy's own flexbox with Yoga's rules wrapped around it. Would be fun to plug your branch into the NitroUI benchmark sometime ๐
@nicoburns Yep, already doing that one! Minimums start at 0 unless the app sets them, like in Yoga. Just tried turning Taffy's automatic minimum back on: first layouts then take 22% more measurements, even more than Starlight. So you were spot on ๐๐๐
@nicoburns Oh nice, that makes sense: Parley lays the text out, the glyphs get drawn from that, and only things like selection go through the native side. Didn't know you could hook into TextKit 2 like that ๐ฎ Now I really want to try it in NitroUI ๐ Thanks!!!
@nicoburns And thanks for sharing Blitz! Hadn't heard of it before, but an HTML/CSS engine built on Taffy and Parley sounds super cool. Definitely gonna play with it in one of my next experiments ๐
@nicoburns As far as I know (might be wrong!), it measures with the native views that draw the text: UILabel on iOS, TextView on Android. On a cheap Android that's ~80% of solving, so Parley is super tempting ๐ NitroUI would have to draw with it too though, or line breaks wouldn't agree
@nicoburns And the low-level traits are what made all this possible: Yoga's rules wrapped around Taffy's own flexbox, without forking a line. If a Yoga-compatible mode ever happens, would love to test it :)
@nicoburns Not sure it's useful, but one thing I noticed: Taffy caches a node by its parent's size, so a list in a scroller is laid out again when the scroller's height changes. Ignoring that height for nodes whose size is decided is where the 25โ43ร comes from: https://t.co/t85OgzWok6
The repo, with the bug still in its first commit if you want to watch it get caught:
https://t.co/nQy4ccwB5x
It's an experiment with a 0.0.1 preview, so take it as that. The post that explains the idea:
https://t.co/tQ6EKf8kC2
TanStack Oracles confused me at first, so I tried it on something real: the reducer behind an AI chat. Streaming answers, tool calls, Stop and Retry.
It found a bug I'd have shipped: press Stop, then Retry, and a late token from the old stream lands in the new answer.
The part that clicked: it tests the tests. It changed my code in 147 small ways, and 80 got past every rule.
Fixing that made my checks stricter and showed some code was dead. Now all 133 changes get caught.