Welcome!

Java Authors: Hovhannes Avoyan, Carmen Gonzalez, Imran Akbar, Sharon Barkai, Adrian Bridgwater

Blog Feed Post

Guest Post from Mobility Expert Peter Rogers - JavaScript Cross-compilation Mobile App Development

If you are a mobile geek or are dreaming of being one, then here is your opportunity to indulge with Cognizant's mobility expert, Peter Rogers ([email protected]).

Recently Famo.us made a big announcement around offering their own PhoneGap alternative using a WebView that could use Chrome instead of the Stock Android Browser. Android 4.4 (KitKat) actually offers this out of the box now but it is actually Chrome 30 which isn’t quite up to the same feature set of Chrome 33. That means no WebGL or WebRTC, which is a real loss. There are also no plans to roll ChromeView to older versions of Android and the open source project with this intention has considerable issues at this stage, which is a shame.

Famo.us plan therefore to bundle Blink (Chrome 33) with Apps in order to offer WebGL and other improvements to Wrapped Web Apps. The downside is of course the size of Blink which is somewhere between 10M and 30M depending on which tech forum you follow. Famo.us plan to get round this by offering a one-off download of a shared library, of course this would need to be updated when the next version of Chrome is released. They have a neat demo showing Chrome 33 features including WebGL running through a WebView on Android KitKat.

There is of course another option and that is actually converting HTML 5 and JavaScript into native code. I was very excited to see that CocoonJS are moving from Games into Apps. They offer a Cloud based compilation solution for converting HTML 5 content into a Native App for a dedicated mobile operating system. The conversion of HTML 5 Canvas to OpenGL (ES) native code has been a technique used in the game industry for a while now and it is often referred to as Accelerated Canvas. AppMobi were one of the pioneers of this technology and recently they sold all their client-side software to Intel and it became part of their XDK – which also offers an alternative to PhoneGap - although it is more of a superset as opposed to an alternative. The difference between converting an HTML 5 Canvas and a whole HTML 5 Web App is quite large though and it starts to bring it into the realms of Apps as opposed to pure Games, which is an exciting prospect. Indeed a lot of hopes rest with CocoonJS Beta for how they can move away from a pure Accelerated Canvas.

CoffeeScript was a marmite solution where some people loved it and others hated it. The basic premise was sound though in that you could write in a higher level more powerful language and then compile it into a highly optimised JavaScript output. Emscripten is a type of compiler which is termed a source-to-source compiler or a transcompiler. You compile from C / C++ into LLVM bitcode which is translated into a highly optimised JavaScript, furthermore it can take advantage of asm.js. An asm.js program will behave identically whether it is run in an existing JavaScript engine or an ahead-of-time (AOT) compiling engine that recognizes and optimizes asm.js. It is early days but preliminary benchmarks of C programs compiled to asm.js are usually within a factor of 2 slowdown over native compilation with clang.

Hyperloop is one of the latest initiatives and it offers the ability to cross-compile JavaScript into native code. It is an open source project and the first implementation of this is being used by Appcelerator in order to power their portable native solution called Titanium. This moves it from a JavaScript VM solution into a cross-compiler solution and the benefits will be massive in terms of performance. I would love to see Hyperloop move to the cloud and have 100% native API coverage for each mobile platform but it is obviously early days. Hyperloop is currently available as developer previews for both iOS and Windows.

When I look at CocoonJS, Hyperloop and Intel XDK then I see a real future for developers who want to write in JavaScript but who want native level performance. JavaScript isn’t a great language but it is the most accessible language and this has given rise to a vast number of libraries in both the game and Apps space. Just the other day I wrote Tetris in HTML 5 using the Quintus API and it only took me the evening. There is no other language that comes close in terms of supporting libraries and frameworks. If somebody can build a Cloud based system that works with any JavaScript framework or library, game or application, and spits out native code for all the main systems then I would suggest that would revolutionise the mobile universe.  

*************************************************************
Kevin Benedict
Senior Analyst, Digital Transformation Cognizant
View my profile on LinkedIn
Learn about mobile strategies at MobileEnterpriseStrategies.com
Follow me on Twitter @krbenedict
Join the Linkedin Group Strategic Enterprise Mobility

***Full Disclosure: These are my personal opinions. No company is silly enough to claim them. I am a mobility and digital transformation analyst, consultant and writer. I work with and have worked with many of the companies mentioned in my articles.

Read the original blog entry...

More Stories By Kevin Benedict

Kevin Benedict is the Senior Analyst for Digital Transformation at Cognizant, a writer, speaker and SAP Mentor Alumnus. Follow him on Twitter @krbenedict. He is a popular speaker around the world on the topic of digital transformation and enterprise mobility. He maintains a busy schedule researching, writing and speaking at events in North America, Asia and Europe. He has over 25 years of experience working in the enterprise IT solutions industry.