Live data from Hacker News

Yoga: A cross-platform layout engine

code.facebook.com

41–50 of 168 posts

Re: Yoga: A cross-platform layout engine

#42
post #35

Why not just embrace Cassowary ( https://en.wikipedia.org/wiki/Cassowary_(software) ) aka the algorithm behind Cocoa's Auto Layout? Auto Layout isn't perfect but I think that it's fundamentally the API/UI that you are working with, the concepts are definitely at the right level of abstraction. Some sort of DSL could really solve this. Flexbox could be implemented as a framework on top of this.

(Original author of css-layout here) I've spend a few months playing with Cassowary before working on css-layout and had long chats with its creator Greg Badros and the people behind https://gridstylesheets.org/ . Cassowary underlying abstraction is a linear inequation solver. So you give it a bunch of constraints of the form ax + by + cz + d ## There are two innovations in Cassowary: 1) There's a concept of strength…

HN Comments are ephemeral... this would make a nice blog post!

Re: Yoga: A cross-platform layout engine

#43

Earlier quoted context omitted.

Parent was referring to the current version of IE which still has partial support. I wish it were better supported today. It would sure make my life easier.

If you use autoprefixer you can reliably use flexbox, with a few minor exceptions which, IMO, aren't huge dealbreakers.

Fair enough I've just kinda avoided things not supported fully in evergreen browsers when I can. I should probably re-examine that more often.

Re: Yoga: A cross-platform layout engine

#45
post #30

Yoga's layout API is very similar, if not a direct copy, of the web's Flexbox. Which funny enough means that we might get a chance to use Flexbox on the desktop before we can use it on the web. (I'm looking at you IE and your continuing partial support: http://caniuse.com/flexbox )

A lot of real-world usage of flexbox is broken that has nothing to do with IE/Edge. Follow the "Known issues" tab on your caniuse link. Also see Flexbugs [1] for more. I get bitten by #11 and/or #14 on almost every project, which work fine in IE/Edge. [1] https://github.com/philipwalton/flexbugs

Wow, thanks for the link. I use flexbox for layouts and usually can get away with fiddling with wrappers and such until it looks right, but I can easily see myself losing at least a half a day to each one of the bugs on that list. :)

Re: Yoga: A cross-platform layout engine

#46

I like the concept and the C# code is just hands down the best example out of all of them (yet another reason I miss coding in C#). I'm curious though, will this be eventually ported to JavaScript? Yeah yeah I know "flexbox is already on the web!" but if you could write a layout in this fashion versus using style sheets then you could take it and directly apply it to any of your applications (even if you have to conv…

Just curious, when/why would you want to code UI layout in C# vs using a template ?

Hmm good question. The last time I did C# I did a little WPF and mostly Win or Web Forms so I'm not sure what the state of creating GUIs with C# / .Net is. If this technique affords me better cross platform support then it likely makes sense to use it but as far as using it versus a template I'm not really sure.

Re: Yoga: A cross-platform layout engine

#47

I like the concept and the C# code is just hands down the best example out of all of them (yet another reason I miss coding in C#). I'm curious though, will this be eventually ported to JavaScript? Yeah yeah I know "flexbox is already on the web!" but if you could write a layout in this fashion versus using style sheets then you could take it and directly apply it to any of your applications (even if you have to conv…

> will this be eventually ported to JavaScript?

It's already cross-platform; cross-language would probably be a little much to ask :)

Re: Yoga: A cross-platform layout engine

#49

Earlier quoted context omitted.

I already use it in production. I don't really care about old IE users. I agree that not all devs can afford this, but many can.

Parent was referring to the current version of IE which still has partial support. I wish it were better supported today. It would sure make my life easier.

In my experience it's "good enough". I just shipped a production site with all flexbox layouts and we had to support IE11. I found that the trick was to avoid the shorthand flex attribute and use the explicit flex-* attributes instead.

Re: Yoga: A cross-platform layout engine

#50

I like Facebook creating platforms but it is unclear, at least to me, what the problem is they are trying to solve here.

There are a couple of things which we set out to solve with Yoga. These are two things.

- One layout concept across different platforms. This allows developers to more easily collaborate and jump between platforms and re-use knowledge.

- Decouple layout from rendering. A lot of UI frameworks couple layout tightly with rendering which often ties the layout to be run on the main thread. By decoupling layout we are able to run it asynchronously. https://code.facebook.com/posts/531104390396423/components-f... Talks about how we make use of this.

Post reply on HN