Comments (1)
Sorry this has taken a while, I wrote a long answer but it didn't cover everything I wanted so ended up putting it on the backlog, and well... 18 days later.
First-off, I'd recommend folks evaluate the two for themselves to see which meets their needs for product quality, perf, devx, integration with existing code (if applicable), etc: that's going to give a clearer picture most relevant to their specific context than anything I'll write below.
Second, both frameworks are moving targets due to both being under active development, so who knows how long much of the below will stay accurate after posting :)
As far as similarities go, both are declarative UI frameworks in which you write Comp(onents|omposables) which are effectively special static functions which should have no direct side effects while executing. They both 'resolve' down to some primitives - Views/Drawables in Litho and drawing commands in Compose for Android (I believe!). Both introduce a new way of thinking about writing UI, which solves many problems (e.g. bugs in managing UI state) and introduce fun new ones ('why is this update recreating so much of the tree?').
Both frameworks take React as a degree of inspiration, and have many of the same concepts (though litho uses the React names still): e.g. useEffect in Litho and SideEffect in Compose exist to accomplish approximately the same thing - in the same way I think someone wrote a cheatsheet for React/Compose, you could write one for many concepts between Litho/Compose. I'm not trying to say the APIs are interchangeable though - Compose has made some very cool innovations on things like gesture handling, composable functions with and without return, @composable modifiers, etc.
At time of writing, some of the main differences I see are:
- On the core API front: Litho's Kotlin API is currently implemented without codegen or compiler plugins - it's plain old Kotlin code you can go read and step through in the debugger. Compose's semantics are realized via a compiler plugin can allow it to enforce some constraints and do some very clever things for fast updates, among other things, at the tradeoff of a bit more magic.
- A main selling point of Litho (Kotlin and Java) is performance: this comes from granular (per view/drawable type) recycling, view flattening (removal of layout-only views), incremental mount (views/drawables are only materialized as they enter the viewport, with more granularity than RecyclerView), and background/ahead of time layout. This latter one imposes restrictions on code used from Litho (it must be threadsafe!) but has shown to improve scrolling, interactions and navigation. I know less about analogous optimizations in Compose, but currently composition/recomposition happens on the main thread: however I believe the team is currently working on adding parallel/ahead of time layout.
- Beyond initial rendering, Compose is able to perform very granular updates in response to data changes via read tracking: Litho doesn't have this and generally gets by with coarser update boundaries, bridging out the Views/Drawables when necessary, and the use of DynamicProps and a Transitions API for animations.
- Compose encompasses a larger ecosystem, across multiple libraries: for instance, at the moment Litho Kotlin doesn't publicly provide APIs around navigation, material design, alternate layout systems (Litho is flexbox or bust atm, but hopefully changing soon), or a data system (snapshot state). Compose also is being positioned to target Desktop, KMP, and web (though I can't speak to the state of those myself)
- Compose inspection and tooling lives in Android Studio, Litho's is with Flipper (fbflipper.com)
- Litho Kotlin components are fully compatible with our Spec-generated (Java) components: not super relevant to new adopters but important for incremental migration of the API.
In some ways this is just scratching the surface, but I think it covers the broad strokes. I'll end with saying that Compose is a really amazing set of libraries built by some very clever people, so major props to the team at Google!
from litho.
Related Issues (20)
- visibleHandler and invisibleHandler is not effective HOT 1
- Relocate Litho dependencies in a location other than JCenter. HOT 1
- Paint Flags support HOT 1
- ClickEvent beyond recycler HOT 4
- TextInput with RTL makes ViewPager jump between pages HOT 1
- Elements outside the viewport are not drawn on entering HOT 2
- Litho HOT 1
- Automirrored vector drawables do not get mirrored when layout is RTL HOT 2
- HorizontalScroll should provide the ability to fade edges HOT 3
- how do you update state from a Android Fragment/View parent? like React's useImperativeHandle
- Are there any plans to replace unsupported APIs (KEYCODE_BACK and #onBackPressed) to support Android's new Predictive back gesture?
- OnUpdateState not invoke on parent recycler component
- How to update prop value of MountSpec from LayoutSpec
- Lazy list not working in project getting error HOT 4
- ContentAllocator API not working HOT 14
- NullPointerException in TextDrawable.Draw, seemingly from a race condition in ComponentHost$InterleavedDispatchDraw
- Setting a background to a container using Style.background(dynamicValue: DynamicDrawable) draws outside of bounds of parent. HOT 1
- Dimension error when adding flexure process
- Unable to import Litho KComponent, ComponentScope and other Litho classes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from litho.