My Life As A Blog

Archive for October 2008

Ruby Tuesday #22 : First steps with IronRuby and Silverlight

with one comment

With the recent release of Silverlight 2 and the latest version of the Dynamic Languages SDK, now seemed like a good time to write a simple Silverlight application in Ruby.  Once you’ve got all the bits downloaded, installed and extracted, find yourself a fresh new folder and open a command prompt.  I should note that I put the scripts folder of the Dynamic Languages SDK on my path variable before opening the command prompt.  At the prompt type:

sl ruby <application_name>

replacing <application_name> with the name of your application.  To see it running type:

server /b

Navigate to index.html and there’s the app running.

Right – time to fiddle.  Open the app.xaml file and add a button.  Here’s my xaml file:

<UserControl x:Class="System.Windows.Controls.UserControl"
  <Grid x:Name="layout_root" Background="White">
      <ColumnDefinition Width="*"/>
      <ColumnDefinition Width="100"/>
      <RowDefinition Height="100"/>
      <RowDefinition Height="*"/>
    <TextBlock x:Name="message" FontSize="30" Grid.Column="0" Grid.Row="0" />
    <Button Margin="4,4,4,4" FontFamily="Verdana" FontSize="18" Grid.Column="1" Grid.Row="0" 
Content="Push Me!" x:Name="rubyButton" />

Now, we just need to do something when the button is clicked.  Open the app.rb file and update the initialise method so it looks like this:

def initialize 
  message.text = "Welcome to Ruby and Silverlight!" do |sender, e| 
    message.text = "Hello World!" 

Reload your app, click the button and whoop with delight.  Worth looking at index.html in an editor – the documentation will prove helpful.

Written by remark

October 21, 2008 at 6:07 pm

ASP .NET in IronPython

leave a comment »

If you’ve ever wanted to use a dynamic language and target the ASP .NET platform, you’re in luck.  First step is to visit this download page and download the samples and documentation – I’m assuming you already have IronPython installed.  The documentation contains a walkthrough and some how-tos.  There’s also a useful post from Jimmy Schementi here that guides you through  an introductory example step by step.  I always like samples that run as expected and are simple enough to understand quickly.

Written by remark

October 21, 2008 at 4:25 pm

Made Up Technical Terms #15

leave a comment »

Crowd Computing – The use of large numbers of people to solve a problem.

Written by remark

October 14, 2008 at 2:54 pm

Posted in General, Software

Mobile multithreading

leave a comment »

While it is still (relatively) fresh, I thought I’d share my experiences writing some multithreaded code for the .NET Compact Framework.  You can read the article here.

Written by remark

October 10, 2008 at 5:13 pm

Posted in .NET, c#, Development


leave a comment »

PDC is coming up fast.  I’m heading out for the conference in a couple of weeks and was just reviewing the sessions I’d like to attend – spoilt for choice.  Worth keeping an eye on the blog and the twitter feed for the latest info.  Those of you attending will be getting a little something.

Written by remark

October 9, 2008 at 1:56 pm

Posted in .NET, Events, Microsoft, Windows

Ruby Tuesday #21 : Closures

leave a comment »

It seems impossible to avoid closures when reading about Ruby.  What is slightly unclear is what exactly one of these closure things is and what they should be used for.  According to Wikipedia, a closure is:

"a function that is evaluated in an environment containing one or more bound variables. When called, the function can access these variables"

Not much clearer?  Here’s Martin Fowler’s contribution:

"Essentially a closure is a block of code that can be passed as an argument to a function call."

He goes on to explain that a key feature of closures is that:

"they are a block of code plus the bindings to the environment they came from"

Which leads us back to the Wikipedia definition.  He also points out that in a language that doesn’t support closures, he misses them.  I get the feeling that this is a language construct which is best understood by usage rather than explanation.  And there’s some stylistic preferences.  Consider this example from a useful primer on closures:

@person = Person.find(id)
respond_to do |wants|
 wants.html { render :action => @show }
 wants.xml { render :xml => @person.to_xml }

The author describes this code as "beautiful to look at, and with a quick glance, you can tell exactly what it does" – I’m not sure I agree on either point.  I’ve seen a fair amount of Ruby that has impressed me with its expressiveness – this excerpt doesn’t make that list.  In my search for more insight into closures, I found this is a good starting point – an executable piece of exploration (found via RubyInside.)

Written by remark

October 7, 2008 at 7:30 pm

Posted in Development, Ruby

LINQed Lists Article

leave a comment »

While working on the National Rail Enquiries Proof of Concept, I wrote some code to filter lists and select items from lists that used LINQ and ran on the .NET Compact Framework.   There’s more detail in this article.

Written by remark

October 6, 2008 at 5:57 pm

Posted in .NET, c#, Development