codefoster | Windows 8: Top 10 Reasons Why I Choose HTML5 Over XAML
Jeremy Foster
@codefoster

Windows 8: Top 10 Reasons Why I Choose HTML5 Over XAML

by Jeremy Foster 23. May 2012 10:26

My colleague and friend Jerry Nixon recently wrote an article on the top 10 reasons why he chooses XAML over HTML5 and it begged me for a reply. Alas, here it is...

Following are the top 10 reasons why I’m in the HTML/CSS/JS space right now.

I should qualify. I completely adore C# and XAML. I geek out on the nuances of the C# language, lambda expressions give me joy, and LINQ is like dreams and starlight. But that’s not where I am right now. I’m moving on but not moving away. I want both bullets in my belt... the sheer power of C# and the wit and fancy of JavaScript.

More qualification. I love JavaScript and at the same time I hate JavaScript. Sometimes it makes me feel like a coding cowboy and other times like I’m in its gallows.

So here we go...

1. Skill Ready

I and about a kazillion other people in the world have gathered a ton of experience on the HCJ stack. Websites became applications as some point, and they became essential in the enterprise. I would guess that the web stack has drastically more developers than any other stack... but that’s a guess.

2. Triptych

HTML, CSS, and JavaScript form what I like to call the happy triptych. Instead of separating code into two roles, HCJ has three. HTML defines the structure, CSS defines the layout and style, and JavaScript defines the logic. This makes things like modifying the layout and style for different view states or devices as simple as swapping out the style sheet.

3. Dynamic

I know that C# has the DLR and I’ve used it in numerous real scenarios, and it’s some awesome functionality added to the language. JavaScript, however, is truly dynamic. If I want to add a property to my app like lastLaunched, I just type app.lastLaunched = “5/1/2012” and voila I have a new property. If I want to add a function called detectLastLaunched, I just type app.detectLastLaunched = function() { ... }. That’s way cool.

4. JSON

JavaScript has JSON. I know that C# can speak JSON too, but not like JavaScript. JavaScript and JSON go together like peas and carrots.

5. Light

JavaScript is light. Super light. The absence of some of C#’s heavy artillery (I’m thinking polymorphism, inheritance, type safety, etc.) leaves it light and agile. The fancier things like inheritance and even asynchronicity are implemented as patterns instead of as language features. This means they’re not baked in so they can be adapted to suit.

I was newing up some sample data in both languages the other day. I had to declare all of my types in C# and then even with object and collection initializers, the code to create the sample data was quite large and repetitive. In JavaScript on the other hand, it’s a matter of declaring a variable and setting it with very terse object initializer syntax... thing of beauty.

Just compare the default Metro style Grid Application in XAML/C# and then in HTML/JS and you’ll see how light JavaScript is.

 

6. Libraries

Again, there are a ton of web stack developers out there and consequently there are a ton of web stack libraries and helpers. Bing something like “javascript face detection” and you’ll find an open source library that’s ready to go. Glance at microjs.com to see what I mean about JavaScript library support.

7. Query Selection

In XAML, it’s easy enough to give a control an ID and then select it in the code. But how do you select all of every third paragraph, the third element in the grid, or something like that. The answer is imperative code. There’s no part of the object model that you can’t access, but with query selectors in CSS and JS, you can use simple strings like “div#myDiv p:nth-child(3n)” to select every third paragraph in the div with the ID of myDiv.

8. CSS

CSS is amazing. With a collection of style rules, I can style, animate, layout, add images, position things, and a ton more. With declarative CSS code I can make the same HTML view look entirely different. Style rules cascade down to the eventual screen element and allow a developer to set a style globally and then override that style locally given the need.

There’s a JS library called LESS that extends CSS’s capabilities and allows me to set style variable and even do variable math. So I can set the base color of my app to red and then create a number of derived colors (darker or lighter for instance). That way, the change of a single color variable will result in a complete change to my app’s color palette.

9. Blend

The nature of HTML/JS apps means that Blend for Visual Studio can dynamically execute the application while you’re designing it. Expression Blend (the XAML designer for classic Windows apps, Silverlight, Windows Phone, etc.) has some robust support for sample data and designer data because it’s not able to drag in the application data at runtime. With Blend, however, when working on a Metro style app using JavaScript, the entire need for sample data goes away. Instead, you look at your real app data... even if you’re pulling it down from the sky (I’m a little tired of the word cloud, so I choose to use the word sky).

10. Name

I live in Seattle. I drink coffee. Fancy coffee. The people that make coffee in this town are insane about their technique, the quality of their bean, and the nanosecond precision of their brew pull. So I’m enjoying JavaScript because it goes so well with the french press of Ecuadorean joe I hold before me.

Sorry, C#. Your name is sharp, but it’s so technical and boring compared to JavaScript.

Nail. Coffin. JavaScript wins hands down! Oh, whatever. It’s all in fun.

Tags: , , , , , ,

C# | CSS | JavaScript | Windows 8 | XAML

Comments (10) -

Jerry Nixon
Jerry Nixon United States
5/23/2012 11:25:43 AM #

I can't breathe in this coffin!

Reply

Jeff Ammons
Jeff Ammons United States
5/23/2012 12:13:06 PM #

For me the key is that web tech will work for most users.

I don't have to worry about whether or not browsers will be accepted by consumers or companies.

I have no way to know if Windows 8 and Metro will be loved or loathed. Either way a web app will be accessible from Windows 8 (in Metro or Desktop IE) AND Mac and iPad, etc. etc. ad infinitum, ad nauseum.

I have more trepidation about Windows 8 than I did about Vista before it launched. Metro will either be a home run or an out. We won't truly know for nearly a year. Scary.

Reply

Herman van der Blom
Herman van der Blom Netherlands
8/3/2012 9:09:03 AM #

I think the whole discussion is meaningless. The HTML5/Javascript/CSS way of programming in Windows8 is just like XAML/C#, different flavor same result. The same like VB and C# is in Visual Studio. Depends what you prefer to program in. Skilled programmers in C will program in C#, skilled programmers in VB6 will program in VB.NET, the result is the same. The same counts for the Windows8 platform, it offers a migration path for Silverlight programmers to Windows8 to program in XAML. The focus of Microsoft will be on HTML5 because it will be the industry standard. I can program both but I focus on where the market is going to, a bit like join the winners. Recently I do a lot with RX. I like that a lot and it can be used in C# as with Javascript. I can program in C/C++/C#/VB etc. for almost 30 years. For people bashing Javascript, dont judge a book by its cover, learn the language, then make up your opinion and you will see its a highly underestimated language. The dynamic nature of it is great Smile

Reply

Ken Lin
Ken Lin Australia
11/4/2012 7:29:41 PM #

One of my colleagues went to the coding fest at TechEd Australia. He heard from some other developers that there are things that C#/XAML can do that HTML5/JS/CSS cannot, and also C#/XAML has better performance.

Is this true? Or is it just people's assumptions based on what they knew of HTML5/JS/CSS?

Reply

Jeremy Foster
Jeremy Foster United States
11/7/2012 9:58:43 AM #

There are things that C#/XAML can do that HTML/JS cannot, but the reverse is also true. The two language stacks are very different and are going to have their own strengths and weaknesses. It's also not generally true that C#/XAML has better performance. There are some things that JavaScript and HTML are faster at.

Reply

Joakim Eriksson
Joakim Eriksson Sweden
2/5/2013 12:27:52 PM #

Hi!

I'm currently looking for limitations/differences for HTML/JS and C#/XAML. Is there anything you can mention that is a drawback or something for any of them? Or hint about what I should dig into?

Best regards

Reply

jeremy
jeremy United States
3/20/2013 4:40:04 PM #

Try this link codefoster.com/Which-Windows-8-Language-Stack-Should-I-Choose

Reply

Martin Parenteau
Martin Parenteau Canada
12/13/2012 2:35:33 PM #

Maybe someone here can help me...

I work as a programmer in a printing company which produces, among other things, student yearbooks. For the past 4 years, we have built a Silverlight application to let our Windows and Mac clients design the pages of their yearbooks. Each page is a XAML document. In the company, our computer graphics designers also use the application to make corrections to the pages. Once a yearbook is completed, they use an internal application (WPF, on Windows) that converts the XAML to PDF files. It works great. Everybody is happy.

In fact, everybody was happy, because now we know that Silverlight is going to die. I really don't know what to do with that situation. Does anyone have a suggestion for me? Here are some characteristics of the application:

-It is very interactive (sometwhat like Adobe InDesign, or like a WPF application)
-It must run on Windows
-It must run on Mac OS X
-It reads and renders XAML
-Ideally, it would run in a Web browser

In short: it would do what Silverlight can do. Any ideas?

Reply

Anis
Anis Jordan
2/5/2013 11:02:05 AM #

@Martin Parenteau

HTML5 Canvas with Javascript can do it except for XAML part (am guessing here). Anyway the output format should be readily converted to PDF or automated by utilizing available libraries.

Reply

jeremy
jeremy United States
3/1/2013 5:07:47 PM #

@Martin, you can consider using Silverlight still. Just because Microsoft is not moving forward with the technology doesn't mean it's not supported. In fact, I believe they announced that it will be supported for 10 years or something like that.
I wouldn't personally use an app UI technology to create a publication. If you were building an online catalog of students then I would use XAML or HTML to do that, but for a yearbook, the layout, theme, and images are so different every year. I would just pull images and student information out of a database and merge them into some good publication software and then add all of the creativity to that, but it sounds like you like the system you have now, so perhaps you should just stay on with Silverlight.

Reply

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Feed Subscribe