Why Jetpack Compose is a game-changer for Android Development
What is Android Jetpack Compose?
Google's first sentence describing Jetpack Compose on its landing page is: "Jetpack Compose is Android’s modern toolkit for building native UI".?I agree this is true, yet I think this statement significantly understates the importance and future impact of Jetpack Compose. Of course Google doesn't hold back on superlatives about Jetpack Compose in other areas of communication!?
In an?article on SwiftUI I penned last week, I called Declarative UI Development a?megatrend. The declarative UI trend includes Android too, and Jetpack Compose is the Android framework to enable declarative UI development for native Android applications.?
Jetpack Compose Positioning
Google's clear direction is to move developers toward?Declarative UI development?tools for future Android mobile development.?Google isn't alone in this paradigm shift.?Apple iOS development is moving in the same direction (SwiftUI), and Google's?Flutter?cross-platform framework was built from the beginning with similar declarative UI principles.
Important points regarding Jetpack Compose's positioning and architecture:
Declarative UI Development
The most important and architectural feature of Jetpack Compose is that it uses (and requires) a?declarative?syntax for UI development.?
What does that mean?
Put simply, the code (syntax) of Jetpack Compose describes?what?the the UI should present--not?how?UI elements should be constructed. The?how?part is left to the runtime Jetpack Compose library to work out.
The declarative paradigm shifts a great deal of work from the developer to the underlying Jetpack Compose subsystem--read as "writing less code to do the same thing". This saves time and money during initial development--and reduces the occurrence of UI bugs and regressions throughout the life of the codebase.
In a traditional Android UI development, a combination of XML documents and UI code will tediously describe both what?and?how every UI component is constructed.?The?how?part can be quite a lot of code, and is potentially a source of difficult to find UI state change bugs.?State bugs in mobile apps are a significant risk--so reducing them from the start is a big win.?
Declarative UI Development shifts a great deal of work from the developer to the underlying UI subsystem--saving time and money during initial development and reducing long-run codebase TCO.
Jetpack Compose Advantages over traditional UI development
Google has drawn a roadmap that all Android native developers are eventually expected to follow, but there are some short-term practical advantages of Jetpack compose to consider as well:
Disadvantages for Jetpack Compose
Most of the reasons not to adopt Jetpack Compose yet relate to timing, risk and learning curve.
领英推荐
Can I use Jetpack Compose today??
The short answer is yes.?Compose can be used as the basis for new apps or added to existing apps today. Apps that use Compose will still run on older versions of Android.
Is it still too Early (Spring 2021)?
As of this writing (March 2021), Jetpack compose is in Beta. For Google,?Beta?means the software interfaces are feature complete and developers can expect minimal breaking changes before the production release (planned for Summer 2021).?So while it's early days, it's not too early to get started with Jetpack Compose for those who are willing to be among the first movers.
Compatibility with older Android Devices
Android has a highly diverse installed base, and devices are often removed from Android OS upgrade support before the end of their useful life (Android Fragmentation). Android application developers need to support older Android OS versions to avoid excluding large numbers of users.
Google has been mindful of the Android fragmentation issue, and whenever possible designs new UI and application services (such as?AppCompat?and?Jetpack?components) as backward-compatible libraries that are bundled with each application that uses them. Conversely, Apple's iOS installed base is far less fragmented, so the company often includes new features with new iOS versions, making it unnecessary for these services to be bundled with applications.
Jetpack Compose, like most other Jetpack components, is designed for backward compatibility.?Under the covers, Compose is a Kotlin-based software layer bundled with your app. That bundled software layer transforms the Declarative Kotlin code at runtime into UI components that even older versions of Android can create and use.
Jetpack Compose, while a new UI design paradigm, generates UI that older versions of Android can use.
Should I use Jetpack Compose?
Google has made it clear that Jetpack Compose is their direction. In the long-run (2-3 years), virtually all new native Android development will be built using Jetpack Compose--so the more relevant question probably is is "when should I start using Jetpack Compose".?
Other platforms that have already made the primary pivot to declarative syntax (such as Apple SwiftUI) have been enthusiastically received by developers. It should be expected that Jetpack Compose is highly likely to succeed and acquire significant adoption in the coming months and years.
Jetpack Compose is a good candidate when
It may be better to wait on Jetpack Compose if
Summary
The first Android Development SDK was released in 2007--14 years ago as of this writing. The Android SDK has evolved--significantly--in that time, yet the basic paradigm of loosely coupled layout (usually in XML files) with code in Java (more recently, Kotlin), has largely remained the same.?
While the current Android development architecture?works--and works well, for the most part– much has been learned over the years about how to help developers build UI faster, with fewer bugs and with higher levels of quality. Some of these learnings have been incorporated in the current SDK, but others need an architectural/paradigm shift to be efficiently incorporated.
Jetpack Compose represents a major shift of the Android UI development paradigm--a direction which will be easier, faster and ultimately result in less expensive, higher quality software that better meets the needs of companies field software in a competitive mobile software marketplace.
This article was originally published at www.cuvenx.com.
Android dev | SMA
3 年I want to be one of the first to migrate to jetpack composing, but after a while I learn I have found that many practices become obsolete and that is why my learning process is slow... ??