John Liu .NET

View Original

SilverLight is better than AJAX + DOM

I just got home from the Sydney .NET User Group tonight, where they talked about SilverLight and Flex in a session focused on RIA.

I personally think the session was relatively informative to a general crowd,  but not detailed enough to go into the specifics.  I'm not sure what the intended audience was given that the SNUG crowd is pretty much all .NET guys.

I had a chat with a few guys after the session and most were unsure or even unimpressed with what SilverLight has to offer.

I find that pretty sad.

The main arguments against SilverLight were along the lines of:

  • All those can be done with AJAX

Perhaps the presentation was too general and did not focus on outlining the benefits of using SilverLight over plain old AJAX.

I think there is a very naive view of SilverLight among the audience tonight.  Probably, what we needed to convince the .NET people that SilverLight is cool is this following list of stuff that just can't be done with AJAX.

Development Scenarios

  • Dynamic loading could be done with AJAX, but you have to test it with FireFox, IE6/7/8, Opera, Safari.
    Not to mention the various combinations of operating Systems with them.
  • Did I mention mobile devices?
  • Difficult debugging scenarios - VS.NET actually makes this easier for IE and FireBug made it easier for FireFox, but essentially you are down to debugging JavaScript, which is iffy at best.
  • Mucking around with CSS and DOM is wasted time
  • SilverLight can be debugged directly in VS.NET - there is an option to switch on (default)

Vector Graphics

  • No vector graphics with the DOM
  • Try to do rounded corners with DOM and you either have to resort to some background picture trick (lots of files and connections) or stuff around with multiple layers of borders (nasty looking DOM).
  • You can't even draw a diagonal line in the DOM,
  • Let along trying to do Ink (point below)
  • There is a reason that people wanted SVG support, and to pass the ACID3 test the browser needs to natively implement SVG, and Microsoft is criticized heavily with not supporting SVG out of the box in IE8 (they probably never will).
  • People know the DOM sucked at this stuff, they wanted to stick SVG in the browser so they can stay mucking around with the DOM some more.
  • To be fair, Adobe was at the forefront of SVG development, but as soon as they picked up Flash/Flex/Macromedia, they stopped their free SVG plug-in development immediately.
  • I think SVG is a waste of time in the wrong direction altogether.  SVG was designed for a market that failed to materialize in 1999.  The reason that Flex and SilverLight are successful is because people and technology have moved on.
  • I'm convinced a SilverLight vs Flex scenario is better for the world as both companies race forward to win developer minds.
  • Finally, if you are not convinced SVG is dead, go to Yahoo! Finance's interactive chart here and tell me how much stuffing around would it be required to get those cool looking graphs to work with DOM+SVG+AJAX.

Animation

  • The SilverLight story boards is a time-based system, which is an improvement over the frame based systems in Flash. 
  • I think with SVG another protocol SMIL will be needed to achieve the same thing.

Ink

  • SilverLight supports Ink

Layout Management

  • Stop stuffing around with aligning this label/textbox with another label/textbox halfway down the screen, past the grid in between
  • The DOM simply don't support proper layout management, and hacking it via CSS is ugly, or fails to scale when the browser window size changes
  • Which is a big problem for mobile devices, apparently.

Data Binding

  • SilverLight has data binding support out of the box.  Browsers/DOM/AJAX are stuck with manual data binding, or part/full page post backs.

Framework

  • SilverLight is build with a solid set of the .NET framework library.  This includes multiple out of the box functionality that would need to be build with JavaScript
  • Working with proper collections and generics, or LINQ and LINQ to XML

Threading Support

  • Bread and butter of Windows Application development.  Threading has never worked properly, if at all with AJAX.
  • Try calling three web services at once and collect their responses and make some use of them.  Note that any or all of these asynchronous calls can and will fail.  Most DOM/AJAX implementations of the XMLHttpRequest stuffs up right about here.

Isolated Storage

  • Isolated Storage
  • AJAX systems rely on ViewState or server session systems.  ViewState is passed around all the time and takes up bandwidth, and is lost when user logs off. 
  • Cookie file is far limited in size.

Network Capabilities

  • Sockets
  • Cross-Domain calls - excluding JSON with AJAX.

Serialization

  • JSON, XML, SOAP Serialization

File Processing / Upload

  • The HTML upload input control is still stuck at the 90s
  • SilverLight has read-only access and has OpenFileDialog implementation
  • Can preview a file on client side before deciding to make service call to upload them.  Doesn't even need to upload them.

 

Argh I'm tired.  That's probably too much info for one evening.