Ian 的个人资料Silverlight for Business照片日志列表更多 工具 帮助

日志


11月5日

Silverlight 2 vs. Asp.Net Ajax

When choosing to build a rich web based ui (or ‘RIA’) using Microsoft technologies today you have two approaches: Silverlight 2 or Asp.Net Ajax.  In reality and at this moment in time, you may well choose to do both, but I will blog about that from an implementation point of view later.

So what are the arguments for and against Silverlight and Asp.net Ajax (to be clear I am talking about Microsoft’s implementation of Ajax, including the Control toolkit).  I have attempted to summarise the main differences in the table below – but I would love to hear your opinions on my choices and if I have missed anything.

Personally I think Silverlight is the clear winner where you have control over the deployment environment (and don’t have to worry about “reach”)

 

Silverlight 2

Asp.Net Ajax

Winner

Controls


What sort and range of controls are a available out of the box, from third parties and how extensible are they?
Silverlight has a rich set of controls out of the box, with a whole new set being released recently.

The stated intention is to have 100 controls from Microsoft sometime soon.

The controls are all skinnable with the rich templatable model, some have strong support for DataBinding, both oneway and twoway, and there is already a growing third party market from organisations like Telerik and ComponentOne.
We are still waiting for pure client side controls – in the form of Client Templates.  The control toolkit mostly provides server based extensions which are fine if you are working with asp.net server controls, but useless if you are working purely in the client.

There are other client control frameworks out there (e.g. YUI) and many asp.net server controls that provide ajax ui (e.g. Telerik)

jQuery is worthy of note by itself because of the recent announcement that MS are going to support and ship it.  This adds a feather the into asp.net ajax cap.  Hugely powerful and extensible, easy to learn, and widely used, it’s a great addition, with lots of community support.  And with that MS support many asp.net developers are going to start to adopt this and see how easy it is to work with the DOM in the client.

Silverlight



Even with jQuery, Silverlight controls are compelling, powerful and flexible – they are hard to beat and are only going to get better.  There is more of an investment to learn and template but Silverlight is the clear winner IMHO.

Development Experience


What is the IDE Support like, how is debugging support and the design time experience?
It takes a little to get used to, and there are still some rough edges (read-only design surface in VS for one, caching issues with the Xap file for another, or debug symbols not being hit), but essentially the dev experience for Silverlight is the same as any managed code environment: strong Intellisense, compile errors rather than runtime, great debugging.  Couple that with Blend for UI design and the Xaml/separation split and it looks like a strong contender. 

Hopefully Blend can have Team System/VSS support sometime soon ;-) but even without that the developer/designer experience is much improved.
Microsoft have made some great improvements in VS2008 SP1 for javascript support, but it is hard to do and still not complete.  This results in developers not being able to rely on it as a way of learning an api or validating what they are typing.  Still this will only get better, and we are seeing great Intellisense support for jQuery now.

Client side debugging too has been greatly improved in VS 2008, and IE8 improves it further.

However most server-side asp.net developers are going to feel much happier in the managed code environment of Silverlight.

Silverlight

Nothing beats the managed code environment for me, and when the IDE has all the crinks ironed out, it will be even better.  There is a simple elegance to working with jQuery though ;-)

Reach

How many and what type of clients can use it

Silverlight has an albatross around it’s neck, and that is the “player” installation.  It is in the same place as Flash was many years ago, and the statement from MS that “1 in 4 people have access to a computer that has Silverlight installed” is rather obscure (my mum has access to my laptop at my house, but she doesn’t use it and she doesn’t have Silverlight installed on her machine).

Moreover Microsoft has made the strange (IMHO) decision to deliver it as an EXE download rather than using the ActiveX install method (the yellow bar that appears in IE).  I have seen more than one user interpret this as a virus attack(!)

Customising the installation experience is easy though, and it is critical that developers provide context to the reason for their users to install Silverlight to mitigate possible misunderstandings.

It will take time too for corporate networks to roll out builds that include Silverlight.

Windows Update is delivering Silverlight but only as an optional install.

Still it is not all bad news – this will change over time and in a year or two Silverlight will be everywhere (IMHO) and the auto-update will ensure that it is kept up to date.

Silverlight also has good accessibility support through UI Automation features.
Ajax is supported in all modern browsers, so there is no problem here in terms of reach, and accessibility support is growing.

Asp.Net Ajax

Silverlight will get better, but Ajax will always be the winner here.

Unique Features

What features stand out?

  • DataBinding

Powerful and productive – RAD but still gives you full control.

  • Threading

BackgroundWorker makes it easy and having threading support can bring real performance benefits.

  • Isolated storage

Access to unlimited (with the users permission) structure protected storage in the client

  • Xaml Animation and design

Powerful, rich, growing resources, consistent across all browsers

 

  • SEO

Natural search engine optimisation because it’s Html.  Silverlight has nothing built in and search engines can’t yet index Xaml.

  • Text Handling

A basic and well supported feature of Html – Silverlight has some way to go!

  • Server Control Integration

Asp.Net Ajax server controls allow developers to create rich UI without writing and client code (e.g. Update Panel)

Silverlight

Silverlight really needs better text handling, but the other features listed here are fantastic.

Documentation & Support

Msdn – a lot of pages, not all well commented, but a strong community, more books coming out all the time. Pretty similar to Silverlight ;-) (e.g. asp.net/forums)

Joint

Performance

Silverlight is compiled managed code so performance is generally going to be much better (see www.bubblemark.com for some interesting metrics – though it needs to be updated for RTW ;-)

There are still things you need to be aware of (see this PDC presentation) but performance should be an easy win for Silverlight.
Google’s Chrome browser has impressive results for JS performance, and the engine is available for anyone to use.  So here lies a clear battle line – with google bettering on Ajax/JS/Dom performance and  MS with managed code.  To be fair IE8 also improves JS/DOM performance but not as much as Chrome

Silverlight

Even with the JS improvements from Chrome, Silverlight is still the winner.

Interaction with Services

Silverlight has great support here:

  • Asmx
  • Wcf (SOAP, REST) with ASR (Add Service Reference) (basicHttpBinding)
  • WebClient
  • HttpWebRequest / Response
  • Sockets
  • WCF Duplex
  • Ado.Net Data Services
  • Cross domain support via policy files

This is also an area that will get better for Silverlight with Alexandria (Silverlight v3)

Limited compared to Silverlight

  • Asmx
  • WCF (basicHttpBinding)
  • Supported via ScriptManager Service reference
  • No cross domain support directly from the client, though you can bridge on the server.

 

Silverlight

Silverlight has better all-round support that is going to get better.

Interaction with the Host Page

Silverlight has a rich HtmlBridge that allows Silverlight to interact with Html and Javascript in the host page, and also allow Javascript to call back into managed code. Native support (obviously!)

Asp.Net Ajax


(though Silverlight is really good too)
Technorati Tags: ,