DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > Facebook Announces Yoga

Facebook Announces Yoga

Zone Leader John Vester examines the cross-platform layout engine that has been recently announced by the team at Facebook.

John Vester user avatar by
John Vester
CORE ·
Dec. 14, 16 · Web Dev Zone · News
Like (6)
Save
Tweet
82.87K Views

Join the DZone community and get the full member experience.

Join For Free

the development team at facebook recently released yoga. i know you might be tempted to stop reading this post and immediately search "facebook yoga" to cut to the chase. but be warned that the results will more likely resemble groups with pages on facebook focused on physical, mental, and spiritual practices than anything programming related.

let me save you from one of those internet searches that don't provide exactly the results you are expecting.

what is facebook yoga?

emil sjölander, a software engineer at facebook, recently announced yoga , calling it a "cross-platform layout engine" for application design. with the varied approaches for layouts often differing across application platforms (android, ios, web-based), teams developing across multiple platforms are often duplicating efforts to meet their current needs.

"today, layout is handled differently on each platform, through systems like auto layout on ios, composable containers on android, and various css-based approaches on the web. having such a diverse set of layout systems makes it hard for teams building products to share solutions across platforms and increases the amount of time developers spend fixing platform-specific layout bugs."
- emil sjölander (facebook)

yoga introduces a cross-platform library (java for android, objective-c for uikit and c# for .net) that can be used in products like react native, components for android and oculus. the team is continuing to extend their reach by migrating some views in instagram as well as componentkit.

as one might expect, yoga is oss too, which can be found here at github.

how does it work?

using java as an (android) example, a new yoganode (called root) can be established with some initial properties being set:

yoganode root = new yoganode();
root.setwidth(500);
root.setheight(300);
root.setalignitems(center);
root.setjustifycontent(center);
root.setpadding(all, 20);

from there, nodes for a text box and image can be configured as well:

yoganode text = new yoganode();
text.setwidth(200);
text.setheight(25);

yoganode image = new yoganode();
image.setwidth(50);
image.setheight(50);
image.setpositiontype(absolute);
image.setposition(end, 20);
image.setposition(top, 20);

finally, the text and image nodes can be attached to the root node:

root.addchildat(text, 0);
root.addchildat(image, 1);

when displayed, the end-result will appear as follows:

image title

conclusion

facebook yoga is intended to reduce the effort of designing layouts across multiple platforms while fostering the goal of creating an optimal layout that can be shared and optimized. emil sjölander has even stated that "sharing a layout implementation across platforms has also enabled us to optimize performance once and see the gains across many product and platforms."

software engineering teams that support different platforms should consider using facebook yoga to standardize on the layout aspect of their applications. in doing so, these teams can work together to build a reusable layout that can be applied to all the platforms that yoga supports. since yoga is part of the open source community, team members can give back and contribute to the project where improvements or optimizations are found.

what are your thoughts? will yoga be part of your application design in 2017?

have a really great day!

facebook

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Terraform Controller: Cloud Resource Self-Service
  • Pub/Sub Design Pattern in .NET Distributed Cache
  • Troubleshooting HTTP 502 Bad Gateway in AWS EBS
  • Design Patterns for Microservices

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo