Auto Added by WPeMatico

Cash App Case Study

Cash App is the easiest way to send money, spend money, save money, and buy cryptocurrency. We believe in providing everyone with access to important financial services so they can fully participate in the economy. The app launched in 2013 as a simple peer-to-peer payment app with 4 mobile engineers, and it now has 50 mobile engineers (split across iOS and Android) and 30 million monthly active users.

The app has been built with the native Android/iOS toolchains throughout, with a few small exceptions. We introduced a JavaScript runtime to power some shared server-driven logic for displaying sensitive payment information, and that was our first exposure to shared code. We continued to experiment with JavaScript as a tool for sharing code after 2016, but we concluded that unless circumstances required it, the cost of working with JavaScript outweighed the value of sharing code. We strive for a quick development turnaround with Cash App, with small pull requests that are reviewed and merged in a matter of hours, and working with JavaScript always slowed us down, both in the writing and the reviewing of it. Over time our Android and iOS teams grew closer, the platforms did the same with Swift and Kotlin, and collaboration between the two teams strengthened. We started bouncing ideas off each other and comparing code, and similar implementations started emerging within the codebase.

The decision to test out Kotlin Multiplatform started in open source. A library we maintain called SQLDelight was gearing up to generate Kotlin-only APIs, and the decision was made to also use KMM to make those generated APIs platform-agnostic. The fit seemed natural. Since SQLite is the most widely used cross-platform technology around, this would serve as an opportunity to test the technology, and it would open the doors for Cash App to use it later, since the Android version of the app relied heavily on the library at its core.


Visit the Kotlin Multiplatform Mobile portal to find more case studies from different companies!


Within Cash App the value proposition of using KMM was twofold: we could remove some of the shared JavaScript that was causing issues and enable the Android and iOS engineers to take the next step in their collaboration and maintain a single codebase. We loved the “shared business, native UI” idea that Kotlin Multiplatform promoted, and it meant that our teams did not have to give up using their preferred toolchains. We started testing the technology within Cash App in 2018 with the help of TouchLab, slowly rolling it out behind a feature flag to ensure we could roll back and upstream our problems to JetBrains if we encountered any early-adopter issues.

In the last year, we’ve made major changes to how we use Kotlin Multiplatform to help teams to adopt it. We had originally introduced the Gradle toolchain to the iOS build by keeping the shared code in the same repository, but the added cost of running Gradle and rebuilding the project did not make sense in light of how often the dependency was being changed. Instead, we created a shared repository for Android/iOS to be the home for our shared business logic. Since then, our network, investing, and growth teams have all built features with parts of their business logic in KMM. What has made me most proud is that the contributions have come not only from Android and iOS team members, but from the server team as well! Since we use Kotlin for our server-side development, their team is now able to work in the repository, and because the platform-agnostic Kotlin so closely resembles Swift that the shift is manageable for our iOS team too.

In addition to using SQLDelight, we use CrashKiOS from TouchLab to get better stack traces in the wild, and we are in the process of adopting Wire to work with protocol buffers in the shared codebase. As for which parts of our business logic we’ve encouraged KMM as a solution for, we’ve had the most success so far with persistence and pure functions in the shared code, and next we’re hoping to work more closely with our network APIs using Wire.

The vast majority of our code is written natively — developer happiness and productivity is still the most important thing for us, and our focus right now is making sure those who want to try Kotlin Multiplatform can do so easily (and the number of people who do is growing!). The trend in the last year of more projects exploring it as an option shows the strength of the technology.  With JavaScript, we were quick to run away after giving it a shot, but so far more and more folks on the team have been showing interest in adopting KMM.


Visit the KMM portal to create your first cross-platfrom application with Kotlin!


We love Kotlin Multiplatform because we didn’t have to give up any of the things we love about our work. We’re at a place now where the developer workflow is unchanged but there is an option to share code and get all of those benefits without stepping out of our comfort zone. Our teams are increasingly realizing the potential of KMM, giving it a shot, and seeing how powerful it is.

Alec Strong,
Senior Kotlin Developer

Continue ReadingCash App Case Study

Down Dog Case Study: Building 500K Subscribers App with KMM

Down Dog is the innovative start up that brings a studio-like yoga experience to your mobile device. With Down Dog you get a brand new yoga routine every time you come to your mat.

Unlike following pre-recorded videos, Down Dog won’t make you do the same workout over and over again. With over 60,000 different configurations, Down Dog gives you the power to build a yoga practice you love!

This app brings yoga to over 500k subscribers on both Android and iOS, with over 100k users completing a practice daily. The app has 200k reviews on iOS and over 100k on Android, with an average rating of 4.9 on both platforms. And what is this incredible app built with? Kotlin Multiplatform Mobile!


Visit the Kotlin Multiplatform Mobile portal to create your first cross-platfrom application with Kotlin!


The story behind Down Dog

In 2015, having worked at Google for three years, co-founder of Down Dog Benjamin Simon started to feel frustrated with the size of Google and his inability to drive progress forward as an individual programmer. He had recently become obsessed with yoga and was in the middle of finishing a yoga teacher training program. It suddenly dawned on him that the logic for yoga sequencing they were learning could be put into code in order to generate semi-random sequences much like an instructor does, which was the seed idea for Down Dog. So, with an old college friend, he began to work on bringing the practice of yoga to people’s mobile phones.

The project

It has now been about six years since the first prototype. Certain parts have remained unchanged; the same original set up of a Tomcat backend server still runs on AWS that communicates with a PostgreSQL database. The first version was a prototype that only existed as a web app (written in TypeScript). When they then committed to Down Dog, that prototype was thrown out and they built the first iOS app using Swift, which launched in August of 2015. In March of 2016 the Android app followed, which was written in Java. Around September of 2016, the decision was made to switch to Kotlin for the Android mobile app development and the server, which only took about a month (with the help of IntelliJ IDEA’s auto-converter). 6 months later, the web version of Down Dog was launched, which was built using KotlinJS.

At this point, code was not being shared between any of the three clients, but they were being written in parallel so that changes to the business logic were essentially a copy-paste job (plus syntax changes when converting to Swift). At the beginning of 2020, Down Dog switched to Kotlin Multiplatform and began sharing code among all three clients for everything but layouts and other platform code. The team has even moved the majority of their iOS platform code from Swift to Kotlin, so that their entire project is now Kotlin with the exception of around 5 Swift files.

Down Dog under the hood

In terms of what is native, it is mostly just the view code. There’s also network interaction, media playback, local storage, and third-party integrations like Facebook login. The rest is Kotlin.

Under the hood, there’s a module structure that looks roughly like this:

Common: multiplatform module containing code shared across the clients and server (mostly various helpers that have been written).

Base: a kotlin-jvm module that depends on ‘common’ and contains non-client code used by the server as well as in standalone tasks.

Server: a kotlin-jvm module that depends on ‘base’ and contains all of the Servlets. This module uses the gretty plugin for running the server locally, and the war plugin for deploying to AWS Tomcat servers.

Tasks: a kotlin-jvm module that depends on ‘base’ and contains various standalone tasks that need to run (database cleanup, generating reports, certain content-specific tasks).

Client: a multiplatform module that depends on ‘common’ and contains nearly all of the code for all three clients. Most of this code is structured as ViewController-View pairs, where the ViewController is platform-independent and the View is an “expect” class implemented separately for each Android, iOS, and JavaScript. This module also contains some “expect” objects which wrap other platform interactions (e.g. a Network object to handle all requests/responses), and it contains data classes representing the API with the server, for which we use kotlinx.serialization to convert to and from JSON.

Android: a kotlin-android module that depends on ‘client’ and contains the Activity class, which calls code in ‘client’ to initialize the app.

JavaScript: a kotlin-js module that depends on ‘client’ and contains a main function that calls code in ‘client’ to initialize the app.

Additionally there is an Xcode project similar to the Android and JavaScript modules, containing primarily just the UIApplicationDelegate class, which calls code in ‘client’ to initialize.

Story of the mobile application

The speed of development for the app was probably the single biggest priority. Launching features simultaneously on all platforms is an important component of this and also helps prevent bugs. Even before we were actually sharing code, we did parallel development and kept the three clients up-to-date with each other. Performance is definitely an important consideration, which makes being able to interact with the platforms directly very important (especially with the media playback API’s).

Having used Java since starting coding in high school, Benjamin had long been a fan of IntelliJ IDEA and had been aware of Kotlin’s popularity among app languages for some time. Discussions between the cofounders ultimately led to the adoption of Kotlin for the project. Much of Java was considered overly verbose and otherwise frustrating for mobile development, and it was often pointed out that the problems they were finding in Java seemed to have been addressed in Kotlin. That eventually led to the decision to try Kotlin, especially because it was also much closer to Swift, which at the time was the only option for iOS. In addition to being able to share code across platforms, Kotlin’s ability to create DSLs was very useful because it is used heavily to write the logic for the workouts. There were never any alternatives that were seriously considered. React Native was the other big option at the time that was being pushed, but there were performance issues (especially on Android), and JavaScript was also unappealing.

Gains from using cross-platform

Now, the speed of development across the three client platforms is pretty much unmatched. A single engineer is able to do all of the UI implementations, now does all three clients and has re-skinned or otherwise changed the screens in Down Dog in just a few months.

If you are putting off using Kotlin for whatever reason, Benjamin has just one last suggestion for you: “Just do it. You won’t look back.”


Visit the Kotlin Multiplatform Mobile portal to find more about cross platform development!


Continue ReadingDown Dog Case Study: Building 500K Subscribers App with KMM

Philips Case Study: Building Connectivity with Kotlin Multiplatform

Philips is a leading health technology company focused on improving people’s health and well-being, and enabling better outcomes across the health continuum – from healthy living and prevention, to diagnosis, treatment and home care. Philips is pursuing the goal of improving 2.5 billion lives per year by 2030.

Philips has a wide range of connected products for smart home care and personal health that are supported with smart applications for Android and iOS. Typically these products are connected locally via Bluetooth Low Energy or Wi-Fi, and they are also connected to the Philips cloud for remote control or data insights. For these purposes, the Philips Innovation Services organizational unit develops a connectivity platform that comprises embedded hardware, firmware, protocols, and an SDK for creating mobile apps. This connectivity SDK offers components for discovering, connecting to, and interacting with connected products. The SDK targets Android and iOS, with embedded Linux as the native target also becoming more important.

Installed base of mobile apps for Philips’ connected products

The mobile apps for Philips’ connected products have a combined installation count of well over 1 million on the App Store and Google Play. These apps are being installed and used all around the world, with the USA, Europe, and Asia being the biggest markets.

How is Kotlin Multiplatform Mobile used in your product?

One of our SDK components is a client library for Philips’ cloud solution: HealthSuite Digital Platform, or HSDP for short. It enables an app developer to interact easily with the cloud infrastructure without having to write HTTP requests with intricate headers and complex payloads. Instead, developers can call high-level functions, such as

getBlob()

to download a binary file,

sendCommand()

to control a cloud-connected device remotely, or

createDataItem()

to upload telemetry data.


Visit the Kotlin Multiplatform Mobile portal to create your first cross-platfrom application with Kotlin!


Boilerplate code generation with Kotlin

All HSDP service endpoints are documented in the OpenAPI (Swagger) YAML format. Using these definitions, we generate a lot of boilerplate code during a build, which allows us to be ‘in sync’ with the cloud services in production. Our team has created the Kotlin codegen module for the popular OpenAPI Generator, which we are contributing to on Github. The code we generate with this includes all the necessary data transfer objects and classes that wrap the HTTP request/response handling using ktor. This means that we can focus on writing the business logic that builds on top of the generated code, instead of spending extra time working on the plumbing. The moment a production service is upgraded to a new version, we re-generate the code for it using the updated

YAML

file and we can immediately spot the changes we need to make.

Designing an API for Java, Swift, and Kotlin

An interesting aspect of writing a Kotlin Multiplatform SDK component is thinking about your API. Each platform language has its own paradigms. For instance, asynchronous operations are handled slightly differently in each case. In Java it is natural to invoke an asynchronous method with a callback argument to handle the result, for example:

In Swift, we are used to using completion handlers in this type of scenario. For example:

And finally, for Kotlin users we’d like to offer an API with the suspend keyword, so they can make use of it using coroutines. One problem that quickly arose with this was that defining multiple method signatures on the API would generate more than is needed on each platform. Suspending functions are for instance converted for Java, but especially on Android SDK levels below 24 (which don’t have support for all Java 8 language features), the result generates quite a verbose signature that is hard to work with. To address this situation for all target languages, we added functions with specialized signatures for Java, Kotlin, and Swift on the external API. These signatures wrap the

suspend

variant using a custom

runAsync

wrapper function that arranges the correct

CoroutineScope

and

Dispatcher

for executing suspending functions. The

@JvmSynthetic

annotation was key in hiding the incompatible Java variants.

This enables us to offer the API function signatures that feel most natural on each native platform while keeping the business logic concentrated under one implementation.

Why did your team decide to use Kotlin Multiplatform?

We had been busy building SDK components for Android and iOS for a while, and cross-platform code reuse was not really happening apart from a few bits and pieces in C, such as the implementation of the SSDP protocol. However, because of the difficulty of bridging between Java, Objective-C, and C, we actually ended up reimplementing this protocol natively on each platform.

This meant that the development team was also split in two when we were implementing new features. The advent of Kotlin Multiplatform provided a serious opportunity to not only become faster at implementing new features, but also to get more interaction in the team between Android and iOS developers.

We knew that Kotlin Multiplatform would still evolve a lot, but the benefits of being able to write once, test once, and deploy more as a res
ult, were compelling enough.

Our experience

Some of the things that we learned from this experience were:

  • The integration of the Kotlin Multiplatform plugin in the IDE (IntelliJ IDEA/Android Studio) has not always been ideal, but it has definitely improved with each release.

  • There is always a trade-off between code reuse and writing stuff natively, but this holds true for every cross-platform solution. You have to think hard about which types of business logic can be converged and which should remain native.

  • Adopting Kotlin/Native on iOS is definitely harder than using it on Android or JVM, especially when it comes to IDE and debugging support.

  • With Kotlin Multiplatform, our development team is able to push out new features much faster, the codebase is easier to maintain

  • The Kotlin language itself helps us write better code with less effort.

  • We have seen an increase in interaction and knowledge sharing between the Android and iOS developers in the team.

  • Leaving the ecosystem to the community allows JetBrains to focus on the essentials and move faster.

We are planning to target Linux natively as well, so we will have lots of opportunities to see whether the shared codebase pays off. For anyone thinking about using Kotlin Multiplatform, my suggestion would be to look at that portion of your codebase which does not directly interact with platform-native APIs or interfaces that are specific to one platform. Focus on the business logic that has a clear overlap between platforms, since that is where you can actually gain the most.

Contact

Jeroen Brosens, Mobile Connectivity Architect, Philips Innovation Services


Visit the Kotlin Multiplatform Mobile portal to find more about cross platform development!


Continue ReadingPhilips Case Study: Building Connectivity with Kotlin Multiplatform

Results of the First Kotlin Multiplatform Survey

The Kotlin team has always relied on feedback from the community for making decisions about the future of the technology. You will always be our go-to people who know best how to make Kotlin even more enjoyable to work with!

This past November, we conducted our first-ever Kotlin Multiplatform survey with the goal of understanding how the recent changes in the technology have shaped the ways developers use it. This initiative was well received by the community, resulting in an astonishing 1163 replies and 614 fully filled-out surveys, which are the basis for this report. We want to say thank you to everyone who took the time to share their feedback with us.

As a result of this survey, we were able to get a much more complete understanding of our users, how the technology is generally used, and what problems need to be solved to help those using Kotlin Multiplatform for work, personal, or university projects and those who are thinking about adopting Kotlin Multiplatform.

This is the first report of its kind and it will help shed light on the current state of Kotlin Multiplatform. We will also share our thoughts and conclusions about what is going on with the technology and reveal some of our plans for future changes and improvements that will be done in response to the present state.

User portrait

Developers with an Android background prevail among those who use Kotlin Multiplatform. But the number of developers with backend experience is big too. Surprisingly, as many as 8% of the respondents are from an iOS background.

We are very happy that Android developers enhance their knowledge and skills with the capabilities of Kotlin Multiplatform, which helps them go beyond Android development. It is also nice to see that the technology is attracting such a wide variety of users from different backgrounds and that it provides everyone with so many opportunities.

With 61.4% of the respondents having more than 5 years of development experience, we can conclude that Kotlin Multiplatform is interesting to those who have a lot of knowledge in programming. It is an honor for us to be chosen by developers with so much experience. But if you are still a middle or junior level developer, please do not worry — making Kotlin Multiplatform friendlier for everyone is our top priority and we will take steps toward helping less experienced developers get started with Kotlin Multiplatform too.

How Kotlin Multiplatform is used

42.2% of the respondents use Kotlin Multiplatform for sharing code between iOS and Android. This means they are using KMM, which recently branched into a separate project and went Alpha with big investments from the Kotlin team. Mobile targets + WebClient conjunction and backend + WebClient are popular too, but what is most unexpected is that the technology is being used by 16.3% for all existing targets that are aiming to have their code as universal as possible. One example of the all-targets approach is Space by JetBrains, which has recently been released and is built almost entirely on Kotlin.

Kotlin Multiplatform is a popular choice for creating open-source libraries and internal SDKs, but we are very excited to see that the technology is trusted by 41.1% of respondents to build user-facing applications with shared code or at least parts of them. It means that sharing code with Kotlin not only helps many developers save time and effort with a consistent and fast development process, but also satisfies the needs of their users.

“Is Kotlin Multiplatform ready for production?” That is one of the questions we are most frequently asked. According to the survey results, more than 56% of the respondents have already released an application with a shared module or are about to release one in the near future. This means that even though the technology is still in Alpha, it is trusted for use in production and it is already giving many companies and independent developers around the world the benefits of reusing code between platforms.

Data serialization and algorithms are the most popular parts to share between mobile platforms, with internal utilities, data storage, algorithms, and data synchronization just slightly behind. You can find more information about particular companies and their use cases in the case study section of the Kotlin Multiplatform Mobile developer portal.

KMM was designed to help developers reuse their business logic between mobile platforms and still keep the native UI. It is great to see that the original purpose is not stopping developers and KMM is being used for multiple different purposes, from reusing networking logic to sharing the UI.

Check out our step-by-step guide on how to create your first application with a shared codebase.

Main pains

Nothing is perfect and Kotlin Multiplatform is no exception. The strict Kotlin/Native memory model, build setup, problems with libraries, and IDE support tend to bother our users the most. It is good to be on the same wavelength because all of the pain points that are being highlighted are already being included in our roadmap. We hear you and we will try to do something about these issues to make Kotlin Multiplatform as easy and fun to work with as possible.

Tooling

More than half of the respondents use Android Studio to unleash the capabilities of Kotlin Multiplatform. IntelliJ IDEA Ultimate and IntelliJ IDEA Community Edition are the next most used tools with 27.3% and 16.7% respectively. The only way we can improve the developer experience with the IDEs is by creating better tools, but in order to do so, we need more feedback and usage data. We encourage you to help us and enable statistics sharing with JetBrains (if you use IntelliJ IDEA) and Google (if you use Android Studio).

52.6% of our respondents would like to use CocoaPods for exporting Kotlin Multiplatform framework to the iOS app. We are very happy with the amount of feedback we have had about this technology, and we have some great ideas on how we can improve the developer experience of working with it.

We were surprised to discover that 25% are interested in having Swift Package Manager integration. We will pay more attention to this in the future and will reconsider our backlog in order to take further actions to satisfy the needs of our users.  

Onboarding and documentation

We were very interested to find out how developers approached their first Kotlin Multiplatform project. The results show that creating a project with the IDE wizard, using the official step-by-step guides, and cloning the official samples are the most popular ways for developers to start exploring the technology. It is good to know that in order to get started, developers use the KMM portal and the official documentation, but they don’t forget about resources that the community creates and maintains around the world either, as these also provide a great understanding of how to start benefiting from sharing code between platforms.

Improving the experience developers have with Kotlin Multiplatform is our top priority. In order to increase the level of satisfaction with Kotlin Multiplatform, we need to continue to improve and maintain the documentation. From the answers we received, we see that we are lacking particular use-case samples, ready-for-production examples, and articles the most. To cope with this challenge, we have created a documentation improvement backlog that will reduce the lack of these types of content about Kotlin Multiplatform. The focus will first be on common user scenarios that are not well covered in documentation articles, such as testing, and then on creating hands-on tutorials and samples for building apps from scratch and also for apps that have an integrated multiplatform module.

Conclusion

With all the feedback that has been gathered through the first Kotlin Multiplatform User survey, we understand that we are on the right track. The technology is evolving fast and it is already helping many companies and independent developers share code between platforms while they create user-facing applications.

We are very happy that the community has welcomed our attempt to understand how developers use Kotlin Multiplatform and we had more than a thousand replies. This information provided us with many insights and helped us reconsider the fields that had previously not been so clear. We plan to organize this activity on a regular basis and conduct a Kotlin Multiplatform User survey around twice a year.

Once again we would like to say a huge thank you to everyone who participated in this survey! We believe that together we can make Kotlin Multiplatform the best technology to work with.

Continue ReadingResults of the First Kotlin Multiplatform Survey

End of content

No more pages to load