Advertisements

The world has gone mobile. It has become a “must have” element for any organization, regardless of its size. Undoubtedly, some organizations can concentrate on only one mobile OS (operating system) and avoid all the other ones, yet it is important for many businesses to focus on a myriad of mobile devices with various operating systems. Gone are those days when you were satisfied with only having a mobile app. Today, it is important that the app must support Android gadgets, iPads, Windows Phone, Amazon Kindle, Tabs, BlackBerry, etc.

One of the most challenging situations for app developers is, whether to develop a native mobile app or go for cross-platform. Of course, as a business, you require dealing with different types of customers who possess different types of devices. Therefore, you’d need to have a mobile app that could work seamlessly on almost all the platforms (i.e. Android, iOS, Windows, etc.)

What are cross-platform apps? 

In ideal scenario, cross-platform apps work on multiple operating systems with a single code base. There are 2 types of cross-platform apps:

  1. Native Cross-Platform Apps
  2. Hybrid ‘HTML5’ Cross-Platform Apps

Native Cross-Platform Apps

Every major mobile operating system has its own SDK (Software Development Kit) to create mobile apps. These SDKs also have preferred programming languages which are supported by the OS vendor. For example, for iOS, Objective-C and Swift are the preferred programming languages supported by Apple, whereas for Android, Java is the preferred language supported by Google. Generally, apps created with these languages using the official SDK are called as “native apps”.

However, it is possible to use APIs (Application Programming Interface) provided by the native SDK, in other programming languages which are not supported by the OS vendor. This is how “cross-platform” native apps are created. Generally, a third party vendor chooses a programming language and creates a unified API on top of the native SDKs provided by the various OS vendors. Using this unified API, it is possible to support multiple operating systems with a single code base. The third-party vendor generally provides an IDE (Integrated Development Environment) which handles the process of creating the native application bundle for iOS and Android from the single cross-platform codebase.

Since, the final app produced still uses the native APIs, the cross-platform native apps can achieve near native performance without any visible lag to the user.

Current State of Implementation

Though creating cross-platform native applications is possible today, the current state of implementation is far from complete. Most of the mobile apps are heavy on the GUI (Graphical User Interface) implementation side. Almost all the critical business application logic resides on the server which is accessed by the mobile via web services.Since the User Interface (UI) and User Experience Design (UXD) of iOS and Android are quite different from each other, it’s not an easy task to create a uniform GUI wrapper on top of it. Though Xamarin and others have put in significant work on this front, it is far from perfect. It works well if you design your application to live within the framework’s limitation, however, if you need anything that doesn’t fit with the framework’s vision, it requires a lot of work to implement and requires writing platform specific code. To give you an example, in Xamarin Forms, it takes a lot more work if your designer chooses to give custom colored borders to text fields. As this is not obvious to the designer, once you have settled in on the design, the programming team needs to put in a lot of efforts to pull off this seemingly simple design. Xamarin is working hard to provide more advanced cross-platform UI components under their Xamarin Forms Labs project. But many components of this project are still under beta status.

One popular approach taken in native cross-platform development involves writing business logic and web service calls using cross-platform libraries while GUI related code is written with platform specific libraries. Depending on the application, this can allow 30% to 60% code reuse.

Popular Native Cross-Platform Frameworks

  1. Xamarin: A California-based software company, which now is backed by Microsoft, founded in 2011. Xamarin uses C# as the main language for the cross-platform development. C# is a statically typed language with mature tooling and IDE support. Also, many big companies have C# programmers already in their in-house IT departments. So,  enterprises tend to regard Xamarin as a good investment.
  2. Appcelerator Titanium: One of the earliest players in this domain. They launched iOS support in 2009 while Android support was added in 2012. Appcelerator Titanium uses JavaScript as the main language for development and aims at bringing familiar web development paradigms to native mobile application development. However, it somehow didn’t capture the mainstream attention but lots of applications development is happening on top of it. Appcelerator also has a proprietary paid MBaaS (Mobile Backend as a Service), which it is pushing more. In the early days, Titanium had quite a few issues which were discussed widely in the blogosphere. This may also have hampered its adoption.
  3. NativeScript: Like Titanium, NativeScript aims at making web-like programming available to app development. NativeScript was announced by Telerik, a company which is famous for its suite of GUI components for enterprise applications in 2014. It uses JavaScript as the main development language. Native script also supports TypeScript, Angular and uses CSS for styling. Compared to the other technologies mentioned above, NativeScript is relatively new but it has a lot of potential.
  4. QT: QT is one of the oldest cross-platform desktop development libraries around, released 21 years ago, in the year 1995. They added support for cross-platform iOS and Android applications in 2013. QT uses C++ along with QML (Qt Meta Language or Qt Modeling Language- it’s a markup language similar to HTML) to create cross-platform applications. However, QT GUI components, by default, don’t follow the look and feel of iOS and Android. Also, C++ is not an easy programming language because of its huge syntax, manual memory management and standards compatibility issues. However, in the hands of experienced C++ programmers, QT can be quite productive.
  5. RubyMotion: RubyMotion is the main language for the development. One of the early players in this domain. When first announced in 2012, it was for iOS only, but supports both iOS and Android, since 2014. Rubymotion requires separate GUI code for iOS and Android, however, business logic can be reused across-platforms.

Hybrid ‘HTML5’ cross-platform Apps

Mobile apps are essentially GUI applications. Most mobile apps depend on backend web services for large parts of their business logic. Roughly speaking, in mobile apps, especially in the business process automation domain, almost 60% of the code deals with creating and managing the GUI.

Advertisements
Advertisements

iOS, Android and Windows Phone, all have a very advanced browser component in their SDKs. By leveraging this WebView component, programmers are able to use standard HTML5 web technologies to design and program parts of their application. So in the end, the application is composed of at least a native frame and HTML/JavaScript executed in a WebView – which is why they are called “hybrid”. Application features which need sensor input like geolocation, camera or lower level functions like accessing the file system usually use some JavaScript-to-native bridge provided by the hybrid application framework.

 The image below shows the architecture of a typical hybrid application:


Cordova / PhoneGap

Apache Cordova which was originally named as PhoneGap (launched in early 2009) is the most popular hybrid cross-platform framework. It supports most of the major modern smartphone operating systems. Since in hybrid cross-platform frameworks HTML and CSS are used to create GUI, almost all of it can be used across different operating systems. With libraries like framework7 (http://framework7.io/) it is also possible to support the underlying operating system’s default look and feel using CSS-based themes.

In hybrid applications the HTML, CSS and JavaScript code is shipped along with the application. Therefore, there is no delay in loading the UI related code, like you would experience it when loading websites over the network. On modern powerful phones, it’s possible to create a snappy UI with HTML5 technologies. Especially for B2B apps, it’s possible to have 85-90% code reuse across-platforms with Cordova.

The image below which will help to put all the mobile app development options in single perspective:

To summarize, here are the pros and cons of the cross-platform mobile app development:

Pros of cross-platform mobile app development

  1. With careful planning around 50%-80% code reuse can be realized across-platforms. This results in faster development and reduced costs.
  2. Cross-platform development provides more benefits during the maintenance period. If a bug is found in a common codebase it needs to be fixed only once.
  3. Unit tests are required to be written only once for the common code, hence the saved budget can be used to write more thorough unit tests.
  4. It is possible to use existing programming talent rather than learning platform specific development language.
  5. Ideal for B2B apps and business process automation apps, where time to deployment and efficient utilization of resources is more important than sleek look and feel.

Cons of cross-platform mobile app development

  1. In general, phones are not as powerful as desktops when it comes to raw processing power. Many mid-level and entry level phones don’t have enough hardware power to perform smooth HTML5 animations. Because of this HTML5 hybrid apps can lead to sluggish UI on low and mid range phones.  Also since browser components have evolved with the operating systems, it’s relatively painful to support operating systems which are more than three years old.
  2. Rendering modern HTML and CSS which uses advanced features like gradients requires a lot of CPU and GPU resources. Thus, HTML5 based apps consume significantly more battery compared to native apps or native cross-platform applications.
  3. Usually, HTML5 hybrid apps depend on callback-style programming to communicate with native plugins, which makes the code unnecessarily complicated. Also for some tasks, this might lead to impractically slow solutions.
  4. Native cross-platform app SDKs are not mature yet. GUI needs to be coded multiple times to obtain platform specific look and feel.
  5. Many successful apps are developed as native apps (either Android or iOS) because designing and building an app for multiple platforms with platform-specific user experience is too difficult. This is due to all platforms defining their own human interface guidelines and supporting them with a single code base turns out to be very challenging.
  6. Mobile operating systems are evolving at a very rapid rate. Every year there are more and more features being added. This creates more work for the cross-platform SDK vendors who need to bring out new versions of their SDK within a short time after the release of a new operating system version. Sometimes, it also requires a lot of work on the developer’s part to upgrade an app to newer versions of the cross-platform SDK.

To conclude this in one line, even though native app development offers 100% platform compatibility and smooth performance, for B2B solutions and for business process automation projects, native cross-platform or HTML5 hybrid application development techniques can offer good enough performance in a more cost effective manner.

About the Author

Ritesh Patil is the co-founder of Mobisoft Infotech that helps startups and enterprises in mobile technology. He loves technology, especially mobile technology. He’s an avid blogger and writes on mobile application. He works in a leading android development company with skilled android app developers that has developed innovative mobile applications across various fields such as Finance, Insurance, Health, Entertainment, Productivity, Social Causes, Education, Taxi development and much more and has bagged numerous awards for the same.