Flash to Silverlight Pt. 1

Over the past few weeks I have been examining Silverlight 3 (with an eye to Silverlight 4 which should be released pretty soon), Microsoft's RIA run time. The fact that for the last 8 years I have rarely touched a Windows machine (except for testing purposes), left me feeling pretty in the dark about this technology which uses the Microsoft .NET framework. In the last two days, I have reached the point that I feel like I know the best approach to using Silverlight 3/4, given my Flash background. My goal in the present post is to document what I have found over these past weeks that has led me to this present state of relative tranquility.

Before I dig in, just a little background. I usually work in a Flash environment with Flex 3 (actually, mostly Flex 4 these days) and Actionscript 3. My current Integrated development environment (IDE) of choice is FlashBuilder 4 (currently still in Beta 2, but should be in final release this month or next), for a number of reasons: (1) my Java-coding background with Eclipse (Flex Builder 3 and Flash Builder 4 are built on Eclipse, (2) It is much better than FlexBuilder 3 for reasons I don't have time to go into (If you abandoned FlexBuilder 3 for some reason, give it a try: you will be pleasantly surprised at many of the improvements).

Anyways, I was recently approached by a potential client who was interested in our work, but was looking for someone who could develop for Silverlight 3/4. I agreed to take a look at the environment for them and see what I could quickly throw together using that environment (those examples should be posted soon, I hope). So, I initially spent a few days reading various posts and even a book about Silverlight (I can't recommend this book; though useful to an absolute beginner, it reads like copy from an underpaid Microsoft-paid ad agency). In general, XAML, the markup language of Silverlight applications is no different than the MXML of Flex applications; this is as you would expect given that they are both XML-based markup languages. What concerned me more in these preliminary stages was the main coding language and the development environment and/or workflow.

The choice of coding language and IDE are tightly intertwined for Silverlight, simply because there are more choices all around. Let me explain. In Silverlight, each XAML file has a script/code subfile associated with it. The file naming system explains it even better: If your XAML file is named mainApp.xaml, then your code file will be mainApp.xaml.cs (if you are using C#) or mainApp.xaml.py (if you are (trying to) use ironPython). Now, at least for those of you from a Flash background, you might be surprised to learn that Silverlight gives you multiple options when it comes to your coding language--as was suggested by the previous sentence. You can use Visual Basic, C#, Ruby (in the form of IronRuby, and Python (in the form of ironPython), and probably a few others that have slipped from my current line of thought. The fact that you can use Python was attractive to me for at least two reasons. First, even if my Silverlight experience goes nowhere, I might still walk away with some improvements to my Python knowledge; I would not benefit as much from honing my C# skills, which is a language that I don't see me using much in the future (its not a bad language, it just isn't used very commonly where most of my current work is done). Second, Python is just one of those nice dynamic languages. So, I wanted to find an IDE that supported the development of Silverlight applications with Python as the language of choice.

IDE Adventures

Whats with my obsessions over an IDE. You don't really need it to develop Silverlight applications with Python--a text editor, console, and browser could probably do the trick for some simple applications. However, since most of my work these days involves large amounts of code (the 3D stuff being the most code hungry past time), working from a text editor (personal plug: Textmate) is really not the best way of retaining the few follicles of hair that remain on my head (joking: there are no hairs on my head). So I looked around some.

My main machine is a Macbook Pro. I do have a Bootcamp Windows XP install on it with Parallels as well, but I prefer to work in OS X or in my Fedora virtual machine. So I wanted to see if Silverlight development is possible in a Unix environment. It is: MonoDevelop which is packaged with most(?) Linux distributions and there is also a version for OSX. The one catch is that Silverlight. For example, the current version of Silverlight 2; but Silverlight is currently at version 3 (version 4 is at beta2). Although MonoDevelop does seem like a powerful (and free) IDE, I didn't want to teach myself a version of Silverlight that was one big version behind the current. That, and I suspected the potential client was all for new tech. So, the hunt continued.

There was one more option that could keep me in my OSX la-la-land: Eclipse. If you know Eclipse, you know that if you can think of it, then there is probably a plug-in for it. Sure enough, there is a plug-in to support Silverlight development within Eclipse: Eclipse4SL. It installed wonderfully using the instructions provided on the projects website. I was up and running and happy to be in that IDE environment I know so well. One major glitch though:

No, Rusty wasn't the coder who wrote the plug-in. Just go to the install instructions page and look WAAAAAAAAAAAAAY DOWWWWWN at the bottom of that page. What you will find there says it all. For me the crashes occurred much more frequently than from "time to time": It happened all the time. If you have the time to check it out, I hope you have more luck than I did. Either way, I am hoping they provide a quick fix for that issue some time soon so I can move back into that environment.

As a side note, I did briefly take a side glance at SharpDevelop which was what MonoDevelop forked from many moons ago, but it has nothing in it for Silverlight development. But that was just out of curiosity. So what was next? No more free or open IDEs was what (I haven't been able to find anything for NetBeans; let me know if you spot something). And no chance of developing Silverlight in Linux or OSX was what. You already know where this is going.

Yes, I fired up Windows XP, and followed the steps to download and install the latest version of Visual Studio and the Silverlight Tools. All the initial setup steps can be found at the Silverlight page. Now, I tried installing both Visual Studio 2008 and Visual Studio 2010. I decided to use Visual Studio 2010 because it has a better development environment for Silverlight projects and because you can develop for both Silverlight 3 and Silverlight 4. One important note: At the present time, you should not install the release candidate (RC) for VS2010, which doesn't allow you to develop Silverlight projects; you want to install the beta2 version. The instructions for installing VS2010 to suit Silverlight development are here.

Python -> C#

The major problem with all the IDEs out there that support Silverlight development, is that they don't allow for any easy integration of IronPython into a code project. In Visual Studio, for example, you can install Iron Python Studio as an add-on to Visual Studio, but there is no way to create an IronPython based Silverlight project. So, although Silverlight does support Python via IronPython, there is no IDE tools available that allow you to develop a sizeable Silverlight project that uses IronPython as the main coding language (I could see you using it on top of C#). So, after much strife I settled on exactly what I feared I would be settling on: Visual Studio and C#.

I have spent some time looking at C# now, and I can tell you that if you have any Java background or Actionscript 3 background, you will have no trouble picking this language up. I plan to write more about what I discover about the differences between C# and Actionscript 3 within a different but related set of blog posts, but I can tell you one thing that impressed me about the Silverlight - C# combo: Silverlight and C# support multithreading (e.g., see this post), whereas Actionscript 3 does not (see this post).

Please stay tuned for my first experiments with Silverlight and for more comparisons between Flash and Silverlight and between Actionscript 3 and C#.

Trackback URL for this post:

http://www.stevenjbarnes.com/trackback/35