Role of Web Based Technologies In Maximizing Code Sharing In Your Applications
I was recently approached by a colleague of mine with the following question: "What are the available alternatives to reduce the current complexity of developing for multiple channels?". In a nutshell he was looking for ways to maximize the amount of client code shared among iOS, Android and Web channels while still being able to use native mobile features if/when needed. So here is the answer I shared with him which I thought would be beneficial for the wider community (not to mention that we love open sourcing everything here at Microsoft these days including our internal discussion threads).
The first question I typically start with is “What are they trying to build”? For example if they require squeezing out every bit of performance then native will always come on top.
The fact that he threw in the word web presence mixed with requirement for a consolidated code base makes the web sound like a viable option (we still need to address the two aforementioned questions). There are a lot of options with the web today (this could be a good thing or bad thing depending on how you look at it). So lets discuss some options here:
Browser/WebView Based Solutions
SPA based frameworks like Angular 5 (it will probably be Angular 6 by the time you read this post), ReactJS, or even VueJS which seems to be gaining a lot of traction recently are excellent options since the same code base used for the web can be integrated within native platform shells like Cordova and Electron. Cordova includes a plugin system that allows you to tap into native iOS and Android capabilities (along with a mini web server that hosts the files inside the shell) and electron which allows you to tap into native desktop capabilities on Windows/Mac/Linux. The catch here is that you are still using the WebView (fancy word for browser plugin within your native application).
So in summary this option focuses on selecting a SPA framework while augmenting it with great new capabilities of the web like WebAssembly and PWA with the added bonus of integrating all of it within a native shell like Cordova/Ionic and Electron. The main point to remember here is that these solutions allow you to write once and deploy everywhere (web, mobile, and desktop) but will inherit the inherent limitations of the web and will be limited to running inside a browser.
Native Web Based Solutions (aka Compiled Applications)
At the end of the day there are a lot of options available today. There is no good or bad option in my opinion, but rather a viable or non-viable option given the team’s requirements and skillsets. I included a table blow that measures the three different solutions discussed in this post that create a native shell to make it easier for you to decide on the best option for your team.
* Depending on the nature of the application you are building it might not matter to you. But you may feel the sluggishness in some apps