Monday 30 April 2012

Windows 8 HTML5 Apps–This Ain’t Your Grandpa’s JavaScript

Monday 30 April 2012 01:43

In the past few weeks, I’ve been playing with Windows 8 Consumer Preview. I’d like to build some new apps for it, and have been struggling with which language flavour to go with: HTML5/JavaScript or XAML/C#.

On the one hand, I’ve been working with WPF in the past couple of years, so XAML seems like a natural transition. Although I’ve encountered a few of the WPF pain points mentioned here, I’ve also heard that Windows 8 XAML was a complete overhaul of the old WPF. So it may not be too bad.

One the other hand, I read Brent Schooley’s blog article, Choosing XAML or HTML5 for Windows Developer Preview apps, which favours HTML5 due to better UI designer support in Blend. Skillset reusability is also an obvious plus: I can now use the same programming language to build desktop apps or web apps, even if a paradigm shift is be requried. My two first reservations are:

  1. integration with Windows core (via system DLL calls, etc…), and
  2. source code protection.

OS Integration
Let’s say I go with JavaScript. What then? Wouldn’t JavaScript be limited to only making HTTP requests to the cloud and not able to reach down to the Windows core to do some heavy duty native operating system integration when it needs to? This is a Windows app, afterall.

My mind was put to rest when I read Dave Isbitski’s post, Accessing the Camera in a Windows 8 Metro Style App using HTML and JavaScript. Really? HTML and JavaScript can do that? Enters WinJS. This ain’t your grandpa’s JavaScript. It can instantiate and interact with native objects as easily as C# would. This reminds me of something else. Remember Internet Explorer 4 and Active Desktop? Active Desktop was a flop because it was an open invitation for web attackers to exploit the operating system. I think after 15 years, though, HTML technologies has finally caught up with Microsoft’s vision <grin> to bring web technologies to the Windows desktop. Hey, if you can write a full blown server-side app nowadays with JavaScript (via Node.js), why shouldn’t you be able to do the same for desktop apps.

Source Code Protection
Call me suspicious, but I’m still not comfortable about exposing my all of source code to customers and, potentially, competitors. In my very humble opinion, open source software may be good for the human race in the long run, but if you’re a small ISV trying to make something for yourself in this vast industry, open sourcing could be deadly. So, how do you get around this exposure?  One obvious option would be put your sensitive algorithms in your service layer, hosted on a private cloud somewhere and away from prying eyes. But does that means HTML5/JavaScript is only suitable for cloud based Metro Style apps? Hard to believe that it is. Perhaps you can have hybrid JavaScript/.NET apps, with HTML5/JavaScript code being responsible for presentation logic and pure .NET assemblies being responsible for business logic. It seems like a reasonable way to go.

So where does this leave XAML?

I read a recent discussion thread on Channel 9’s Coffeehouse Forum in which the general consensus seemed to be an abhorence for HTML5 in favour of XAML. WPF guru, Josh Smith has also blogged a short and damning post against WinRT and consequently, I would assume, of HTML5/JavaScript for the desktop. I myself have not worked with WPF long enough to be religiously bound to it. So, I’m going to give HTML5 a fighting chance. I’m going to continue playing with this thing for another couple of months and see whether or not I’ll become abhored by it, and will log my findings on this blog whenever possible.


Toggle Footer