Cross-Platform Development in 2024 3/3

Cross-Platform Development in 2024 3/3

·

8 min read

Introduction

In my previous article Cross-Platform Development in 2024 2/3 I explored 3 cross platform tools: Cordova, Progressive Web Apps (PWAs) and React Native. In this article I will proceed to explore the other 3: Xamarin, Flutter and Kotlin Multiplatform. So let's jump right into it.

Xamarin

What is Xamarin?

Xamarin, built on the open-source.NET platform and later acquired by Microsoft, is a cross-platform development framework utilizing the C# programming language. With support for iOS, Android, Windows and Mac, it facilitates the creation of native apps. Integrated into Microsoft's Visual Studio, Xamarin primarily leverages this robust integrated development environment, although developers have the technical flexibility to write Xamarin code in various editors. A notable advantage of Xamarin lies in its capacity to segregate shared business logic from the app's user interface, allowing an estimated 70 to 90% of code in the business logic tier to be reused across different platforms.

Xamarin App Architecture

Xamarin offers the Xamarin.Forms package, enabling developers to create the UI using C#, establishing a unified development stack for multiple platforms. The development process for Xamarin apps revolves around C#, utilizing platform-specific libraries to craft business logic for cross-platform applications. Optionally, Xamarin.Forms can be employed to develop the UI for all platforms using C#. The Xamarin framework automates the compilation of apps for supported platforms and is adept at handling memory allocation, garbage collection, and platform interoperability.

The outcome is applications that are frequently likened to native ones, boasting comparable performance and user experience on both iOS and Android mobile development platforms. A Xamarin app comprises shared business logic, often covering aspects like database and network access in C#. The UI can be coded in C# using Xamarin.Forms or natively, inside or outside of Visual Studio, resulting in a Platform Native App compatible with platforms such as Android, iOS, Windows, and Mac.

Xamarin's Strength

  1. Unified Development: It offers a single entry point for mobile development across various platforms, enabling developers to use one language (C#) and one tool (Visual Studio) to target iOS, Android, Windows and Mac. This results in a comprehensive end-to-end solution in the cross-platform market space.

  2. Performance Parity: Xamarin apps deliver performance comparable to native apps in Java, Objective-C, or Swift, ensuring a seamless user experience.

  3. Consistent UI: Xamarin provides UI components through Xamarin Forms or native UI development, ensuring that Xamarin apps maintain the look and feel of native apps across platforms.

  4. Device Functionality: Xamarin apps seamlessly integrate with common device functionality across platforms using plugins and specific APIs, eliminating hardware compatibility issues.

  5. Native Libraries Linking: Xamarin supports linking with native libraries, allowing for better customization and the incorporation of native-level functionality with minimal overhead.

  6. Open Source and Backed by Microsoft: The Xamarin SDK is open source and backed by Microsoft, ensuring continuous support and development. Microsoft's commitment to building apps for Android and iOS positions Xamarin as a key player in this ecosystem.

  7. Strong Developer Community: Xamarin benefits from a strong community of developers skilled in C# and the .NET platform, making it comparable to finding developers for writing native apps. Xamarin developers can target multiple platforms, unlike native developers who usually focus on a single platform.

  8. Integrated and a Cross-Platform Development in Visual Studio: Xamarin development is primarily done in Visual Studio, offering first-class support for creating Xamarin apps. Visual Studio allows building native UIs for Android and iOS seamlessly using drag-and-drop tools. For those new to Visual Studio, it provides a unified environment for creating cross-platform native apps without the need for patching together various tools.

  9. Xamarin Live Player: This tool enables continuous deployment, testing, and debugging directly on iOS and Android devices, streamlining the development and testing process.

Flutter

What is Flutter?

Flutter, a cross-platform native app framework developed by Google, is an open-source solution that generates native apps for Android, iOS, web, Linux, Windows and Mac. Its seamless integration with development tools such as Android Studio, IntelliJ and Visual Studio is facilitated by plugins dedicated to the Flutter framework and Dart programming language.

Flutter App Architecture

Flutter employs a unified set of tools and technologies for diverse platforms, primarily utilizing the Dart language to construct Flutter widgets. These widgets, written in Dart, are compiled into native apps by the Flutter framework, delivering applications compatible with Android, iOS, web and desktop platforms.

Flutter's Strengths

  1. High-Speed Deployment: Similar to React Native, Flutter excels in delivering fast, native-speed applications. By generating native apps, Flutter ensures performance comparable to other native apps on the device, eliminating the slower nature of hybrid apps running within platform-specific web components.

  2. User Interface Development: At its core, Flutter is a user interface development tool that revolves around the concept of widgets. Every element in a Flutter app is a widget, enabling developers to compose custom widgets as needed. These widgets are compiled to utilize the same UI components as regular iOS, Android apps web apps or desktop apps, with Dart replacing Swift, Objective-C, or Java or Javascript or C/C++ for assembly.

  3. Declarative Programming with Dart: Flutter employs Dart, a modern and expressive programming language that adopts a declarative approach. Declarative languages enable developers to focus on the "what" rather than the "how," streamlining the development process. This approach allows Flutter developers to maintain a single code base for both Android and iOS.

  4. Platform Independence: Flutter effectively manages platform differences, freeing developers to concentrate on the app's functionality rather than the intricacies of various platforms. This results in a unified development experience across Android and iOS platforms.

  5. Hot Reload Feature: Flutter incorporates a powerful feature called hot reload, allowing developers to experiment with code modifications while the app is running. It facilitates real-time debugging and correction of crashes without interrupting the development flow.

  6. Modern Framework with Built-in Widgets: As a modern framework reminiscent of React, Flutter includes a 2D rendering engine and pre-built widgets that adhere to material design for Android and Cupertino themes for iOS. This approach streamlines the development of visually appealing and consistent applications.

  7. Integration with Developer Tools: Flutter has strong ties with popular developer tools, including Android Studio, IntelliJ and Visual Studio. This integration enhances the development environment, making it convenient for developers to work seamlessly within their preferred IDEs.

Kotlin Multiplatform (KMP)

What is KMP? What is KMM?

Kotlin Multiplatform (KMP) is a technology developed by JetBrains that allows you to write code in Kotlin that can be shared and run across multiple platforms like Android, iOS, web (JavaScript), desktop (Windows, macOS, Linux).

Kotlin Multiplatform Mobile (KMM) is extension of KMP, specifically tailored for mobile application development with a primary focus on Android and iOS.

KMP App Architecture

KMP aims to address the challenge of developing and maintaining separate codebases for different platforms, which can be time-consuming and error-prone. With KMP, you can write common business logic, data models, and utility functions in Kotlin and then target specific platform-specific implementations for user interfaces, networking, and other platform-dependent features.

Sharing code between mobile platforms is a major Kotlin Multiplatform use case. With Kotlin Multiplatform, you can build cross-platform mobile applications that share code between Android and iOS projects to implement networking, data storage and data validation, analytics, computations, and other application logic.

KMP's Strengths

  1. Shared Code: Develop the essential logic of your application or library in Kotlin, creating code that can be shared across diverse platforms. This code, usually platform-agnostic, encompasses business logic, algorithms, and data models.

  2. Shared Interfaces: Define shared interfaces or APIs with Kotlin Multiplatform, enabling different implementations on each platform. This ensures a consistent API while accommodating platform-specific requirements.

  3. Gradle Integration: Manage Kotlin Multiplatform projects seamlessly with the Gradle build system. Gradle facilitates the configuration and building of shared code and platform-specific implementations.

  4. Code Sharing: Reuse code across platforms to minimize duplication, enhance maintainability, and potentially expedite development. While some platform-specific code may still be necessary for an optimal user experience, Kotlin Multiplatform aims to maximize code reuse.

  5. Platform-Specific Code: Tailor platform-specific implementations for each target platform (e.g., Android, iOS, JavaScript), addressing interactions with the platform’s APIs, UI components, and other features.

💡
In summary, Kotlin Multiplatform serves as a robust tool for developers aiming to create cross-platform applications or libraries using Kotlin. It streamlines the process of targeting multiple platforms without compromising code quality or maintainability. Keep in mind that KMP's features may evolve, so referring to official documentation and resources for the latest information is advisable.

Other Options

Having looked at a few of the more popular Cross-platform frameworks, I would like to briefly mention some that you may not have heard of or know little about:

  1. Corona SDK: For Cross-platform game development, explore Corona SDK. It's a gaming engine that utilizes the Lua Programming Language to construct Cross-platform apps, providing full access to the native system.

  2. NativeScript: This is a Cross-platform JavaScript framework generating platform-native UIs with Angular, TypeScript, and JavaScript. Developers can choose their preferred tools, and NativeScript can be installed as a Visual Studio plugin. Learn more at the NativeScript homepage.

  3. Ionic Framework: An open-source framework for hybrid mobile apps, Ionic is built on Cordova and supports Angular JS, TypeScript, HTML, CSS, and JavaScript for app development. It offers starter templates, additional native plugins, and app themes. Visit the Ionic Framework website for more details.

  4. Codename One: If you're a Java developer, Codename One is worth checking out. It functions as a plugin for Eclipse, NetBeans, and IntelliJ, offering a second-generation drag-and-drop GUI builder. It's free and open source, allowing you to stay within the Java language for your development needs.


In another article I plan to talk about how you can choose a cross platform to use in your next massive cross platform project: Choosing a Cross Platform Tool in 2024. So see you there.