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(...

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine: threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration: TeamCity .NET 4.51 EF 6.0.2 VS2013 It see...

Navigating Cloud Strategy after Azure Central US Region Outage

 Looking back, July 19, 2024, was challenging for customers using Microsoft Azure or Windows machines. Two major outages affected customers using CrowdStrike Falcon or Microsoft Azure computation resources in the Central US. These two outages affected many people and put many businesses on pause for a few hours or even days. The overlap of these two issues was a nightmare for travellers. In addition to blue screens in the airport terminals, they could not get additional information from the airport website, airline personnel, or the support line because they were affected by the outage in the Central US region or the CrowdStrike outage.   But what happened in reality? A faulty CrowdStrike update affected Windows computers globally, from airports and healthcare to small businesses, affecting over 8.5m computers. Even if the Falson Sensor software defect was identified and a fix deployed shortly after, the recovery took longer. In parallel with CrowdStrike, Microsoft provi...