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

How to audit an Azure Cosmos DB

In this post, we will talk about how we can audit an Azure Cosmos DB database. Before jumping into the problem let us define the business requirement: As an Administrator I want to be able to audit all changes that were done to specific collection inside my Azure Cosmos DB. The requirement is simple, but can be a little tricky to implement fully. First of all when you are using Azure Cosmos DB or any other storage solution there are 99% odds that you’ll have more than one system that writes data to it. This means that you have or not have control on the systems that are doing any create/update/delete operations. Solution 1: Diagnostic Logs Cosmos DB allows us activate diagnostics logs and stream the output a storage account for achieving to other systems like Event Hub or Log Analytics. This would allow us to have information related to who, when, what, response code and how the access operation to our Cosmos DB was done. Beside this there is a field that specifies what was th...

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills)

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills) The idea that moving to the cloud reduces the costs is a common misconception. The cloud infrastructure provides flexibility, scalability, and better CAPEX, but it does not guarantee lower costs without proper optimisation and management of the cloud services and infrastructure. Idle and unused resources, overprovisioning, oversize databases, and unnecessary data transfer can increase running costs. The regional pricing mode, multi-cloud complexity, and cost variety add extra complexity to the cost function. Cloud adoption without a cost governance strategy can result in unexpected expenses. Improper usage, combined with a pay-as-you-go model, can result in a nightmare for business stakeholders who cannot track and manage the monthly costs. Cloud-native services such as AI services, managed databases, and analytics platforms are powerful, provide out-of-the-shelve capabilities, and increase business agility and innovation. H...