Because the show is supposed to be just 30 minutes or so, I didn’t get into my usual preaching about the Ruby programming language or why people should use a dynamic language. Instead I just stated the fact that I really like Ruby and I really like Silverlight and I especially like the combination of the two.
Now, it’s not absolutely necessary to go through all of those steps to get started with IronRuby in Silverlight. Instead, just download the Silverlight Dynamic Languages SDK. Under the Releases tab, there are a handful of downloads. The one that you want is the one that has “Everything”. This includes the languages, samples, quick start templates and more.
Steps to get started:
1. Unzip the SDLSDK into a directory. I put mine in my public downloads directory for ease of access.
2. Open a command prompt, cd to the sdlsdk directory and run the script:
script\sl ruby demo
This will run the template to generate a starter Silverlight application with IronRuby as it’s language. You could substitute in python or jscript as well.
3. cd to the directory demo and run the script
This will run Chiron and then launch a new browser window pointing to the directory. Chiron will first package up the dynamic language files into the XAP and then host a simple web server.
4. Browse to the index.html file. You should see a simple page with “Welcome to Ruby and Silverlight!” displayed in the Silverlight instance.
5. Under demo/ruby, open the file app.xaml. Alter it as follows:
<Grid x:Name=”layout_root” Background=”White”>
<TextBlock x:Name=”message” FontSize=”30″ />
6. open the file app.rb. Alter it as follows:
class App < SilverlightApplication
message.text = “Welcome to Ruby and Silverlight!”
button_main.click do |sender, args|
message.text = “Hello from the click handler”
$app = App.new
The “do” in this case is wiring up a .NET delegate as the event handler for click event.
7. refresh the browser (or relaunch via Chiron per step 3 if you closed the browser).
You can also find samples at:
If you want to play with IronRuby or IronPython you can get started playing in the DLRConsole found at http://silverlight.net/samples/sl2/dlrconsole/index.html. All the source for that is under the SDLSDK samples as well.
I’ll update the post once they put up the recording – .NET Coffee Break Show