Native vs cross platform development

Shares

Native vs cross platform development

It’s 2017, and arguably the biggest fight after “iOS vs Android” is “Native vs Cross platform app development”. And it is showing no signs of slowing down. Many big organisations like Google, Facebook, Airbnb, Skype have already built their applications on a hybrid platform such as React Native, and Xamarin.

Cross platform solutions are either oversold or an under sold in most cases and many developers and entrepreneurs even fail to make informed decision. So, here’s our take on the current state of cross platform solutions.

What is cross platform app?

In the most simple terms, each platform recommends a specific language to build your apps – For Android it is Java, and for iOS it is Objective -C. When an app is not written in a platform recommended language and runs on multiple platforms, it is called a cross-platform application.

React Native

React Native is JS  + Native UI, developers are now embracing this fast and simple Javascript based platform for it’s much easier free screen and code layouts. While the iOS apps built on top of react native have amazed developers,  android still requires a lot of work in terms of support and making developers understand how the ins and out of react native works.

React Native bring us the opportunity to build apps that feel native without using native code. React native also brings some limited support for Swift on Apple devices, but more support is likely to be slow for the following reasons:

  1. Swift API is currently unstable, and Apple makes major breaking changes in every release.
  2. Swift runtime doesn’t ships with iOS, so it needs to be embedded within each application which significantly bloats app’s size.

The main focus of React Native’s team currently is on improving app performance, that being said the current performance won’t be an issue for the majority of apps built on top of it. React native also updates frequently, which is kind of both good and bad thing for developers. For some it brings the news of fixed patches they requested, for others they need to match their existing code with the newly pushed changes.

While writing code in React Native you don’t code 100% in Javascript, but the most parts of it. And it’s often impossible to drop down Objective-C or Java completely. For now, it is safe to say that to push out low to medium complexity iOS apps on a tight deadline, React Native is the safe bet.

Some concerns recently surfaced about Over the air bug fixes and updates with React Native. As OTA updates are often exploited to push malicious updates, you will always remain under scrutiny and should make sure that you are always playing by the rules. In case of Apple, ensure that your updates don’t significantly alter app’s nature and code is always executed using Apple supplied JavaScriptCore VM.

Kotlin

Kotlin is a statically typed programming language developed by JetBrains, the team behind World’s most popular IDEs. In case, you’re wondering — Statically typed languages are faster because they check and validate the codes at compile-time rather than at run-time.

Kotlin has a multi-OS engine and a cross-platform serialization library, which increase the code shareability. Moreover, the multi-OS engine allows developers to build cross-platform applications for Android, and iOS using Java.

Why Kotlin is better than whatever language you’re using:

Kotlin is concise

The developers coming from a Native(Java) background can understand how many boilerplate codes they had been dealing with. For instance, just look at their extension.

Java had a four-letter extension(.java) when most of the languages keep it to only three letters.

Kotline takes it further and reduces it only two letters(.kt). Boilerplate codes not only slow the performance but add additional load in the runtime.

Pinterest have used Kotlin in their application, and one of their engineers said:

Went back and removed all my for loops. Really liking changed operations (firstOrNull) with an expression brought down one of our models from 115 to 54 lines and I would argue it’s a lot easier now what the class is doing.

Interoperability

Kotlin has an upper hand with its 100% interoperability with Java. The developers have the privilege to use any frameworks, or Native libraries that they want.

Unlike React Native, and Xamarin, which relies heavily on wrappers, or adoptive layers, Kotin doesn’t need any. Moreover, Kotlin codes can be also be compiled to JVM bytecode or Javascript.

Coding error safety

Every once in awhile, the developer gets frustrated with common programming errors like null pointers and other syntax errors. With Kotlin, if you are not sure about a syntax or null function, then put a ? at the end, and it will return a default value when found the thing.

For Instance, if you’re making a server call to get some data, and the function couldn’t execute, then Kotin will use a default instead of showing an error.

Kotlin wasn’t just built on academic theories. But to solve real problems of modern developers who are working with large databases, and complex architectural applications.

Many startups including Pinterest, Evernote have already integrated Kotlin in their applications. And we are going to see a much more rapid adoption in the coming years.

Flutter

Flutter is a UI framework based on Dart, developed and maintained by Google. Fluther is definitely promising with its React Inspired development model and native-like UI for pixel perfect design.

With Flutter, you can do fast iterations and instant UI updates with hot reloading. The architecture is far superior to React Native, which allows developers to put everything in a single codebase and build a high performing application.

Aside from other languages, Flutter promises to be a more interesting framework for developers, as it allows to write apps for ios, Android, and the new unreleased OS, Fuchsia by Google.

At this moment, we are not sure about Google plans, but what if Google replaces Android with Fuchsia, and put Flutter as its app development framework.

However, Here are few things about Flutter that’s promising:

  • Flutter is based on Dart, so anyone who have used Java, or Javascript for web apps would feel home with Flutter.
  • You can build anything on the UI side, that means it’s highly customizable. You have not limited to OEMs widget anymore.
  • Flutter is blazing fast, and use a single codebase for both Android and iOS.
  • Java codes can be copied and run in Dart Framework without any complexity. It gives you more Native flexibility.
  • Flutter has built-in native ios widgets, which drastically reduces the engineering burden.

Kotlin vs Flutter vs React Native

 KotlinFlutterReact Native
Community and SupportBacked by JetBrainsBacked by GoogleBacked by Facebook
LanguageBased on JavaBased on DartBased on Javascript
Platform SupportAndroid, iOS(coming soon) with its multi-os engineAndroid, iOS, and FuchsiaAndroid, iOS, and Windows
UINative UI widgets, and libraries are supported.In-built UI widgets, and library support.Native UI support through adoptive
Native features Support
Direct access to Native features.Mostly supportedThrough binding or Native wrappers
PerformanceFasterFastest Fast
SecurityIt supports most of the security implementations of Android.Authentication, and authorization supported along with oAuth for social logins.Authentication, and oAuth 2.0 supported.
LicensingOpen source(Apache 2.0 license)Open SourceOpen Source

 

Xamarin app development

Xamarin is said to be the closest thing to Native when you are not using any native language. People love Xamarin and it has evolved as one of the most successful cross-platform solutions today.

Some common myths about Xamarin are:

  1. It’s buggy – Xamarin isn’t full of bugs as many reports. Often these reports are a result of a code optimized for local values. To deal with any uncaught expressions, Xamarin allows stack trace with the number line.
  2. Xamarin.Forms == Xamarin. Actually, Xamarin.Forms != Xamarin. There’s a flying misconception about Xamarin Forms as being the primary UI library for building apps. Xamarin facilitates a more comprehensive set of libraries to build native UI codes.
  3. Xamarin doesn’t cover many native features. Xamarin actually covers almost 100% of the native APIs and provide access to almost all native features.
  4. Limited documentation  – Xamarin actually has a complete set of documentation with 300 example apps to help you.

 

Xamarin is not just a FAD, it’s a real thing, so what’s bad about it? Well, there’s a serious concern about memory management stemming from a disposable C# wrapper around native objects.

Which brings us to the question “When should one use Xamarin?”.

The first and most obvious case for using Xamarin is when you are low on resources and you still wish to publish on all major platforms. Secondly, if you are developing a Windows app it does makes a lot of sense to use Xamarin, it works seamlessly with Windows ecosystems.

Lastly, if your business is already using Microsoft based technologies, using Xamarin could bring in a lot of ease.

Cordova and PhoneGap

PhoneGap is an Adobe-owned cross-platform solution that helps developers to launch their apps on all platform. PhoneGap runs on top of Apache Cordova. Most of the developers using HTML5 apps are now utilizing the Ionic framework to get performance focused and well-designed components. Ionic relies on Angular-JS and Sass and provides UI components that you can use in your apps, reducing any need for to optimize UI in most cases.

Most of the problems that developers face arise from the fact that they are either using 3rd party libraries or are doing things synchronously instead of doing it asynchronously.

The thing about using these two platforms is that a developer should try to do his best, otherwise he would end up with an app that has choppy and slow animations. And while testing code on computer browsers seems okay, the code would not perform comparably on real mobile devices.
While there has been some support for Apple Watch and Android Gear, PhoneGap and Cordova clearly doesn’t fit properly for this wearables right now.

Cross-platform vs native apps performance comparison

The following charts sum up the performance of some of these cross-platform computing tools.

Performance of Xamarin vs Java on Android.

RunJavaXamarin  
12.7493.33
22.7592.48
32.6642.866
42.6762.459
52.8323.367
62.7092.875
72.7233.172
82.7753.386
92.7272.689
102.723.353
Average2.73342.9977

The results below illustrate cross platform vs native code performance.


RunJ2ObjCJ2ObjC/ARCSwift 1.1Swift 1.2Swift 1.1/J2ObjCSwift 1.2/J2ObjCXamarinRoboVMRubyMotion
10.6761.0472.7041.0031.3100.9061.1640.71220.732
206851.0492.8011.0091.1930.8780.6620.70721.856
30.6821.0062.6861.0141.2030.8710.4760.70521.435
40.6811.0082.6841.0051.1940.8701.3780.69521.111
50.6770.9682.6921.0081.1950.8740.9830.71121.651
60.6760.9582.6831.0001.1970.8711.1890.70920.929
70.6810.9772.6841.0091.2010.8700.9540.70022.189
80.6731.0222.6811.0041.1970.8691.1820.71021.275
90.6740.9532.6801.0041.1960.8700.8130.69921.100
100.6870.9562.6841.0021.1950.9000.8130.69821.825
Average0.6790.9942.6981.0061.2080.8781.0150.70521.810

An enterprise’s best friend – Cross-platform apps

Imagine an enterprise whose mobile strategy is web and mobile only, they are an iOS-focused organization. Two years later they re-assess their mobility needs and find that cost-effective Android handsets could bring a lot more savings. They look into the costs of porting their iOS apps to Android which brings additional costs. Now as you can imagine a native app would mean a lot of lost opportunities in this case, while having a cross-platform based app would allow them the flexibility of easy migration to Android, thereby being truly beneficial.

Best Multi-Platform apps running on these solutions

  • React native app – Discovery VR
  • Apps using Xamarin – Down JonesWatch(iOS) and Trello
  • PhoneGap based app – Pacifica

And there’s the “But”!

But when cross-platform apps are this awesome, Is there a need for this discussion?

Well, apart from the performance, costs, and availability a true mobile strategy requires much more to be successful. Other significant parts of a successful mobile strategy include:

  1. User experience
  2. Frequency of updates
  3. SDK Integration
  4. Security
  5. Multithreading
  6. Other situational parameters

 

We will now discuss these one at a time.

User experience

No doubt that you can develop and replicate almost any user interface, but how well that UI performs is very important. A user perceives a system that has a response time of 0.1 seconds as a responsive and continuous system. Third party development platforms do suffer from this issue of Jank or Lag.

The frequency of updates

With each release of a feature in mobile phones and wearables, the cross-platform tools always find themselves chasing deadlines and fixing a number of bugs. Which could be a huge missed opportunity. As it often takes days if not months to come up with a solution, let alone a perfect one.

SDK Integration

Often underlooked on mobile strategies, especially by small developers, it is one of the most important parts of your future mobile growth. Often many cross-platform solutions are way too immature to accept or to bind with the new SDKs. We have often seen cases when the entire app had to be redeveloped natively to allow growth critical SDKs to be integrated with them.

Security concerns

Both native and cross-platform apps have their own type of security concerns. But native app development provides us the opportunity to bring more and more natively built solutions that could make the work of attacker comparatively very difficult. More specifically when cross-platform apps are coded by a Rookie, they are more prone to JS injections, weak SSL implementations, and caching issues.

Multithreading

We have no multithreading on the hybrid app development platforms, which is always an option when you are doing native app development. Some solutions like Titanium allows multi-threading and some don’t.

Complex architecture

Cross-platform solutions are very good for what they are made. But when you face a complex problem that hasn’t been solved yet, going native is the preferred way. You cannot bet on wrappers to accomplish what a native code can when it comes to complexities
While these are just some of the factors that should be considered before selecting a cross-platform technology, but many of them are unique that requires close inspection. For example, if the OEM’s brought in some changes that would render a particular cross-platform solution unsuitable.

What does 2018 hold for cross-platform application development?

Apple has already released Swift 4, which holds great promises for the developer community. Google’s Flutter is still in Alpha, and we are not too sure about them releasing it next year.

Aside from some performance issues, React Native and Xamarin offers excellent code sharability, faster shipping time, third-party libraries, and Native UI components to build scalable hybrid applications.

Ionic, on the other hand, is still immature, and not suitable for Enterprises.

Maitrik Kataria

Maitrik leads the Digital Enterprise team at Simform. Under his leadership he helps businesses leverage digital transformations through advanced digital and customer experience strategies.

Join 1,000+ Industry practitioners who get mobile engineering insights from us!

Get our latest mobile application engineering insights and reports delivered directly to your inbox

You have Successfully Subscribed!