blog-main-image

Why Choose Rust for Mobile App Development?

Let’s be honest—developing mobile apps that work on both iOS and Android can feel like a balancing act, right? If you want your app to reach a broad audience, you’ve got to make sure it works perfectly on both platforms. But here’s the tricky part: developing for two platforms at once. Typically, you have two options:

  1. Native Development: This is the best choice. You build separate apps for iOS and Android, ensuring that each platform gets its own custom-built experience. It’s great for performance, flexibility, and a super-smooth user interface (UI). But here’s the catch—it’s expensive and means twice the work. You’re maintaining two codebases, which feels like creating two entirely different apps!
  2. Cross-Platform Development: A more cost-effective option. You write the code once, and it works on both iOS and Android. Simple, right? But there’s a trade-off: you might lose out on flexibility and performance since you’re not tapping into the unique strengths of each platform. The app works everywhere but may not feel as polished as a native experience.

But wait! What if I told you there’s a better way? At PayTech (one of CodeSuite’s projects), we’ve found a third option—a hybrid approach that gives us the best of both worlds. How do we do it? We code all our core logic in Rust and share it between our native iOS and Android apps. This way, we create powerful, efficient apps without the common headaches of other methods. Curious? Let me walk you through how we landed on this Rust-powered mobile app development strategy—and why we’re sticking with it!

Our Journey: From React Native to Rust

It all started when we built the PayTech Business Wallet, a Point-of-Sale (POS) app for small businesses. It lets them receive payments instantly, with just a few taps. For our first version, we went with React Native, a popular choice for cross-platform development. It seemed like the perfect solution: build once, run on both iOS and Android, save time, and avoid the pain of managing two codebases.

Sounds great, right? Well, not so fast. As we dove deeper into development, we hit some serious roadblocks that made us rethink our strategy.

  1. Limited Cryptography Tools: React Native’s JavaScript environment wasn’t cutting it when it came to cryptography—specifically Elliptic Curve Cryptography (ECC), which is crucial for handling financial transactions. This meant we had to build separate native modules for both iOS and Android. Ugh, double the work!
  2. Dependency Chaos: The fragmented JavaScript framework turned managing dependencies into a nightmare. For an app dealing with sensitive financial data, we couldn’t risk it. We needed something rock-solid, but the complexity of managing multiple libraries increased the chances of security vulnerabilities.
  3. UI Performance Problems: While React Native made it easier to create cross-platform apps, it didn’t give us the smooth, fast performance we were hoping for. And when a bug popped up on one platform, it often affected the other too. Frustrating!
  4. Cumbersome Build Process: React Native was supposed to speed things up, but instead, we found ourselves stuck in a slow, error-prone build process. Instead of speeding up development, we were bogged down by performance bottlenecks and frequent build issues.
  5. Specialized Skills Required: To make React Native work, you still need developers who know both iOS and Android inside out. Finding talent with expertise in both platforms? Let’s just say it’s like sourcing a developer with deep expertise in both iOS and Android—a rare and highly specialized skill set.

At this point, it was clear—we needed a change. We considered Flutter, but we were hesitant about running into the same problems. So, we went native, hoping for better performance, more control, and fewer headaches. But then we discovered Rust—and that’s when things got interesting!

Why Rust? The Next Big Thing for Mobile App Development

As we began work on another project, the PayTech Personal Wallet (a non-custodial wallet for individuals), we realized we needed a powerful, reliable software development kit (SDK) to handle the core financial logic. That’s when we came across the Transaction Development Kit (TDK)—a Rust-based SDK designed for complex financial operations.

Why Rust? Well, it’s fast, safe, and handles concurrency like a champ. Perfect for our needs! However, there was one hiccup: TDK’s Swift and Kotlin bindings weren’t fully developed, and updates were slow. We didn’t have time to wait around, so we decided to take matters into our own hands.

We built our own Rust library around TDK, using UniFFI to connect Rust’s logic with Swift (iOS) and Kotlin (Android). We called this library paytech-lib (PTL). This allowed us to handle all the heavy transaction-related logic in Rust and share it across platforms while keeping the UI native.

As we pushed more business logic into PTL, it became clear—this was a smart move. The more logic we handled in Rust, the less we had to rewrite for iOS and Android. It was saving us tons of time and reducing redundancy.

Seeing the success of this approach in the PayTech Personal Wallet, we decided to do the same for the PayTech Business Wallet. We created another Rust library, paytech-business-lib (PBL), and voila! We now had a hybrid system where Rust handled the core logic and native code handled the UI. Brilliant, right?

rust for mobile app developmenr

Why Our Rust-Powered Approach Rocks

So, why is Rust such a game-changer for our mobile app development strategy? Here’s why we love it:

  1. One Codebase, Multiple Platforms: We write our core logic once in Rust and use it on both iOS and Android. This means fewer bugs, less time spent on maintenance, and quicker updates. And in the future? We could even extend our Rust core to other platforms like the web using WebAssembly. Cool, right?
  2. Rust = Speed + Safety: Rust is known for high performance and memory safety, thanks to its ownership model. Unlike languages with garbage collectors, Rust gives us efficient memory management without compromising speed. For an app dealing with financial transactions, security is everything—and Rust delivers that peace of mind.
  3. Best of Native Apps: By keeping our UI in native code, we get the best user experience possible. Our apps are fast, responsive, and can fully tap into platform-specific features. It’s the best of both worlds—shared logic with Rust, polished UI with native code!

The Challenges We Faced

But let’s be real—every great approach comes with its challenges. Here’s what we learned along the way:

  1. Complex Integration: Adding Rust into the mix adds a bit of complexity. Bridging Rust with Swift and Kotlin wasn’t always easy, and debugging issues across both native code and Rust required some serious problem-solving. But thanks to UniFFI, we were able to automate most of the process.
  2. Learning Curve: Rust is a relatively new language in mobile development, so our team had to get comfortable with its syntax and unique features. We also had to understand how Rust dependencies work on both iOS and Android platforms. It took some time, but the effort has paid off.
  3. App Size: Embedding Rust libraries can increase the size of the app, which can be an issue on devices with limited storage. We managed this by optimizing our libraries and keeping them as lean as possible.
  4. Limited Resources: Rust is still emerging in the mobile development world, so there aren’t as many resources or community examples. Sometimes, it felt like we were forging our path. But knowing that companies like Mozilla use Rust for their browser development gave us confidence that we were on the right track!

Why We’re Sticking with Rust

Despite the challenges, using Rust has been a total win for our mobile app development services. Here’s why we’re sticking with it:

  1. Streamlined Development: By cutting down on code duplication, we save time and can focus on building great features instead of rewriting the same logic for different platforms.
  2. Boosted Performance and Security: Rust gives us the performance and safety we need, especially for apps handling sensitive financial data.
  3. Top-Notch User Experience: Keeping the UI native means our apps are fast, responsive, and user-friendly.

In short, Rust allows us to build high-quality mobile apps for iOS and Android without compromise. It’s fast, safe, and perfect for apps that need performance.

So, if you’re thinking about taking your mobile app to the next level, why not give Rust a try? It might just revolutionize the way you build apps!

At CodeSuite, we’re always looking for new ways to push the boundaries of mobile app development services. Want to see what Rust can do for your next app? Let’s talk!