Using JavaScript and C++ to build Metro apps
Written by Mike James   
Friday, 30 September 2011

Microsoft has provided a video to explain how to use a combination of JavaScript, for the "easy" stuff, and C++ for the "deep" stuff in the Metro environment.

 

The whole idea of using JavaScript and HTML as a way of creating Metro style apps for Windows 8 is something of a mystery. Why would you go that way. The UI may look as if it is just HTML, but the JavaScript is about as custom as you can get simply because of the range of specific library calls needed to make it work.

Microsoft, however, seem to be backing JavaScript, but there are problems - JavaSript is slow and not suitable for writing things like video processors or advanced 3D graphics. The solution suggested is to use C++ and JavaScript in combination. You use JavaScript to build the UI and do the "easy" stuff and C++ to do the deep technical stuff.

To show you how to mix these two very different languages, there is a video for you to watch.The real meat of the talk starts at around the 7-minute mark. The example simply displays an input image and a processed image - the processing is done using C++.

 

 

 

The basic idea is that you add a WinRT layer that allows communication between the JavaScript and the C++. This WinRT layer takes the form of a WinRT component, which is a sort of COM component but without the hard work. Basically you create a WinRT component and this becomes a runtime extension to the WinRT subsystem. You can then call you WinRT component from any WinRT enabled language. The process is a simple matter of using the Visual Studio template and adding some public methods. If you remember COM development, you will find things strangely familiar - GUIDS and so on. To tell the JavaScript project or any WinRT language to make use of the new component you simply have to add a reference, instantiate the class and make use of its methods.

It is all very easy but it's another reinvention of the wheel. Or is it a return to a simplified wheel? At first there was COM and it was difficult and had lots of problems. Then there was .NET and introspection, which did away with the complexities of COM. Now there is the WinRT component, which is COM reinvented to be as easy to use as a .NET runtime object.

All of this isnt' bad - it's just very strange and, dare I say it, not very logical.

 

metro

 

Related items:

Windows 8 - the Developer's Take

WinRT - the new Windows

Windows 8 - after the dust has settled

Getting started with C# Metro apps

 

To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Twitter or Facebook or sign up for our weekly newsletter.

Banner


Gender Differences In Coding Style
13/11/2024

A novel investigation into the gender gap between men and women regarding coding ability was undertaken by Dr Siân Brooke. Her conclusion? There is a difference in the Python code [ ... ]



Google Intensive AI Course - Free On Kaggle
05/11/2024

Google is offering a 5-Day Gen AI Intensive Course designed to equip data scientists with the knowledge and skills to tackle generative AI projects with confidence. It runs on the Kaggle platform from [ ... ]


More News

Last Updated ( Friday, 30 September 2011 )