The Easiest Path to Windows 8: HTML + CSS + JavaScript
Sometimes it happens that a new version of an operating system introduces a new type of application completely incompatible with older versions of the same system. The last time it happened I think it was with Windows 95. More than 15 years later, Windows 8 comes with support for a completely new segment of applications named Windows Store apps. These applications can only run on Windows 8 and they have a brand new look and feel compared to other and older Windows applications. In addition, Windows Store apps follow a different pattern as far as publishing and sales are concerned. Windows Store apps, in fact, can be distributed for free or for sale through a central marketplace known as the Windows Store. This channel is a valid alternative for widespread distribution to classic direct user-led install of applications. Windows 8 specific applications are not limited to personal computers but can also run on a variety of compliant devices, most notably Microsoft Surface devices. In summary, developers can now create two types of Windows applications: classic Window apps that also run on multiple and older Windows platforms (i.e., Windows 7, Windows Vista) and Windows 8 specific apps that only run on machines and devices equipped with Windows 8. Classic Windows applications can only be distributed manually or via custom setup programs; Windows 8 apps can be distributed via the public Windows Store or under the control of the system administrator. Windows 8 apps are based on a different API and a different runtime system-the WinRT framework. The new API is offered to developers in a variety of languages. In this article, you’ll see how to build Windows 8 applications using JavaScript for the logic, and a combination of HTML and CSS for the user interface. Formerly known as Metro style applications, Windows 8 applications are now officially referred to as Windows Store apps. Under the Hood of Windows Store Apps As mentioned, you can write Windows Store apps in different ways. You can use HTML and JavaScript, as discussed in this article. You can also write applications using C#, Visual Basic or C++ as the programming language, and XAML to express the user interface. All approaches deliver nearly the same programming power. This means that you can build the same application behavior regardless of the language and markup that you choose. It goes without saying that JavaScript is fairly different from C++ and a good deal of difference also exists between C# and C++. While the programming power is nearly the same in all cases, the actual programming experience may be different as features and capabilities of the languages are not the same. I’ll return to this point later in the article, but I’d like to mention it here: asynchronous programming is much easier to code in C# than in JavaScript, but it can be done equally in both languages. Windows Store applications rely on a new infrastructure; this is what makes them incompatible with operating systems older than Windows 8. In Figure 1 you can see the Windows 8 runtime stack at a glance. Two parallel stacks live side by side and support two different application development models-one centered on JavaScript and HTML and one on XAML and C# (and other .NET languages).  Figure 1: The Windows 8 runtime stack. Darker blocks refer to areas of the runtime covered in this article.The WinRT API supplies several classes of functionality. In particular, you’ll find media, networking, storage and presentation functions. Any application interaction with the operating system is actually mediated by the WinJS library. Subsequently, any Windows Store application written with JavaScript must include the WinJS library and use its API to access available functions. Your Windows Store application results from the combination of JavaScript files and HTML pages. Before running, the JavaScript code is compiled by the Windows 8 JavaScript engine and access to the WinRT subsystem occurs dynamically as the user interacts with the application. |