Comparison: Flutter Vs NativeScript

Two serious contenders in the battle of mobile application development technologies.

First I should mention that maybe we could include React Native, Xamarin, Appcelerator, Fuse, Ionic, and some others since the cross-platform mobile application development battle is not only between them, but there are many other contenders, with advantages and disadvantages of course, but we are going to leave those other frameworks in the pipeline for now.

Flutter it came to version 1.0. Flutter is Google’s technology that allows us to build native applications for iOS and Android with a single base code, its stable version arrives in less than two years after being launched in May 2017, although they had already released the project since 2015 at the Dart Developer Summit.

About Dart

Skia is an open-source graphic library sponsored and maintained by Google,… Is Google in everything?

Flutter is programmed in Dart which transpires to JavaScript similar to the development in NativeScript with TypeScript which is also transpired to JavaScript but Dart can be executed directly in Dart’s virtual machine (the Dart VM ) which opens up other possibilities such as Dart server-side.

At this point, we could say that JavaScript with NodeJS got into server-side a long time ago.

The original Flutter team evaluated many programming languages ​​and chose Dart because they fit the way they wanted to build the interfaces.

Dart allows Flutter to avoid the need for a separate declarative language layer like JSX or XML, or separate visual interface constructors because Dart’s declarative programming layout is easy to read and visualize. And with all the layout in one language and in one place, it’s easy for Flutter to provide advanced tools that make the layout a snap.

In NativeScript, if we do the development “vanilla” we will have an XML file where we make the layout, although it is much easier than doing it programmatically, we do not stop having this layer, if we make our NativeScript project based on Angular, we will have to adjust our components to give an HTML / XML output, that is, to adjust to the way Angular does things.

So NativeScript (and if ReactJS also hurry me):

  • Run JavaScript in a VM
  • Has access to platform APIs and UI components
  • They offer a level of abstraction for both platforms, as well as direct access to the native UIs.
  • Provide some form of marking to build and style to the UIs (as mentioned).

NativeScript reached version 5.1, which speaks of a maturity since it has more time in the market.

Ahead of Time (AOT)

According to the official documentation, Flutter is built in a new way, completely different compared to other existing frameworks, it works more like a game engine than a traditional mobile application framework.

In Flutter, the applications are composed of Widgets, which are drawn on a Skia canvas (mentioned above) and sent to the platform. The platform displays the canvas and sends the events back when required.

Starting from the platform level, Flutter provides a shell (Shell) that hosts the Dart VM. The shell is platform-specific giving access to the APIs of the native platforms and hosting the relevant canvas of the platform that is being established. There is also an API that embeds, if we want to use Flutter as a library, instead of hosting a running app.

Compiling in native code also of course not only improves the execution but also the startup times of the application as Dart can also be compiled just in time (JIT) to achieve exceptionally fast development cycles and workflows that change the current way of working (including Flutter’s popular hot load sub-second stateful).

NativeScript works by exposing native APIs directly to JS, dispatching calls, and converting data on the fly.

In a little more detail, NativeScript technology can be presented as a multi-part construct — Runtimes, Core Modules, CLI, and Plugins, which is illustrated in the following diagram.

The runtimes NativeScript layer allows us to call APIs in iOS and Android frameworks using JavaScript code. To do this, the JavaScript virtual machines are used — the Google V8 for Android and the WebKit JavaScriptCore implementation distributed with iOS 7.0+.

The Core modules of NativeScript are used to provide the necessary abstractions to access the underlying native platforms, for example, let’s think about the gesture module (pinch, double-tap, scrolls, long presses, and flinch in Android on iOS there are others like swipe), this defines a common API in JS that translates an application’s TypeScript / JavaScript code into native gesture API calls (thanks to Runtimes).

We could say that NativeScript (and ReactJS) are built from the top down, start with the JavaScript requirement, and then fill in the rest.

At the end of the day, who runs the best? What technology is more efficient in terms of performance? size? Is the difference significant enough to change technology? Well, I do not know, but we will do the corresponding tests to contrast the differences in applications made on both platforms. Please be patient.

If we go to a more general and perhaps strategic panorama, Google has an ace up its sleeve called Fucshia, the Google operating system that is said to eventually replace Android (in many years I think but that’s where it goes) development in Flutter will be natural or native.

Without a doubt JavaScript is one of the most popular languages ​​in the world, Dart I don’t think so (the TIOBE index places it at # 25), so there are more people contributing code, solving problems and in general, making life of the developer more friendly it has a guaranteed future, this goes to either side.

But the fact that Flutter is the only SDK for mobile applications that provides reactive views without requiring the JavaScript bridge should be a reason to pay attention and test and try to develop in this technology, but there is something more revolutionary in Flutter still, than is the way you implement widgets.

Christina Cheeseman is a Technology Strategist at Elitech Systems. She enjoys writing about Technology, marketing & industry trends.