Live data from Hacker News

Yoga: A cross-platform layout engine

code.facebook.com

151–160 of 168 posts

Re: Yoga: A cross-platform layout engine

#151

Earlier quoted context omitted.

If you name React in your patent lawsuit against Facebook, your license for React is terminated. Other software licenses remained unaffected. That seems like a pretty reasonable stance for distributing an open source project.

If I am using React/Yoga/etc, and have a patent on FooTech, and Facebook starts using it tomorrow without license, and I sue them, then I have tripped clause (i). The license granted hereunder will terminate, automatically and without notice, if you (or any of your subsidiaries, corporate affiliates or agents) initiate directly or indirectly, or take a direct financial interest in, any Patent Assertion: (i) against F…

It doesn't matter if you use React or not. If you sue Facebook, they can sue you for any of the patents they hold.

Re: Yoga: A cross-platform layout engine

#152
post #78

Using the name "Yoga" for your software is cultural appropriation. Facebook should not do it. It is equivalent of naming a sports team Rednecks.

Is Yoga a derogatory term? I've never heard it used in such a way, so I think that's quite the false equivalence.

Does not matter. It is not a good idea to use other people's cultural heritage to name "things". In fact the downvotes here suggest how deeply prejudiced and racist people are on HN.

Re: Yoga: A cross-platform layout engine

#154
post #152

Earlier quoted context omitted.

Is Yoga a derogatory term? I've never heard it used in such a way, so I think that's quite the false equivalence.

Does not matter. It is not a good idea to use other people's cultural heritage to name "things". In fact the downvotes here suggest how deeply prejudiced and racist people are on HN.

In fact the downvotes here suggest how deeply prejudiced and racist people are on HN.

Is it fair to generalize like this across all the members of HN? You might argue that this is the case for those that down-voted, but everyone?

Re: Yoga: A cross-platform layout engine

#155
post #90
post #87

Earlier quoted context omitted.

This is one of the reasons companies seek patents, called a defensive patent strategy. The goal is to discourage competitors from suing you for patent violations by making sure you own a patent your competitors are likely to have violated. It creates a kind of "mutually assured destruction" that discourages either party from launching a patent war (this only works against real competitors, not against patent trolls,…

Let's say I have a patent for a technology outside of React, and even outside of software, such as some hardware patent. Why should me suing for infringement of that patent preclude me from using React when it (the patent infringement and React) are completely independent?

Because you agreed to use the software facebook architected, developed, tested and publicly made available for you for free, in exchange for letting them use ideas you developed and publicly described for free.

Re: Yoga: A cross-platform layout engine

#156
Cool to see Facebook release code in C! I clicked the "C" tag in the blog post, and this is the only post referencing C. Heh. Anyway, finally code from an Internet Giant in a language I care about enough to go and take a look at.

It seems ... smallish, which was a pleasant surprise. The core Yoga/ folder contains six files which is certainly fewer than I expected.

Didn't have time to do a full read-through, but one thing that I couldn't ignore is the use of a pointer-hiding typedef for the core layout node:

    typedef struct YGNode *YGNodeRef;
I'm really opposed to "hiding the asterisk" in C, since whether or not a thing is a pointer typically matters, and code becomes harder to read when you need to think about this more.

Even stranger, though, is that then most function protypes look like this:

    void YGNodeMarkDirty(const YGNodeRef node);
So, you have a function called "mark" which really sounds like a mutating, modifying, operation. But it's declared to take a constant node reference!

Peeking at the code, what it does boils down to:

    if (!node->isDirty) {
      node->isDirty = true;
      ...
    }
So it really is modifying, there's no trickery involved (like having node be a handle or indirect reference). It then recurses upwards through the chain of parent nodes, like you'd expect.

This works since the "const" here doesn't apply to the pointed-at object (it's distinct from the un-typedef:ed version "const struct YGNode * node"), it applies to the reference.

So the code jumps through these hoops and adds a const to the external interface, which doesn't matter, all it does is say "yeah, this function won't re-assign the reference variable to point at something else". Which, in my opinion, is not very useful information, as opposed to "this function doesn't write to the object you pass in" which you'd get with the non-asterisked version.

Can anyone shed some light on why one would do this?

Re: Yoga: A cross-platform layout engine

#157

Earlier quoted context omitted.

Nope, I am refering to ConstraintLayout. RelativeLayout does not use Cassowary (even though for an API consumer, this is just an implementation detail). Actually, CL one of the reasons behind the creation of RL is to improve on RL : - remove the need to nest for complex layouts. Nesting has some intrinsic measure/layout overhead. CL solves this by allowing way more types of relative constraint. The only remaining rea…

This is incredible! is this going to be paired with a wysiwyg tool... because i have a feeling that writing the constraints is going to get frustrating very quickly.

It is already : https://developer.android.com/studio/write/layout-editor.htm...

The previous layout editor was pretty much unusable. Even though XML is ugly it is still efficient to work with (especially since the IDE auto completes all the cruft), so almost nobody was using the old layout editor.

The new one is still in beta and has some rough edges but it sounds like this will actually be useable and maybe even faster than editing the XML in some cases.

Re: Yoga: A cross-platform layout engine

#158

> Yoga also does not support styling properties that have no impact on layout, such as color or background properties. Does that mean that Yoga is too low level to be used directly by application developers? Who's the intended audience?

Yoga is a Layout engine, not a UI or graphics engine. It's output is basically just the size and position of those objects put into it. So you'd need a bridge to use it for existing UI systems or build a new UI system on top of it (just like what React Native did).

Re: Yoga: A cross-platform layout engine

#159
post #135

I made a similar library earlier this year. It builds as C or C++ and is only two files (MIT license): https://github.com/randrew/layout The API is similar to Yoga. I hadn't seen Yoga before, and I'm surprised at how similar it is. It seems like Yoga is about the same age (or older?) than my Layout library. It's meant to be easily embedded into existing software, such as game engines, OpenGL-based tools, custom GUI l…

Hey, this looks really good - I'll give a shot at using this in MOAI! Thanks for that!

Re: Yoga: A cross-platform layout engine

#160
post #156

Cool to see Facebook release code in C! I clicked the "C" tag in the blog post, and this is the only post referencing C. Heh. Anyway, finally code from an Internet Giant in a language I care about enough to go and take a look at. It seems ... smallish, which was a pleasant surprise. The core Yoga/ folder contains six files which is certainly fewer than I expected. Didn't have time to do a full read-through, but one t…

I'd guess that its because changing the value of the *Pointer would actually be a bug, and const args are used to catch these kinds of bugs...
Post reply on HN