Introduction to Windows 8 App Development: HTML5 or XAML?

by Dmitry Kirsanov 30. December 2012 07:19






Because WinRT is part of the core of Windows 8, it is included in all mentioned Windows systems, and so they all support Windows Store applications, formerly known as Metro. Which also means, that you can choose either of 3 available paths to build your apps.


Mobile devices are very limited in resources, so any additional layer, consuming more system resources, may potentially lead to issues with performance. Since in Metro we have only one active application, the location of the bottleneck always depends from the context of your app.

If what you have is a simple calculator application, there is no difference in what platform you would choose for your app – either way it would have enough resources. But if that’s a game app, you may want to think twice.

And speaking about frameworks, there are few things you need to take into consideration.


In normal .NET, your application is shipped in form of MSIL, which is compiled into machine code the first time your application is run. So the first time is always the slowest. The same is with ASP.NET websites – first request after update is the longest. But it’s not so with Windows Phone, when your application is shipped using Windows Store. Since all phones share the same HAL, your application is pre-compiled during the submission process, so your recipients receive machine code.

But .NET framework is loaded nevertheless, since you reference it. Depending from your references, the memory footprint may grow. However, .NET 4.5 is quite limited here, so don’t overestimate the drawbacks. And you mostly use WinRT, which is asynchronous, taking advantage of multiple cores of your mobile device.

So, I would say, that even though CoreCLR is loaded, it doesn’t make a difference for most applications. But if your app is something like Microsoft Office or Angry Birds – you may want to exclude additional layers and ensure you have no interpreted code.

HTML5, CSS3 and JavaScript

In Windows Phone 8 they are, in fact, XAML applications with a single browser control which navigates to the local page. In normal Windows 8 apps - they aren't. JavaScript in that local page is capable of interacting with WinRT through the use of WinJS library, making it more powerful and interactive than ordinary HTML page.

Windows 8 features Internet Explorer’s Trident HTML parsing engine, introduced by Microsoft in MSIE9, as well as Chakra JavaScript engine, from the same MSIE9. Since your HTML5 and JavaScript code is only a few kilobytes long, there should be no problems with parsing your application’s user interface. Besides, HTML5 and JS apps may be using C# or VB.NET code or even components written in C++, so you may have high performance code elements written in native code, while keeping user interface simple and manageable with HTML5 and JavaScript.

Regarding the JavaScript performance, it’s worth mentioning, that modern JavaScript is no less powerful than most other languages. Here is an example – x86 emulator written in JavaScript. It usually works the same way as Java/.NET – i.e. the JS code is pre-compiled when it’s first executed, so all calls after the first one are fast and native. Yes, machine code.

But there are many JavaScript engines out there. Chakra is one of them, but there are others, like V8 in Chrome or SpiderMonkey in Firefox – they are designed by different teams of highly skilled professionals and don’t duplicate each other, so we never can state that JavaScript is parsed exactly this way, and not another.

Trident and Chakra are not the fastest HTML parser and JavaScript engine on Earth, but with the volume of your application and pre-compilation it doesn’t really matter.

However, you can’t create WinRT components using JavaScript. You can only use C#, VB.NET or C/C++ to create WinRT libraries. Which can be easily consumed by your HTML5/JS application. Just beware, that if your libraries are written in .NET, the CoreCLR will be loaded just like when you are having the .NET application, so if you are counting every megabyte of memory, you might want to use C++ instead, at least for custom WinRT components. Such applications are called Hybrid.


C++ Applications

Are, in fact, on the rise. There are good reasons for C++ developers to not trade their skills for C#, as we’ve re-entered the era of slow computing. Obviously, not for a long period of time, as I believe mobile devices will become very powerful in the next 5-6 years, but for that time, if you are C++ developer with Windows Store skills, you are on demand.

Casual games like Angry Birds can be written in HTML5/JS and run even on weak devices like HTC 8S, with only 512Mb of RAM (just note, that this RAM is for both - operating system and applications). But games like 3D shooters? Hardly. That’s where you might want a game engine (one is provided by Microsoft, by the way) and good new and enhanced C++.

Benefits? No Trident, Chakra, CoreCLR are loaded, nearly all bottlenecks can be fixed in your code.

So what would I do?

I would develop 3D games with C++. Period. I would do the rest with the rest.

We often hear, that it’s a matter of style and you could benefit from using the skills you already have in developing Windows Store apps. For example, if you are web developer, you could use HTML5 to develop apps as well. How I see it, though, is that you are not only consuming, but also gaining the skills in the process, so if your LOB (Line-Of-Business) or LOF (Line-Of-Fun) application consists not only of the client application, but also of the website and perhaps web services, then perhaps you’d like to use the same technologies, to improve your skills and avoid switching.

Switching is never good, unless we speak about switching between work and rest. When you are switching between projects and tasks, your performance suffers. That’s why we use Kanban to handle that problem. When you are switching between technologies within a project, it’s not that bad, but similar.

So, if I am developing website in WPF or ASP.NET MVC, I would use XAML for Metro app. If I would use ASP.NET Forms for website, I would use HTML5 for Metro, it’s that easy.

blog comments powered by Disqus

Month List