The Business of Silverlight

04.04.2008

Chris Carper, a member of the Silverlight business development team at Microsoft, has started a blog about the business impact that Silverlight is expected to have on the industry. It’s brand new, so no real gems there yet, but we’re all looking forward to hear what the Silverlight team has to say about the business side of Rich Internet Applications..

Check it out here: http://silverlightbiz.blogspot.com/


Silverlight 2 beta 1 is out

11.03.2008

Unfortunately I’m knee-deep in diapers and other parental leave oriented tasks, so I haven’t been able to play around with it much, but you can read more here:

 http://www.microsoft.com/presspass/press/2008/mar08/03-05MIX08PR.mspx

Edit: I have now had a bit of time to try out some things in Silverlight 2 beta 1, and my conclusions are:

- Lots of new stuff has been added, such as the much anticipated networking features (Sockets, POX, etc.) as well as many new standard controls, and that’s great news!

- There’s even a “Go-Live” licence, which, for those unfamiliar with Microsoft terminology just means that you are welcome to build something on Silverlight 2 beta 1 and actually deploy it to the public. Nothing business-critical, mind you.

- The environment, toolset and plugin is still far from being finished. I’ve had several crashes already, and I haven’t been using it for more than a few hours. Also, sometimes my Silverlight plugin is not recognized by the sites I visit.

- The documentation is generally speaking much better than before, but still a long way from being finished. For instance, there is no explanation on how to load on-demand a classlibrary user control, except for an MSBuild walkthrough. No VS.NET example, and we are left guessing.

- And yes, the ball bounces just as bad in Silverlight as in Flash.

So.. Back to Flex 3 / Flash for now. But considering the progress that Microsoft made between the Silverlight 1.1 alpha and the 2 beta 1 in about six months time, things are really moving in the right direction.


RIA Wars Update: Silverlight 2.0 Is Coming

01.03.2008

It’s going to be an interesting spring this year; Microsoft has recently revealed some of the core functionality in the upcoming Silverlight 2.0 beta 1, which is expected to be released in the next month or so.

With Adobe Flex 3 just out, Microsoft is keen to show that their offering will be the better product, and they have certainly listened to the feedback from the  1.0 and 1.1 CTP releases, both of which were limited featurewise, frankly to the point of being useless.

Among the features included in Silverlight 2.0 beta 1 are:

  • - WPF-style layout using XAML, deeply integrated with Expression Blend (the design tool)
  • - A wide array of built-in controls (you know, TextBox, CheckBox, RadioButton, Panels, etc.)
  • - Support for REST, WS*/SOAP, POX, RSS, and plain old HTTP and even Sockets - yay :)
  • - Extensive .NET base class library support, including collections, IO, generics, threading, globalization, XML and local storage
  • - HTML/Javascript/DOM interaction with .NET code
  • - LINQ support

There is more, but they are not telling about it yet.

So what about install size, prerequisites and browser and OS support? I’m just going to quote Scott Guthrie, who knows everything there is to know about all things .NET and Silverlight, because I can’t word this any better than him:

“Silverlight 2 does not require the .NET Framework to be installed on a computer in order to run.  The Silverlight setup download includes everything necessary to enable all the above features (and more we’ll be talking about shortly) on a vanilla Mac OSX or Windows machine. 

The Beta1 release of Silverlight 2 is 4.3MB in size, and takes 4-10 seconds to install on a machine that doesn’t already have it.  Once Silverlight 2 is installed you can browse the Web and automatically run rich Silverlight applications within your browser of choice (IE, FireFox, Safari, etc).”

Collections, threading, globalization, Sockets and local storage .. It’s going to be great! As much as I love Flex by now, I can’t wait to get my hands on Silverlight 2.0 beta 1…

Read Microsoft’s accouncement on Scott Guthrie’s blog here, which includes a nice tutorial.


Online Flex Compiler with ASP.NET Web Service

18.12.2007

I just received a couple of very cool books from Adobe a few days ago along with a training DVD, and I’ve been trying to consume as much of it as I could while tying up some loose ends at work before the holidays.

Anyways, two things I like a lot about .NET is reflection and runtime compilation. So I thought I would see how far I could take my (limited) Flex knowledge in that direction, using the new Flex 3 beta 3.

I decided the best way forward would be to create an “online Flex compiler” – that is, a Flex application that allows the user to input some source code and have it compiled and executed directly.

Flex doesn’t allow runtime compilation, so my solution is based on a Flex front-end and an ASP.NET 3.5 Web Service backend, which in turn calls the Flex mxmlc.exe command-line compiler.

I should point out here that Adobe has created another command-line tool called Flex Compiler Shell (fcsh.exe), which boosts compilation time and contains a few features not present in mxmlc.exe. However, I decided that because fcsh.exe is in beta (not production-grade) and mxmlc.exe is a finished product (for Flex 2 at least), I should concentrate on the latter.

My idea was this: Any SWF-file can be compiled using either Flex Builder or mcmlc.exe, and such an SWF-file can also be dynamically loaded, for instance as a module, in a running Flex application.

So why not combine those two things? It might make for an interesting way to allow user-created content to be added to a community RIA in true Web 2.0 style.

Well, I didn’t get that far, but I got the technical solution working :)

The Solution

I can’t show you the finished solution, because I’m sure my poor little web server would choke under the stress of people playing with it – because it’s really quite fun. Instead, I’ve captured a screenshot for you to take a look at.

Dynamic Compiler Screenshot

It works like this:

  • - The screenshot above is of a Flex application called “DynamicCompilerClient.swf” that runs in a browser, and which contains a simple TextArea into which the source code for a simple Flex module is loaded.
  • - The user can change the code freely and then click “Compile and Run”. By clicking the button, the ASP.NET 3.5 Web Service “Service.asmx”, which was previously imported into Flex Builder, is called with the source code as input.
  • - The Web Service saves the received source code in a unique folder on the server that is available from http (eg. mapped as a Virtual directory) and then uses System.Diagnostics.Process to call the mxmlc.exe command-line tool. The standard output from the compiler is picked up by the Process and the resulting SWF-file “DynamicModule.swf” is saved in the folder.
  • - The Web Service returns a URL to the “DynamicModule.swf” to the calling “DynamicCompilerClient.swf”, which picks up that URL and loads the module using ModuleManager.GetModule(url).
  • - Once the module is loaded, the ModuleEvent.READY is fired, and the module is added to the canvas.

Thoughts on Implementation

Here are my current thoughts on the implementation:

  • - It works fine and only took a few hours to implement.
  • - Importing an ASP.NET Web Service into Flex Builder was easy and works great for my simple scenario. I haven’t tested complex data structures yet, but I imagine I will at some point.
  • - The Flex compilation process itself wasn’t as smooth as using .NET’s Microsoft.CSharp.CSharpCodeProvider etc., but on the other hand dynamic module loading in Flex seems to be less bothersome than dynamically loading (and particularly re-loading) assemblies in .NET.
  • - The command-line compiler was pretty slow – it takes approx. 2 seconds each time. However, I imagine a big speed penalty is incurred because mxmlc.exe launches a new Java Virtual Machine on each run and because results are not cached between runs. Fcsh fixes this to a great extent, I’m sure.
  • - I wouldn’t exactly call the solution I’ve implemented production grade. I don’t so much mean code-wise (it’s a mess), but rather the architecture: Calling a Web Service that in turn executes a command-line compiler that stores the result on disk and returns a URL seems to be a chain with a lot of weak links.
  • - There are, luckily, lots of ways to improve the stability of the solution. For instance, instead of doing things synchronously (which is what would cause my server to choke if I opened up to external requests), the Web Service could asynchronously queue the request in a database, and a Windows Service could then poll the queue, run the compiler and store the result also in the database, letting the Web Service (again asynchronously) return the result to the caller whenever it’s good and ready. In other words, it’s not so much a Flex/ASP.NET interoperability issue, it’s an implementation issue on my part.

Conclusion - and what about Silverlight?

The conclusion has to be: It works fine and I’m fairly happy with the results. It’s not runtime compilation in Flex, but it’s pretty close.

However, now I am really looking forward to Silverlight 2.0 beta, because it seems that this scenario is simpler to handle in a pure .NET environment. Runtime compilation will probably not be possible from within a Silverlight application either (CSharpCodeProvider calls .NET’s C# compiler csc.exe from the command-line behind the scenes), but at least the server-side logic would be less of a hack.

Comments? Thoughts? Let’s hear’em!


A* Pathfinding with Silverlight - Not!

09.12.2007

Being a .NET fanboy, I thought I would reproduce the isometric pathfinding demo I made a couple of days in Flex, using Silverlight 1.1 (see the original post).

The A* algorithm, the mouse picking and the movement should be easy enough. But I immediately hit a snag: It’s apparently not possible to paint the image tiles onto another image?! And I refuse to draw the isometric “world” using 10 x 10 images! So I was unable to do it :(

It seems my point about Flex being the easy choice for RIAs until Silverlight is much more feature complete and mature still stands. I doubt all wishes are fulfilled in the 2.0 beta coming in the beginning of 2008.


RIA Wars: Silverlight vs. Flex

05.12.2007

I just love it when new technologies make my working hours as a systems architect and developer more productive. Granted, sometimes it takes a while before I catch on. I’m not really an early adopter (got my first iPod last christmas), but when I see something that can help me deliver a better product to my clients, you have my complete attention.

So about once a year, I venture away from my world of C#, business logic and backend systems and into the wonderful world of frontend and user interface systems, thinking that by now, after all these years, someone will have invented something that actually works. It was time for that again this weekend, and I must say it’s been a more interesting journey than usual.

I normally start looking at XHTML, CSS and Javascript, and every time I feel immediately disappointed: These technologies pretty much still look and feel the same, no matter how much IDE candy, code-completion and drag-and-drop you throw at it, and still behaves wildly different from browser to browser.

Next on my list is to download the lastest version of Flash whilst hoping that this time the good folks at Adobe have stopped smoking whatever it is they were smoking when they invented Lingo and have produced a real development toolset. Something that looks and feels like it could actually be used for serious development work. But this time, I didn’t get that far. One of my colleagues had for weeks been talking about something called Silverlight from Microsoft, which everybody was describing as “a Flash killer in C#”.

Silverlight

Silverlight turns out to be a very interesting and promising technology. It certainly looks like it was meant to be a “Flash killer”: You download a plugin for your browser and then you are all set to view so-called Rich Internet Applications (RIAs) that contain movie clips, vector graphics and all sorts of cool effects.

The thing is, Silverlight uses a declarative XML-based language called XAML and you code the entire thing in .NET. Yes, that means C# code which gets compiled and runs in a special, stripped down CLR inside the browser. Very cool.

But it gets better: It not only works in Internet Explorer, it also works in Firefox and even Safari on Mac. And the Mono guys are hard at work on a Linux version called Moonlight, apparently with some support from Microsoft.

I promptly downloaded the bits for the alpha version of Silverlight and the toolkit for VS2008 and set out to create something worthy of the RIA buzzword. And after playing around with it for some hours, here’s my current take on Silverlight:

  • - It’s really fun and easy to learn, and it really is C# on the client with vector graphics. Woohoo!
  • - It looks and feels like a real development toolset, because it’s based on VS2008, XAML and C# (or VB if you are slow).
  • - The IE7 browser plugin fails some of the time, both the released version 1.0 and the alpha version 1.1.
  • - The codebase and documentation for the 1.1 alpha is far from complete, but that’s to be expected.
  • - There are tons of features that I would love to see included, and from what I can read in the forums, I’m not alone.

So - Silverlight is something of a work in progress. They expect to have a new beta out in Q1 2008 (renamed to “Silverlight 2.0″), which should contain a lot of new features and with a Go-Live licence. My guess is that Silverlight would then become a “real” product during the summer of 2008. But the question remains: Is this a “Flash killer” ? Time to download that new version of Flash and have a look.

What the heck is Flex?

As it turns out, I must have been living in the land of Microsoft for too long, because I had never heard of Flex. Flex is Adobe’s development toolset for building RIAs, and guess what? It doesn’t look anything like Shockwave or Director, it doesn’t run on Lingo and most importantly, it doesn’t suck at all.

With Flex (version 3 beta 2), you can compile applications using an open source SDK if you have too much free time on your hands, or you can be smart and use Flex Builder, an IDE based on Eclipse which works like a charm! The end result is an SWF-file, which runs in any browser-based Flash player, or in a desktop application using Adobe Integrated Runtime (AIR). Completely cross-platform.

Flex is based on MXML, which looks suspiciously like XAML - or is it the other way around? You write code in ActionScript 3 (AS3), which is a script-language that is based on ECMAScript. Now where have I heard about ECMAScript before? Oh yeah, that’s right. It’s Javascript. Damn.

But as it turns out, it’s not that bad. Sure, things are not strongly typed, there are no generics, there’s no way to count the number of elements in an associative array except for the stupid way, etc., etc., but on the plus side AS3 and Flex as a whole is extremely easy to work with and well geared towards quickly and painlessly writing complex RIAs. And let me tell you: The feature set is no joke, and neither is the community around the product. Practically anything you can think of, someone else have already wrestled with and solved in Flex a long time ago. Need to integrated with something other than a simple web service? Or use sockets to communicate directly with someone? Or how about streaming and processing video or audio? Go right ahead, it’s all there.

I could go on.

And the Winner is..?

Perhaps Silverlight really will become a Flash killer - but I don’t think it’s going to happen over night. Flash players are (according to Adobe’s figures) present on 97% of desktop computers and well on the way to be a leading platform for mobile devices as well. Silverlight won’t get there for at least 12-24 months, if at all.

So for now, even though I do miss the consistant and strongly-typed world of C# and .NET, Flex is the easy choice for RIA development.

Let me hear from you. Am I missing something? Do you agree or disagree with my short analysis? Comments, please!