Ruby Tuesday #18 : Ruby meets .NET

12 08 2008

A couple of weeks ago, I posted that John Lam had announced a binary release of IronRuby.  So, I downloaded the zip file and extracted it to the root of my C drive.  That created a folder called IronRuby on my C drive containing all the IronRuby goodness.  In the IronRuby folder, there’s a bin folder in which is ir.exe, so I added C:\IronRuby\bin to my system PATH variable.  I opened a command window and typed ir and saw this:

image

Now that I had IronRuby running, I did the obvious stuff – putting Hello World, adding some numbers and so on.  Next, I tried calling .NET from IronRuby.  I typed the following lines into the console;

require ‘mscorlib’ require ‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ require ‘System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ Form = System::Windows::Forms::Form $f = Form.new $f.Text = “Hello World!” System::Windows::Forms::Application.run $f

I’m using $f (a global variable for those new to Ruby) because, as the console says, local variables aren’t supported yet in console mode.  And, this is what I saw:

image

.NET written in Ruby.  There’s a lot more here to explore.





Synchronicity

6 06 2008

I was thinking about the Twitter client that I’ve been writing in Ruby.  Before embarking on the Ruby learning journey, I had written a Twitter client in C#.  I was considering comparing the two to see what I could learn about the differences and similarities.  The biggest difference isn’t really language related - it’s a design choice.  The C# client is asynchronous whereas the Ruby client is synchronous.  The C# client is asynchronous because I intended it to be used in a WPF app - although to test it from the command line, I wrote a synchronous wrapper (and used reflection in the command line program so that it can call any method on the synchronous wrapper with minimal code.)  The Ruby client is synchronous because it’s a learning exercise.

Writing an asynchronous client (at least in C#) makes your code more difficult to follow (well, it makes it more difficult for me at any rate.)  So, I started reconsidering if it would have been better to write a synchronous client  - largely because the code would be simpler.  This would mean that a WPF front-end would need to implement asynchronicity itself (assuming that it should be responsive.)  And given the fact that the web is, by its very nature asynchronous, this would mean asynchronous code calling a synchronous facade to an asynchronous service. Which sounds wrong.  So, I think that the client should be asynchronous.  But I’d like it to be simpler, too. Because of the target use, I decided an asynchronous client was the better design.  And this is the kind of decision that you have got to make one way or another.  You can’t hedge your bets and make it a bit asynchronous.  And if you change your mind, you’ve got some work to do.  I guess I should look at how you’d make the Ruby client asynchronous so I can get round to that comparison…





Django on IronPython

30 03 2008

At PyCon 2008 in Chicago earlier this month, the latest release of Django (0.96) was shown running on IronPython.  There’s an interesting post about it here, and there’s some background info here from Dino Viehland.

It’s great to see IronPython supporting Django.   It demonstrates the power and ambition of IronPython, but, more to the point, the combination of Django and the .NET platform is exciting.





Mix ‘08

4 03 2008

Want to keep up with what’s going on at Mix ‘08 but you’re not attending?

Here’s some help:

Read Tim Sneath’s blog
Follow Scott Hanselman on Twitter
Visit the official site





Mobile Development

26 02 2008

I’ve always been impressed by the fact that you can leverage your .NET development skills to develop for Windows Mobile devices. I’ve tried out a few trivial examples, but this is an area I’d like to explore in more depth. So, I had to check out the the Windows Mobile Developer Center, which has been refreshed and renewed. Take a look. Isn’t the 4th box intriguing?





What BizTalk does

24 01 2008

Here’s a useful resource if you want to find out the capabilities of BizTalk Server 2006.  It’s an interactive poster that uses Silverlight to allow you to zoom in and out and pan around.  And you can click on a capability to get more information.





Dynamic Data

3 01 2008

During the latter half of 2006, I spent a little time getting to know Django.  I was impressed - especially by the automatic admin functionality.  The challenges of using Django for real, however, were so substantial - the abandonment of a known, tried and trusted environment being first on that list - that the interest never developed further.

So, when I saw the Dynamic Data feature of the ASP .NET 3.5 Extensions Preview, I felt compelled to give it a go.  After a false start trying to use the latest CTP of SQL Server 2008 - this is only preview software, so I’d expect that SQL Server 2008 will be supported in a future version - I switched to the already installed SQL Server 2005 Express and followed the example in Scott Gu’s blog.  It boils down to three steps:

  1. Create a project
  2. Add LINQ to SQL Classes and drag the tables you want onto the designer.
  3. Modify the web.config file to enable Dynamic Templates.

Then you run it.  And it just works.  Really.  The whole thing took me less than 5 minutes.  And you can customise the look and feel easily.  This will be a great way of rapidly creating data entry screens that can be used for admin functionality or for facilitating data entry while the main application is being built.  Prototyping and creating real functionality that can be used and can evolve over time are other uses of this framework.  And being built on ASP .NET 3.5 and LINQ, it’s built on technology that you (will) know.  My only worry is that it doesn’t have a cool enough name.  (For what it’s worth, I’d suggest Aspen - ASP Extensions.) 





Volta

11 12 2007

Last week, Microsoft Live Labs released a CTP of Volta.  Volta is:

“a developer toolset that allows you to build multi-tier web applications by applying familiar techniques and patterns.”

Here’s how it works.  You write your code in C# - let’s say for a web page.  Volta recompiles the MSIL as Javascript - so your page is fully functional even though you wrote in C#.  Then, if you decide that some of the code should run server-side, you can “tier-split” (via an automated refactoring that adds attributes to your classes) and bingo.  Job done.I downloaded the CTP and went through the Quickstart and a couple of the samples that come with it and it does what it says on the virtual tin.  Of course, when splitting, you’ll want to remember the Fallacies of Distributed Computing (especially “Latency is Zero”.)  And to help you, Volta comes with some profiling tooling.This is a technology that’s worth keeping an eye on.  Right now, it seems a little raw - performance will no doubt improve over future releases - but there’s no doubting the power that comes with the simple model it offers.





Analyze That

7 12 2007

While tinkering in Visual Studio 2008 today, I saw a context menu item on a project I’d not seen before: Calculate Code Metrics.  And there’s another called Run Code Analysis just above it.  Pleasingly, if unsurprisingly, you get some metrics about your code.  That’s right - feedback on your code from within the IDE.  Ok, so it’s got a little way to go before it can compete with the code metrics tools you’re probably using now,  but this is a very encouraging start.  Somehow, this feature escaped my attention until now.  There’s more info in this post from Somasegar and this post from the Code Analysis Team.  One more reason to use Visual Studio 2008.





Silverlight Tools

27 11 2007

Scott Guthrie has announced the release of the Silverlight Tools Add-In for the recently released VS 2008.  More info here.  It’s the bit at the end of Scott’s post that’s intriguing:

“The next public preview of Silverlight will include a ton of new runtime features, as well as a significantly enhanced VS 2008 tooling support. I’ll be blogging more details about this shortly.”  

Eyes will be peeled.