Saturday, September 17, 2011

Welcome to Zombieland, the Metro Style Land of WinRT and the Undead

Silverlight is dead! WPF is dead! .NET is dead! Hey, they didn't talk about SharePoint or SQL Server at the BUILD conference, those must be dead too. Welcome our new Metro-id overlords!
We read such FUD everywhere these days. Actually none of these technologies are dead for the next several years! And you'll probably agree if you know the facts and not the FUD. So here are my thoughts based only on the facts I got from watching BUILD sessions, reading posts that stick to the facts and not listening to people who obviously didn't inform themselves, but nevertheless spread FUD around.

What happened
Microsoft announced the new version of Windows at the BUILD conference and the new Windows 8 runtime called WinRT, which is used to develop Metro style Apps. Metro style Apps are primarily focused on consumers, designed touch first and therefore perfect for modern multi-touch devices like tablets.
The good ol' desktop is still there and the usual Windows applications are now called Desktop Apps.
There's a lot confusion out there at the moment and many think only Metro style Apps are the future. Actually both models can exist side-by-side and I'm sure the mainly used UI will be the classic desktop for the usual business client. Metro is for tablets, maybe later for the phone. Desktop Apps will still work better for the classic business PC scenario in an office.
After trying Windows 8 I don't see myself using Metro style Apps a lot on my PC when I work at the desk. However, I will love to use it when I'm hanging out on my couch with a tablet. The good news is, both models are supported by Windows 8 and therefore can run on one device, including ARM hardware. Awesome!

WinRT




















First and foremost, .NET plays a significant role in both development models and is not only used for Desktop Apps. I guess the FUD comes from the architectural picture above, where .NET and Silverlight are only represented by a small box in the lower right corner. Of course Microsoft wants to push the new Metro style Apps, the WinRT model and wants to get web developers into the boat, so they adjusted the graphic and marketing message accordingly.
WinRT is actually a new native COM library, plus some extra infrastructure. Therefore an app developer has not to deal with the COM stuff directly, instead you get a thin / fast projection layer (binding) for each of the supported programming languages. This projection layer is automatically built using WinMD metadata and provides projections for JavaScript, .NET (C# / VB) or C / C++. The UI can be designed with XAML or HTML / CSS in case of JavaScript.
The rendering is completely done using DirectX 11.1 (Direct2D) which results in great performance. In Windows 8 the rendering job is finally fully executed by the right processor. This architecture makes it also possible to implement the complete UI just with DirectX, which will usually be done by games. At the moment it's not possible in the Windows 8 Developer Preview to mix a XAML app with DirectX, which doesn't make much sense since the XAML rendering is done by DirectX. Fortunately all hints that it'll be possible in a later version of Windows 8, maybe in the beta.

The below picture by Doug Seven is a way more accurate picture of the Windows 8 platform architecture.



There are a few good, unbiased posts about WinRT out there, which stick to the facts:
WinRT: An Object Orientated Replacement for Win32
WinRT, the C++ Component Extensions
WinRT demystified 
A bad picture is worth a thousand long discussions.
WinRT reference with all namespaces at the unbiased MSDN, where JaveScript is just another language one can use for Metro style Apps.

WinRT and .NET
From what I have seen so far, coding Metro style Apps using C# / .NET seems pretty straightforward if you've done Silverlight, WPF or esp. Windows Phone development before. The BCL used by .NET WinRT is not the full Desktop version of .NET 4.5, it's a reduced set similar to the Silverlight types.
The design of the native WinRT COM library was heavily influenced by .NET. You see it everywhere. Type names, Properties, Events... Even WinMD is the .NET assembly metadata format.
WinRT types map to .NET types and copying of data structures at the boundaries is avoided by the projection layer to get the best performance. Only two types need to be converted using built-in extension methods. The System.IO.Stream can't be mapped to the WinRT stream, so there's an extension method. A Byte[] to WinRT IBuffer conversion is the other extension method.
You can even write your own, custom WinRT components in C# without decorating the classes with ugly COM attributes. Those components are then automatically exposed to the other languages using the generic WinMD metadata. So you can write a component in C++ or in C# and use it from a JavaScript WinRT project. Pretty cool concept if you ask me.
Many WinRT classes look like their origin is .NET / Silverlight and the WinRT WriteableBitmap is also very similar to Silverlight's implementation. So expect a WinRT version of my open source WriteableBitmapEx library in a few weeks when I'm done with the Mango updates for all my Windows Phone apps. After that I will probably port / rewrite some of my WP7 apps for WinRT.

The lifecycle of a WinRT app should  be quite familiar for a WP7 developer, since it's similar to the WP 7.5 Mango Fast App Switching. The lifecycle states are: Running > Suspended in RAM > Terminated. Apps get an event for suspending, not for terminate, so the state has to be saved during suspending. Of course an app should only be resurrected from the tombstone state if the app was launched, not when resumed. Apps get 5s for suspending and need to launch within 15s. Unfortunately we don't know the reference machine where those values are measured. Probably the low end configuration.
By the way, the Windows Store will be the better version of the WP7 Marketplace. It will include In-App offers, time limited trials and a very nice dashboard with a lot of analytic capabilities and insights.
In general should a WP7 developer feel most familiar with WinRT. Many concepts made it into WinRT and were improved and actually cleaned up.
My Silverlight MVP friend Morten Nielsen started a blog post series about how to port Silverlight / WPF apps to WinRT.
You should also read this post: WinRT and .NET and watch the ton of great BUILD sessions.

Conclusion
I welcome the new possibilities and great performance we get in Windows 8 with the WinRT. I'm sure Windows 8 will be an awesome tablet OS.
XAML has become a first class citizen and .NET is now installed with Windows 8. Microsoft is also working on a next version of .NET. Version 4.5 of .NET will bring better performance for WPF's ItemsControl for example. Seems not very dead to me. In fact, a Silverlight / WPF / WP7 developer's knowledge of XAML and the Silverlight runtime is more valuable than ever before with WinRT.
Silverlight 5 is still in development and wasn't even released. We don't know if it will be the last version or if Silverlight 6 will see the light of the day. For now I'm quite happy with all the features of Silverlight 5 and we can develop a ton of applications for our customers for the next several years.
One should also not forget how long it will take until Windows 8 is finally out and reached a critical mass. A lot of machines out there still run Windows XP. Windows 7 is way better and I guess the transition to Windows 8 will take even longer. Windows 8 will probably mainly pushed by non-PC multi-touch consumer devices in the near future.
This flowchart by the Telerik guys sums it up pretty nicely.

So get yourself informed and start coding away. Don't give FUD a chance!

14 comments:

  1. Thanks for cleaning up the FUD, Rene. I worry that you swing a bit too far in the opposite direction as you take the SL, WPF, etc. is Dead crowd apart, though.

    Take XNA, for instance. XNA is effectively dead on the Win8 platform. While it will still work in desktop mode, that simply isn't where anyone would want to deploy games. Games should be deployed throught the new Win8 Marketplace, which means running in Metro and not the desktop. XNA can still go on in Windows Phone, of course, but that consumer market will be a fraction of what we hope the Win8 consumer market to be.

    If we take that as a touch point, we can do the same analysis for Silverlight. Silverlight as a cross-platform strategy is in trouble and has been for a while. Browser penetration hasn't achieved what flash penetration accomplished. Neither flash nor silverlight will run on iPads. The case for silverlight on Macs seems rather limited -- great for cases where businesses use both mac and window internally -- but these are niche areas like agencies and media companies. Finally, SL won't run in the Metro version of IE -- though it will in DIE. This means a tablet user of Metro won't be able to run our beautiful silverlight apps on their tablets -- just like iPad users.

    Then on the desktop side, while we can certainly do SL out-of-browser on the desktop, I'm not sure what you gain over doing this in WPF -- whereas WPF has lots of advantages including a fuller XAML syntax, and estensible XAML syntax and access to the full .NET framework rather than a subset. This isn't to say that any company currently working on a Silverlight project should abandon it -- there's no reason to throw away a previous ivestment at this point -- but it does raise questions for the future of SL.

    Like XNA, SL is a first class platform on WP7. I woudn't say that SL is dead on Win8 the way I might say XNA is, but it does seem to be slipping into being a legacy platform.

    The final question is what we can do with WinRT. The presumption currently is that WinRT is for writing smartphone style apps, while "real" apps are going to be written in .NET for the desktop.

    When a possible new version of Office is previewed in the next year (and I can't see Microsoft _not_ offering a metro version of office) we'll find out how viable Microsoft thinks Metro in the enterprise is. And if it is, I think that would mean that all .NET platforms have effectively become legacy.

    Honestly, I think this will be great for developers however things turn out, and even for Silverlight developers.

    At the same time, while I agree that it is too early to declare that silverlight is dead, I would also say it is still too early to declare that it is not. If we start seeing all of our SL leaders hedging their bets and rebranding themselves as WinRT devs rather than sticking with Silverlight, then that would probably be the death nail on the platform.

    ReplyDelete
  2. Thanks for the comment James. Don't get me wrong, I see a big market for Metro business apps. Just think about cash or kiosk systems. But I can't see our customers, who are the usual business office workers, using Metro on a daily basis. At least not in this century. I think the whole "End of PC era" thing is highly overexaggerated.

    ReplyDelete
  3. Silverlight, if I'am right this is the thing that "should" run on any device and provide better experience than simple HTML/CSS.

    Well you see, this is no true and MS don't even provide a bright future for it... outside of allowing to run on desktop using IE.

    It is trivial to understand that .NET is here for at least a few years and that most dev will be done in C# for microsoft developpers.

    Javascript here is just a new possibility (and maybe a little late with Google Dart)

    But Silverlight... Yes this technology has really no future. Of course MS is not stupid. New OS version is backward compatible. Like old WinXP app will run on windows8.

    ReplyDelete
  4. Yep, you absolutely right. WinRT is just another platform that lives within Windows instead of being a separate OS. Here is much better version of the picture than that one that Microsoft presented. http://dougseven.files.wordpress.com/2011/09/win8-new-platform.png Once you realize how things play together on Windows 8, .NET is not the little box in the right corner anymore. You see that .NET 4.5 is very alive and used by WinRT, just not fully exposed. How we write apps for the Desktop stays the same. Everything is still there and comes also as fresh new version (.NET 4.5, Silverlight 5). However, I'm still not sure whether Microsoft is committed to support all three XAML frameworks WPF/Silverlight/Metro equally. If you recall the last years then there was a lot of complaining about the fact that Silverlight got all the love and not WPF. So while Silverlight becomes mature with version 5, we (the Silverlight developer) shouldn't be too jealous if the new baby gets more attention now.

    ReplyDelete
  5. Guys, I don't know if you have been paying attention to the live demos. Somebody demonstrated how he tweaked an existing Silverlight app and ran it as a Metro app. That makes Silverlight still the best investment if you're building line-of-business apps. You can easily run it on all Windows versions, as well as the Mac, and with a bit of tweaking, it can be a Metro app as well. Not to mention the fact that most enterprises won't be upgrading to Windows 8 until far in 2013.

    ReplyDelete
  6. Thanks for the comments and esp. for the hint to the graphic by Doug Seven. I updated the post.

    ReplyDelete
  7. The issue is that many developers equate "no new updates, or minimal new updates" to "dead". Windows Forms has had minimal updates now for some years, and it's still a useful technology for many problems. WPF hasn't really had many huge changes since 3.5 SP1 and it's still very usable for many apps. Silverlight 5 will essentially have the vast majority of features that are needed for both web and fairly rich desktop apps. Each of these platforms is essentially more than most people can handle already, what else do they need? So even if Microsoft said they would be continuing to release updates for every one of these, what would you expect from them? There is a time when a platform matures and doesn't need continuous updates and features. I find WPF and Silverlight basically there today. Sure there are a few smaller things that would be nice, but overall with the latest versions of each (WPF 4.5, and Silverlight 5) I'm pretty happy where they are. So maybe they are "dead" in the respect that we won't be seeing big changes to either in the future, but in my book I'm not sure that's a huge problem either. The problem I see is developers always want to play with the latest and greatest, even if it's not what they really need to support their problem at hand.

    The feeling I get isn’t that these technologies are "dead" as in; no longer useful to solve problems, the real issue here is if you stick with WPF or Silverlight you won't be "on the cutting edge" any more. And developers don't like to admit they aren't playing with the latest toys. Look at how many people use "dead" technologies and are doing quite well in this industry. There are many who have discovered the value and reaped the rewards in delivering solutions, not playing with the latest toys. Be known as someone who can deliver solutions, the end users really don’t care what technology you use as long as you solve a problem they have, and you will always been in demand, even if you do work on less than leading edge technologies. Have a big toolbox, and know when to use each tool. Don’t get caught up in the hype that every new generation of technology brings, select the right tool for the job, not just because it’s the latest shiny tool someone created.

    ReplyDelete
  8. Great article.
    I believe that right now Metro Win8 is the tree hiding the forest. Desktop will still be the "main" platform, especially for business and productivity, so the WPF/SL/Win32 stack will continue to have its raison-d'etre for a long time.

    ReplyDelete
  9. When I use the term XYX is Dead, I usually mean XYX is DEAD TO ME. Nothing REALLY dies in tech.

    Even give my definition though I called some things dead that really aren't. I just mis-understood what WinRT was at the time.

    It is looking like a lot of existing tech is entereing the realm of "dead to me". This is fine with me, I genrally like change.

    -Jeff

    ReplyDelete
  10. It's all about the way Microsoft are handling this mess..

    Who cares about metro UI on desktop?
    Who cares about winRT if it's running only on windows 8?
    Who cares about windows 8?
    maybe 0.01 percent of .net developers

    and yet, everybody .net developers cares about Silverlight but Microsoft doesn't even take the time to really show that they care about it..

    if they really want to show they care they should use the same WinRT win32 layer under .net and Silverlight so that those technologies benefit from the performance optimization that it will provide.. Of course they don't want to since windows 7 applications will be as fast as windows 8 if they use the same win32 layer.

    Yes of course they will keep a little team on silverlight to give little support but they just want to sell windows 8 and make money..

    Microsoft doesn't have any excuse and just saying they will fully support and update silverlight side by side with winRT is simple and easy but they don't even want to commit to this.

    I will learn and code WinRT apps because i will not have a choice.. but i will never trust Microsoft ever again for anything and I will make sure to learn Scala and JavaFx as soon as I can and get away from this Hell.

    ReplyDelete
  11. I totally agree. It'll be close to a year before Windows 8 is on the desktop & tablet and longer for the phone. It will definitely undergo a lot more changes which I'm guess will make WinRT a lot more like Silverlight.

    Even when Win8 is rolling are still left with the same options for cross-browser apps. Silverlight, Flash/Flex, or HTML5/Javascript. I'm not a fan of ActionScript. I'm also tired of writing moz-, webkit- and etc. to make my HTML5 app cross browser just to watch it break with the latest nightly build. So I'm sticking with Silverlight.

    Ken

    ReplyDelete
  12. The destiny of Silverlight/WPF is bonded to the future of the Desktop. So the question is whether the Desktop is doomed or not. If yes, Silverlight would be just collateral damage but it also means we have plenty of time left. The Desktop can't be killed over night.

    ReplyDelete
  13. I wonder how the architect is supposed to pick a platform today? MS rate of change causes business real problem in finding qualified developers for the next tech. Another problem is what I should do with Joe who wrote the Windows Forms application that is being migrated to tech X? Joe does not know this technology and I can't pay 8000 dollars above his salary to learn it? So Joe has to go. But what will Joe do? Joe can't live with the legacy technology for long. Joe has to leave planet earth...Too bad Joe!

    People who took the PL/SQL path or even the COBOL path, have not had to read a single chapter in 10 years and can call themselves senior developers indeed. The same can never be said about MS professionals.

    Developers are not born to learn from 5:00 PM to 3:00 AM every day studying the next great MS invention just for MS to get rich or to survive.

    For example, what does WPF offer for business applications beyond what Windows Forms offered?

    I invite Microsoft to consider its global responsibility to the business and the developers community.

    I can't help post this link so that you may have some smiles...
    http://www.youtube.com/watch?v=RRFiu0xfQzw

    ReplyDelete
  14. And...

    WinRT is dead.

    Good riddance.

    ReplyDelete