Opinion: Don’t bother with native code

(Image Credit: iStockPhoto/andresr)

There’s always been something of a philosophical discussion over the efficiency of developing native apps. The argument follows that native apps give you access to a platform’s full functionality helping you to manipulate built-in capabilities to create sophisticated applications. Conversely, there is a popular conception that web apps are a stop-gap, which may be easier to run in the browser, but lack the quality of native apps.

But, these perceptions aren’t necessarily fair and comparisons between HTML5 and native apps are not always fought on a level playing field. My argument is that with the right frameworks and JavaScript virtual machines, web apps can be just as powerful as native apps and more scalable. That’s why developers should avoid native code where possible – with one small caveat – native code is bad in the long run if you are not working on or building a platform.

In other words, if you work on the UIKit team at Apple, this article is not for you. If you work on the kernel for Windows, this article is also not for you.

It’s all about quality vs. scale

To create a great application and ensure that it gets into the hands of as many users as possible, it needs to scale for as many platforms as possible. But, native code limits scalability. Two of the most popular mobile platforms for native apps are written in different languages: Java for Android and Objective-C for iOS. Even if you’re proficient in both languages this means having to re-write the code. It’s double the work. Technology silos just don’t work in the long run.

This is where web apps prove their worth. They can scale across any platform, and any device, but without being able to access certain native device functions like the camera or geo-location, web apps in the past have limited app capability. To overcome this issue, web developers often use hybrid applications (i.e. Cordova/Phonegap) so that they can still use their web knowledge and almost build a native mobile application. They key word there is "almost".

Hybrid applications are good enough for a lot of scenarios, but also inadequate for a sizable share of them. Hybrid application performance suffers as applications grow in size. We spent a lot of time trying to debunk the myths that HTML5 on mobile is too slow to be good. The honest truth is that “good enough” just doesn’t cut it for most.

JavaScript Native: the answer to an age old problem

But pause before you jump back into developing native apps. There is a solution here; it’s JavaScript. JavaScript is the only language that runs on every single platform, and the only true "write once run everywhere" language. Whether that's directly on a JavaScript engine, or as an abstraction to native languages, the important part is that the language that the actual business logic is coded in stays the same.

There are frameworks that use the JavaScript engine on the device to evaluate JavaScript and in turn execute native code. The most well-known of these are NativeScript and React Native. Note that neither of these frameworks actually run JavaScript on the device; both include an embedded JavaScript engine (V8 for Android and JavaScript Core for iOS). This means that strictly speaking, both of these frameworks could be extended to the desktop without a huge technical divide to cross.

Change is on its way

The fact that JavaScript frameworks even exist proves that developers will not stop until they can create truly native applications with JavaScript. The Principal Of Least Power – the idea that less powerful the language, the more you can do with the data stored in that language - is as true today as it was when it was first written.

Developers don't have to encapsulate their business logic behind proprietary platforms anymore. Native code no longer has to limit developer innovation. We don't have to sacrifice performance to get that benefit. JavaScript makes it possible to have all business logic in modules that are the single source of truth. Those modules can then be used on the web, on the desktop, and now on iOS and Android thanks to NativeScript.

Do you think native code is becoming redundant for most scenarios? Share your thoughts in the comments.

Related Stories

Leave a comment

Alternatively

This will only be used to quickly provide signup information and will not allow us to post to your account or appear on your timeline.

Anonymus
15 Mar 2016, 3:06 a.m.

The problem can be solved by using c# with xamarin which provides single code working on multiple platform.

Reply