Skip to main content

Metro Apps on Window 8 - What to use? XAML/HTML? JavaScript, C#, C++?

Windows 8 is almost released, a lot of companies started already to develop application for Windows 8 – Metro Applications.
In a Metro Application we have three technologies to render the UI:
  • JavaScript
  • C#
  • C++
And yes, VB, but is on the same level with C#. With this three languages we can use HTML and CSS, DirectX and XAML but not in any combination.
On the first level we have DirectX for the UI. This can be used only from C++. Of course we can define libraries that can be consumed by C# and JavaScript code.
The second way to create UI is using XAML. We can use XAML in C# (VB) and C++. The big difference in comparison with DirectX is that we cannot use an XAML controller in a JavaScript application. In this moment we don’t have a JavaScript component that permits us to display a XAML (and I don’t think that we will see soon).
On the same level as XAML we have HTML5 and CSS. This can use only JavaScript and don’t permit to create WinMD libraries that can be consumed by C# and C++. We don’t have any kind of support of JavaScript in C++/C#.
What nice things we can do? We can have a DirectX library and over it an XAML as overlay. This is a very powerful for game industry that can use XAML for data binding and interface and in the same time to use DirectX for the game UI.
After 4 months working with JavaScript and C# on Metro Application on Windows 8 I can say:
  • XAML can bind to everything (we have in JavaScript and HTML – but the performance is not the best)
  • Dependency property – we can bind 10.000 properties to the UI without any problem (I saw a HTML/JS implementation and it took over 20 seconds to bind and render all the data)
  • OOP – is nice to work with a functional programming language (but I miss OOP)
  • MVVM – in this moment this pattern is well defined for XAML solutions and a lot of MVVM frameworks already support it
  • Debugging – full debugging support as intellisense, code analysis and symbolic refactoring
  • Vectors – can be done in HTML5, but I prefer to work with them from XAML
  • Resolution independence – don’t need to say more
In conclusion I don’t want to say that XAML is better than HTML5. No, this is not the idea of the blog post. But be aware when you want to use XAML or HTML about what limitation can bring with them. For example in XAML/C# we cannot load dynamically WinMD libraries. But we can load and execute JavaScript at runtime.

Comments

  1. Interesting - anyway, about "What to use?" - the answer is simple - what your team has more experience in. Very, very few developers are equally experienced in XAML and HTML5/JScript, or in both C# and C++.
    For a programmer that used C++ and MFC for the last 10 years, getting up to speed with C# and XAML in 5 days is not an option.

    ReplyDelete
    Replies
    1. I would not say to use only the language that you know. A technology can be learned, is not so hard. We need to realize that there is some limitation when we use one HTML/JS or XAML/C# or DirectX/C++. We need to take this account before starting the project and see also what language can make us happy.

      Delete
    2. Of course - I meant to say - what technology to use when a team of let's say 10 people is asked by a client to start to implement an application _now_, and have it released in production in 2 months - in such cases, which are the norm in most companies, the developers are happy if they have 4 days before the project starts to get up to speed with some new technology.

      Sure, when somebody has plenty of time before a project starts (months), it will also have time to switch platforms, learn something new etc..

      Delete
    3. To give you a clearer example:
      You cannot do dynamic loading of code (assembly) in XAML/C# metro application. But using JavaScript and HTML5 this is possible. In the same time it is easier to use C++ and DirectX in a XAML application than in HTML5 and JavaScript. And you don’t want to have 1000 bindings in a HTML/JavaScript application; you will need more than 2 seconds to load the page.
      What is the scope of your application? What you will do in it? What we need to in our application? This is the most important question. Quality software cannot be developed only because we know a technology. We need to know a lot of technologies and know what is the most suitable for our application. You don’t want in version 2 or 3 to have a blocker because you didn’t use a suitable technology.

      Delete
    4. Indeed, this is the best approach - when possible, evaluate the most appropriate technology and use that.
      If you have developers skilled in multiple technologies, or time to train them in advance, it's best.

      Otherwise, when a company has only 20 developers, and 10 or them have just finished working 4 years for a big project in WPF, then the company finds another project that must be developed for Win8/Metro, and the company has won the bid against other companies because they promised to finish it in 3 months, what do you do? :)
      Turn down the client because maybe JS/HTML5 is more appropriate in some cases, or use the technology that the developers know?

      About: "You cannot do dynamic loading of code (assembly) in XAML/C# metro application" if it's true, this is a very strange limitation, because it was possible until now. Anyway, the cases when this is needed, are rare in normal applications.

      Delete
    5. “Anyway, the cases when this is needed, are rare in normal applications.”
      In a LoB application dynamic loading is a have to in many cases. They don’t allow this for security reason and I try to understand them (only try). Maybe a Prism for Metro Application will be launched soon and all our problems will be solved

      Delete
    6. Somehow it's logical - since a Metro app is a sandboxed app that must be pre-approved by Microsoft in order to run (usually), and dynamically loading is usually used for plugins/extensions that are not installed in advance, such a restricted application can't use plugins that are not yet verified by Microsoft.
      Maybe in future they will develop a MEF version for Metro that allows this (http://mef.codeplex.com/wikipage?title=MetroChanges).

      Delete
    7. I'm waiting this version of MEF for Metro Apps and also I hope that they will support HTML and JS.

      Delete
  2. Also you'll have to take in consideration what type of application you're developing, what features need to have and the complexity of the app. Based on these things you'll decide the right solution to use.
    This is the path of decision making in my company.

    ReplyDelete

Post a Comment

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(

Azure AD and AWS Cognito side-by-side

In the last few weeks, I was involved in multiple opportunities on Microsoft Azure and Amazon, where we had to analyse AWS Cognito, Azure AD and other solutions that are available on the market. I decided to consolidate in one post all features and differences that I identified for both of them that we should need to take into account. Take into account that Azure AD is an identity and access management services well integrated with Microsoft stack. In comparison, AWS Cognito is just a user sign-up, sign-in and access control and nothing more. The focus is not on the main features, is more on small things that can make a difference when you want to decide where we want to store and manage our users.  This information might be useful in the future when we need to decide where we want to keep and manage our users.  Feature Azure AD (B2C, B2C) AWS Cognito Access token lifetime Default 1h – the value is configurable 1h – cannot be modified

What to do when you hit the throughput limits of Azure Storage (Blobs)

In this post we will talk about how we can detect when we hit a throughput limit of Azure Storage and what we can do in that moment. Context If we take a look on Scalability Targets of Azure Storage ( https://azure.microsoft.com/en-us/documentation/articles/storage-scalability-targets/ ) we will observe that the limits are prety high. But, based on our business logic we can end up at this limits. If you create a system that is hitted by a high number of device, you can hit easily the total number of requests rate that can be done on a Storage Account. This limits on Azure is 20.000 IOPS (entities or messages per second) where (and this is very important) the size of the request is 1KB. Normally, if you make a load tests where 20.000 clients will hit different blobs storages from the same Azure Storage Account, this limits can be reached. How we can detect this problem? From client, we can detect that this limits was reached based on the HTTP error code that is returned by HTTP