Wednesday, May 20, 2009

IronRuby 0.5 Released

imageI’m pleased to announce a new release of IronRuby: IronRuby 0.5!

Download IronRuby 0.5

You can also check out the source code for this release

Staying true to our "Conference-driven development schedule," this release is in conjunction with RailsConf '09, where IronRuby was demonstrated running real Rails applications and deploying them on IIS. A ton of work has been done in this release to get real Ruby programs running well, like RubyGems, Rake, Sinatra, and Rails.

Read more about IronRuby at RailsConf here

Special thanks to Daniele Alessandri, Jirapong Nanta, and Ray Vernagus, who contributed code during this release, and everyone else who has submitted bugs, updated the wikis, or built software on-top of IronRuby.

Also, take a look at the IronRuby CTP for .NET 4.0 Beta 1, which has been released as part of Visual Studio 2010 Beta 1.

What’s in the Release?

A big language feature of this past release was adaptive compilation; the ability to start-up quicker with a fast interpreter, and then compile code that gets interpreted more than two times. This brought Rails startup time down from 89 seconds to 34 seconds, giving Rails approximately 2.5x quicker startup. Since this compiles “hot” code, your Rails application will get faster after an initial set of requests. There is a lot more to do for performance, but this was a great accomplishment.

Here are some more interesting changes:

  • Removes ClrString. CLR strings are referred to as System::String
  • Removes IronRuby library. "require 'IronRuby'" is no longer needed; IronRuby module is now a built-in module.
  • Integer/Float operations for all CLR primitive numeric types
  • System::Char and System::String methods so that they behave like an immutable UTF-8 encoded string
  • Improves handling of BOM in 1.8 mode
  • Debugger visualizer for RubyObject so that VS will display the result of to_s in the Watch window.
  • Adds support for .NET operators (op_* special methods)
  • Implements bitwise operators on flag enums
  • Precompilation of simple Ruby method invocations
  • Improves performance for file IO#read method. Previously we were 10x slower than MRI, now we are approx. 1.5-times faster.
  • Tons of fixes to File, String, Array, and other built-in types to drive up RubySpec and Ruby application test-suite pass-rates.

For detailed information, please see the CHANGELOG (which is much more verbose now. including all commit messages for the release … not just syncing to head of tfs)

Bugs closed

RubySpec status

IronRuby passed the 80% mark on RubySpec during this release:

image

You can see more IronRuby statistics on http://ironruby.info.

Also during this release IronRuby has been running other Ruby applications test-suites as part of individual developer tests and in continuous integration, such as RubyGems, Rails (including ActiveRecord, ActiveSupport, ActionPack), and Rake.

Next Release

The next release will push harder on application compatibility, especially Cucumber (which has been the most requested application), Rails, and all the other frameworks being tested currently.

Also, the feature which makes IronRuby stand out, .NET integration, has next-to-no documentation, so that will large focus during this next release as well. Keep an eye on http://ironruby.net/Documentation/.NET, but as I said, is very sparse at the moment.

In the meantime, please test out IronRuby 0.5 and let us know all the issues you find. Enjoy!

IronRuby CTP for .NET 4.0 Beta 1

We’re pleased to announce the release of the IronRuby CTP for .NET 4.0 Beta 1!

Download IronRuby CTP for .NET 4.0 Beta 1

This is our second preview of IronRuby running under the Dynamic Language Runtime that is built directly into a .NET 4.0 release! As before, this release allows you to use IronRuby objects and types as .NET 4.0 dynamic objects from within C# and Visual Basic code. These binaries are roughly equivalent to the functionality found in IronRuby 0.3. Please also note that the IronRuby CTP for .NET 4.0 Beta 1 will run only under .NET 4.0 Beta 1.

This release also includes the binaries for the IronPython 2.6 CTP for .NET 4.0 Beta 1.

To try out this preview release:

  1. Install some variant of .NET 4.0 Beta 1 or Visual Studio 2010 Beta 1 from here
  2. Download the release
  3. Follow any of the many dynamic walkthroughs online. Here would be a good start.

Enjoy!

Thursday, May 14, 2009

IronRuby at RailsConf 2009

0975_DSC_0115

I spent last week at RailsConf 2009 in Las Vegas representing the IronRuby team. I gave a talk there titled IronRuby on Rails, and spent the 45 minutes talking about the benefits of IronRuby running Rails, or any other Ruby web framework, can provide. This write-up will walk through the four sections of the talk:

Downloaded all demos

(get slides, or just visit GitHub page)

Introduction

image

Last year, IronRuby was much like this sprout; much of the plumbing was there (xylem and phloem, if you will =P), but it has only just begun to be useful, like running Rails.

image

Quickly we learned that growing up is hard to do. As IronRuby was dispatching it’s first Rails request for RailsConf 2008, it began to experience all the stresses of the outside world, like loading activesupport on startup, which loads almost everything in the Ruby standard library.

image

The good news is that IronRuby is maturing; meaningfully interacting with the world around it, and begin to get good at things. Startup has much improved, and can run real Ruby programs like Rails, RubyGems, Rake, and Sinatra (to name only a few relevant apps).

image

IronRuby’s real world, the .NET framework, is different environment than the usual Ruby developer is used to, but IronRuby bridges the gap to bring the .NET framework to Ruby developers. An example of this is deploying Ruby web applications just like other .NET framework web applications using IIS.

image

Due to running real Ruby applications, and playing nice with .NET, people are starting to notice us. Community involvement is starting to pick up, and we’re getting closer to being a “real Ruby implementation”.

IronRuby running Rails

IronRuby running Rails is not new, but doing it well or completely – is. IronRuby can now run real Rails applications, rather than just toy-hello-world examples. This does not mean IronRuby on Rails is ready for production, but it’s a great measure of forward progress.

IronRuby running Rails

Get the source code

Special thanks to Chad Fowler and Rich Kilmer for first building this sample!

We’ve been tracking our Rails progress by running though all the different Rails development scenarios, like migrating a database, generating a model, etc. The Rails documentation page on the IronRuby website walks through setting up IronRuby to run Rails, and shows the various scenarios in action, as well as how to run the Rails test suite.

Other Ruby libraries and web frameworks

Rails is not the only thing IronRuby is tracking; we’re running RubyGems, Rake, Sinatra, Rack, and a bunch more ever-increasing Ruby libraries to catch bugs, find performance issues, and use their test-suites to gather more metrics on IronRuby’s completeness. For example, the Sinatra-basesd ironruby.info website runs perfectly well on IronRuby:

ir-info

Also, for a while now IronRuby has been using and contributing to RubySpec to provide a standard-runnable Ruby specification. IronRuby’s latest numbers are available on ironruby.info.

ActiveRecord support for SQL Server

image

ActiveRecord SQLServer Adapter

Installation instructions

To run Rails, IronRuby uses a SQLServer adapter for all ActiveRecord database interactions. This adapter will work against either SQLServer or SQLServer Express (which is a free download).

ActiveRecord is useful outside Rails, and especially to a .NET developer for interacting with SQLServer. Using Ruby to manage the evolution of a schema through migrations is extremely simple and takes the pain out of doing database development. This is an example of a migration which adds a “people” table (and knows how to undo itself).

You can read more about migrations in the ActiveRecord documentation.

Once your database is created by the above migration, you can fetch and manipulate the data inside of a Ruby REPL:

Also, using ActiveRecord in a desktop application is pretty straight-forward. The following is an WinForms application which databinds an DataGrid to the ActiveRecord “Person” class.

image

Get the source code

Deploying Rack-based Ruby Application on IIS

Being able to run real Ruby applications is great, but what about deploying them? Most Ruby apps are web-based, so in this case deployment means getting the application on a production web-server and database server. The database server is already covered by SQLServer, so wouldn’t it be great to use IIS as the web-server?

Of course ...

image

ironruby-rack: deploy Ruby web applications on IIS

Rack is a Ruby web-server interface which almost all Ruby web frameworks build on-top of, like Rails, Sinatra, and Camping. This package enables and Rack-based Ruby application to run on IIS. Today this is only possible for Ruby applications through FCGI, where this implementation integrates directly with ASP.NET (through a HttpHandler), so your application will be “running” whenever IIS is.

If your organization already has an IIS knowledgebase, you probably want to utilize it. Deploying this way requires no retraining, as this solution is purely ASP.NET based; no throwing away of experience. It’s also a great way to sneak Ruby into your organization.

This project is fairly new, so if you want to use it please let me know and I help with any issues.

IronRuby ASP.NET MVC

Another way to get a Ruby web application running on .NET is to use ASP.NET directly. While there is no IronRuby support for ASP.NET WebForms (IronRuby in .aspx pages), IronRuby does have support for building ASP.NET MVC applications.

image

ironruby-mvc: ASP.NET MVC applications in Ruby

Special thanks to Phil Haack and the ASP.NET MVC team for seeding this implementation, and Ivan Porto Carrero for recently running with this (I’m sure his book will cover this =)).

In a previous post I built a tiny web-service in IronRuby-MVC to persist code typed into a IronPython-scriptable Silverlight calculator (here running outside the browser!).

calc-oob

Project Status

As IronRuby is maturing, more and more people are noticing it and (more importantly) using it. Special thanks to the more consistent contributors:

They either contribute C# code to the IronRuby codebase, documentation on http://ironruby.net and http://wiki.github.com/ironruby/ironruby, or the general ecosystem with active blogs, speaking at user groups, or new projects based on IronRuby. More information about contributing to IronRuby can be found at http://wiki.github.com/ironruby/ironruby/contributing.

To get all contributor projects, check out the ironruby-contrib project

IronRuby will be tracking performance and compatibility as it gets closer to 1.0. With 84% total compatibility on RubySpec, focus is being put on running real apps’ test-suites. Startup performance has also been a focus of improvement as of late, and by building an adaptive interpreter/compiler (like IronPython now has) Rails startup time decreased from about 85 to 30 seconds, without sacrificing startup time! Keep an eye on http://ironruby.info for updates to these types of stats.

Lastly, a little bit after this post is published ironruby-0.5 will be released. Please give it a try and submit any bugs you find to Codeplex.

image

Tuesday, May 12, 2009

MacDrive 7 with Windows 7

UPDATE: MacDrive 8 has been released, which has support for Windows 7, so the work-around explained in this post is no longer necessary. Also, people have been experiencing issues with it, so my advice is to upgrade.


If you’re running Windows on a Mac, and you’re shuffling files between Mac OS and Windows, MacDrive is the best tool for mounting your HFS (Mac OS’s default file-system format) partitions in Windows. MacDrive costs $49.95, but is well worth it. However, MacDrive does not release versions for pre-release operating systems, and there are a couple speed bumps when trying to use MacDrive on Windows 7. There are various version of this solution posted in a bunch of forums, but no definitive guide. Here’s exactly how I solved it:

1. MacDrive’s installer will only run on Windows XP and Vista. To have it run on Windows 7, you must run as Administrator, run in “Windows Vista” compatibility mode.

2. Also remove the operating system version checks the installer makes with Orca. MacDrive’s installer is an self-extracting exe, so you must extract it first; using 7-zip or any other unzipping tool will do the trick. Once extracted launch Orca and open MacDrive/x86.en-US/MacDrive7.x86.en-US.msi (or the x64 version if that applies to you). Once open, look for the “LaunchCondition” table and delete all rows from it.

3. If you run the main setup.exe from the extracted location it will install fine, but upon reboot you will not see your Mac OS drive. This is because MacDrive simply doesn’t assign the drive a letter. To do so, download Ext2Fsd, unzip, and run Ext2Mgr.exe. Find your HFSJ-formatted partition, right-click and select “Change Drive Letter”. Assign it a letter, exit the application.

image

4. Open up your “Computer” screen and you should see your Mac OS drive now:

image

Please post in the comments if this doesn’t work for you, and I’ll update the steps. Enjoy!