Click here to Skip to main content
12,698,899 members (22,162 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

16.8K views
5 bookmarked
Posted

What to Choose between XAML and JavaScript for Windows Store Apps Development

, 28 Nov 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
What to choose between XAML and JavaScript for Windows Store Apps Development

If you are a novice in Windows store app development, then it is obvious to get stuck on the question which platform is best for metro apps development or which one is suitable for you to code and build metro apps? As developers new to Windows 8, we’re having a hard time choosing between C#/XAML and JS/HTML for our upcoming app development.

I still remember the day when I started to learn coding in .NET Framework 2.0 and an overarching question was echoes about new application development in C# or VB.NET ? Now from .NET Framework 4.5, developers have a new rivalry to choose: XAML/C# or HTML5/JavaScript? and it's quite obvious that making this new choice has farther reaching implications than the prior C# or VB.NET decision.

The Landscape of Modern App Languages

You can use many languages to create Windows 8 apps and to interact with WinRT. Here are the available language sets for Windows Store app development:

Language Familiarity

To develop Windows Store apps, language will probably be the biggest factor in decision. If you have no experience with web development, then C#/XAML will be easier for you. XAML developers will see a lot of familiarity to Silverlight or WPF in Windows Store development, but there are plenty of differences as well.
In the same way, if you are good in web development, and would love to code using JavaScript, and are just more comfortable on the client-side of things, then HTML5/JavaScript is for you. An HTML developer will be familiar with how the markup looks but will need to learn the WinJS specific classes and data attributes.

Concept of HTML and JavaScript in Windows Store apps

HTML5 and JavaScript are open web standards and that’s why they work in nearly every browser in the same way. That is the reason why you can develop HTML5 applications for Mac OS and port it without writing numerous lines of coding to Windows. There are a lot of JavaScript functions, that are only supported by IE10 (Internet Explorer 10) (in fact, nearly every function you can find in the WinJS-File).

If you want to port Win 8 Application to any other Operation System, you have to review your code and need to write extra code in order to target the desired platform.

Concept of XAML and C# in Windows Store apps

XAML( Extensible Application Markup Language) is an XML-based markup language developed by Microsoft. XAML is the language behind the visual presentation of an application that you develop in Microsoft Expression Blend, just as HTML is the language behind the visual presentation of a Web page. Creating an application in Expression Blend means writing XAML code, either by hand or visually by working in the Design view of Expression Blend. XAML is .NET and so it is fixed to this Framework. You cannot easily port a XAML Application to another platform. Therefore, XAML and C# is very good implemented into Visual Studio (Intellisense,Blend and Design-Views) and has some nice features like LINQ(Language-Integrated Query), DataBinding, Resolution Independence, Debugging. whereas C# is nothing more than a language which is used to write code behind file to manipulate and make UI(User Interface) in actions.

When and Why I should choose HTML/JavaScript or XAML/C# for Windows Store apps?

Personal Experience and your Interest

I am repeating again, if you have no experience with web development, but you know how to code using C#, then C#/XAML will be easier for you. XAML developers from both the Windows Presentation Foundation (WPF) and Silverlight camps continue to write the same declarative XAML for the UI layout alongside C#, VB.NET. In the same way, if you have interest in web development, and would love to code using JavaScript, and are just more comfortable on the client-side of things, then HTML5/JavaScript is for you. An HTML developer will be familiar with how the markup looks, but will need to learn the WinJS specific classes and data attributes.

Tooling Support

Blend for XAML offers a lot of the standard XAML editing features XAML developers/designers have come to expect but doesn’t offer much beyond that since WPF designers and developers have enjoyed Expression Blend. Expression Blend provides a visual and designer interface to accomplish complex actions and interactions in XAML UIs.

Note: Blend for Visual Studio 2012/2013 provides visual authoring for Windows Store apps, with support for both XAML and HTML.

The XAML functionality is similar to previous versions of Blend, so if you’ve used previous versions, you’ll feel right at home. In addition to rich support for Windows Store app development, Blend for Visual Studio 2012/2013 also supports enhanced compatibility with the XAML Designer in Blend, whereas Blend support for HTML represents a new and innovative kind of authoring environment for HTML. So, if you are new to blend, then it would be a tedious task to work.

For more details and differences: Design Windows Store apps using Blend for Microsoft Visual Studio 2013.

Third party library support

You can find lots of libraries that are written for C# and JavaScript. Many of these libraries will work just fine with no change necessary. So if your concern is for third party library support, then you don’t need to worry.
Read more: Code libraries, toolkits and other sources of help

If your app target OOP(Object Oriented Programming)

The key part of OOP Inheritance, Polymorphism, Abstraction and Encapsulation, unit testing architectural reuse, and pervasive design patters are completely supported by OOPL like C++, C#, and VB.NET. XAML/C# is the best option to make apps that target OOP in comparison to HTML/JavaScript. C#/VB.NET has everything and a full set of features including symbolic refactoring, complex metrics and superior code analysis.

Resolution Independence

Your app can have resolution Independence. Either you choose to write code in C#/XAML or HTML/JavaScript, but the prime factor is that HTML does not get to resolution independence as quickly as XAML (or as transparently) does, but you can certainly accomplish it in HTML.

XAML is cool because of XAML’s resolution independency, it looks completely the same – just clearer, sharper. Size values in XAML are not pixels, they are device-independent units.

Interoperability

JavaScript lovers always claim that JavaScript is better in terms of interoperability because it can cross communicating with other applications. Just because of Dynamic features, JSON and being light in nature, we shouldn’t say HTML/JavaScript is better than XAML/C#.

C# can speak in the same way! In other words, C# can do all of that too. :) We shouldn’t forget C# has DLR(dynamic language runtime). Any of the C# objects are one small serialization step away from becoming the same JSON object that a JavaScript app uses and likewise in the other direction. Just because C# application is fat and little bit complex with business logic, it does not mean it can’t communicate lightly with the outside world.

Platform Target

If you are making apps that need to be targeted only for Windows 8, then C#/XAML is the best option but if you are looking to make an app that is targeted to run on more than one platform, then HTML5/JavaScript option would be worth.
Read for more details: Building Cross-Platform Apps with HTML5

Functionality of Bind to Anything

Data Binding is one of the greatest and most powerful features of XAML (WPF, Silverlight, Windows Phone or Windows 8) compared to other traditional web and Windows app technology in .NET. The power of XAML really starts at its native ability to data bind. Nothing data binds like XAML – one way, two way, one time, and to almost any property. Not only is it built-in, not only is it powerful, not only is it fast, but it’s simple.
For JavaScript lovers – They can use WinJS Framework and KnockoutJS both support ObservableLists that allow you to do the same, but the performance is not the best.
Read more: 2 Great JavaScript Data-Binding Libraries [ For HTML/JavaScript ]

Raw Graphics

If raw graphics performance is a concern for your app, then going C++/DirectX ends up being your only real choice.

Still have doubts? If yes, read below the feedback from www.wirestone.com Labs
We’ve been developing highly interactive graphical applications using markup languages like XAML and HTML for some time. But when there’s a demand for high performance, we turn to DirectX. And to test the limits, we developed a proof of concept shown in this video under Windows 8 as a DirectX app.
Read more - Gain maximum graphics performance with DirectX.

Which is good between C#/XAML and C++/XAML ?

First, let's be clear that the XAML rendering engine is pure C++ / COM whether you’re using C++ or C#. Since .NET and C++ use the same WinRT framework, there probably won’t be too much difference in interacting with the XAML/WinRT platform.

From an XAML perspective, it becomes a language choice. The XAML UI stack is the same regardless of which code language you choose here. Depending on your goal of the app, it might make more sense to use C++ or C#.
The great advantage of using C++/XAML is if speed is important to your project. The advantage of C#/XAML is that it is much more easier to code.

What Should I do ?

I should first ask: “What are my needs?”

PlatformTarget – Multi
Choice – HTML5/JS

If your needs are to target the mobile world, and to get your mobile application to as many people as possible, I’d suggest going HTML/JavaScript instead of XAML/C#/VB.Net. More of your core logic will translate across the platforms when you start looking at Android or WebOS or Blackberry development using tools like phoneGap, etc.

Target – Windows Ecosystem
Choice – XAML/.NET

If your app is only targeting windows platform, I would suggest XAML. XAML gives you full access to what Microsoft has to offer. HTML5 has some limitations that XAML does not have. XAML does have a learning curve, but it's worth it, if your target is Windows.

Target – High Performance
Choice – Native (XAML/WinRT)

If your app target 2d, 3d graphics and need great performance. I would suggest you should go native. Which in this case is XAML + C++/Cx (though you may be able to get away with mixture .NET managed code depending on need). Even if you were to look at porting your app to other devices in the future, you’d probably go native on each of those platforms, for performance.

Some Feedback to give more ideas to make better decision

Conclusion

For me, I love both languages (C#/XAML and HTML/JavaScript) equally and here I am not underestimating the power of JavaScript and HTML5, but when the matter comes to choose a platform to make a Windows Store app, personally I would definitely choose C#/XAML because of my skills, I am more familiar than JavaScript. :) If you have the same question regarding opting for a language, then don’t worry. Many have the same query. You are in an interesting situation, where your mind is in a blank slate. Your choice may be different. If it is, make sure that you have valid reasons for your choice. Not all choices are equal. You can choose platform as per your skills familiarity and based on app requirement.

Filed under: .Net, C#, CodeProject, Windows 8
Tagged: HTML5, javascript, Windows 8, Windows 8 Metro

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ravi Ranjan Kr
Software Developer
India India
Microsoft Student Partner | CS Student | MCTS | CP MVP | Crazy Learner | Dreamer

An Indian, who loves his country, believes in freedom, He is an enthusiast Techie and crazy learner. He is passionate about Technologies and social media. He holds bachelor degree of CS in Information Technology and now pursuing Master degree in Computer Application.

He always excited and keen Interested in learning and sharing knowledge. He loves to write blog, learn new things, listen music, taking arts and Playing Games..

He keep himself on the desk of his imagination, hanging around with some inceptions.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionInteresting Article, thanks for posting Pin
Dave Kerr28-Nov-13 22:20
mvpDave Kerr28-Nov-13 22:20 
AnswerRe: Interesting Article, thanks for posting Pin
RaviRanjankr29-Nov-13 20:49
professionalRaviRanjankr29-Nov-13 20:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170118.1 | Last Updated 29 Nov 2013
Article Copyright 2013 by Ravi Ranjan Kr
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid