Thursday, July 02, 2009

IronRuby 0.6 Released!

The IronRuby team is pleased to announce a new release of IronRuby: IronRuby 0.6!

Download IronRuby 0.6

You can also get the source code for this release

Staying true to our "Conference-driven development schedule," this release is in conjunction with ... wait, there is no conference this time! Just a good ol' monthly release of IronRuby, chock full of awesomeness. And just so happens to be the 4th of July weekend, so hopefully you have some downtime this weekend and can give the new release a spin.

What's in the Release?

Performance has been a major focus to this release, getting startup time quicker and optimizing built-in types. There has been more progress with Ruby compatibility (Cucumber works!) and .NET interop. Silverlight binaries are back in the release, and there are a couple of samples to help you learn IronRuby.

Most of these descriptions are from Tomas's very detailed code review emails, so thanks Tomas! For more detailed information, please see the CHANGELOG (which includes all commit messages for the release ... not just "syncing to head of tfs")

Lazy method compilation

Last release adaptive compilation was enabled for IronRuby, which uses a fast-to-start-up interpreter to start up the program, while code which gets run a lot is compiling on a background thread. This gave IronRuby significant performance improvements for large apps like Rails, which has improved startup by 2.5 times.

This release we've added "lazy method transformation" to the bag of startup performance tricks. In IronRuby 0.5, a method was transformed to the DLR AST as soon as it was defined. IronRuby 0.6 postpones the transformation until the first time the method is called. This significantly improves startup time. For example (not NGEN'd):

This has made Rails startup time 30% faster, coming in approximately 20 seconds on my dual-core laptop running Windows 7.

CLR member enumeration

Now methods like Module#instance_methods, etc, include CLR member names. Though it's a lot cooler than that. The array of methods returns contains strings for Ruby methods, and objects of type IronRuby::Clr::Name to represent CLR methods that can be called by either the actual CLR name or a mangled (Ruby-esk) name. ClrName has methods to_s, to_sym, to_str, <=>, inspect, and dump so that it can be used wherever a string can be used. The display string for the name uses single quotes so that you can easily distinguish CLR (dual) names from regular names (plain mutable strings). CLR strings display themselves as single quoted strings, so this fits nicely.

Even cooler, this works well for meta-programming:

A new set of define_method overloads, strongly typed to ClrName, have been added to enable this. They define the real method using the ruby_name and alias it using the clr_name. So both CompareTo and compare_to calls are intercepted.

Generic-Method Parameters-Inference

Thanks to some work by the IronPython team, IronRuby now has parameter inference for generic methods.

This needs some more TLC before it works perfectly, but this lets you use simple LINQ methods from IronRuby.

Testing C# with Cucumber

This release of IronRuby runs the Cucumber testing framework rather well. Try out Cucumber against some C# code.

Given a feature file (this being the addition.feature)

A step_definition file (calculator_steps.rb)

And a DLL:

Cucumber will test the addition feature:

3 scenarios (3 passed)
12 steps (12 passed)
0m0.753s
Silverlight building and updated binaries

This release re-adds Silverlight binaries to IronRuby, contained in the "silverlight" directory of the release. These bits have been integrated from the AgDLR project, and will be maintained in the IronRuby and IronPython source code repositories from now on. The AgDLR GitHub project will redirect to one of those for binaries for both languages in Silverlight. In addition, the SDLSDK CodePlex site will be redirecting to the IronRuby and IronPython CodePlex sites, for downloads, discussion, and issue tracking. AgDLR was a little side project to add new features to DLR Silverlight applications, and play around with Git. I'm very happy to see it merged back in with the languages.

Note: IronPython Silverlight assemblies are included directly in the release. They may be moved out to the separate package that contains IronPython desktop DLLs in the future.

See the integration commit for more information

Another notable change is that you can now build Silverlight binaries out of IronRuby's GitHub repository very easily. Given that you have Silverlight installed at C:\Program Files\Microsoft Silverlight\2.0.40115.0, this will build IronRuby for Silverlight:

msbuild Merlin/Main/Languages/Ruby/Ruby.sln
  /p:Configuration="Silverlight Release
  /p:SilverlightPath="C:\Program Files\Microsoft Silverlight\2.0.40115.0

You can also build IronPython for Silverlight in a similar manner. Aliases for this will be added soon, but if you need a custom build of the DLR languages for Silverlight, this is the way to do it.

Samples

Six samples are included in this release. The first three are desktop samples in the “/samples” directory. The last three are Silverlight samples in the “/silverlight/samples” directory:

Tutorial - An interactive IronRuby tutorial
IronRuby example - Tutorial

DiskUse - A small WPF application which visualizes the disk usage for a particular directory
IronRuby example - Disk Usage

IRPowerShell - a small library and sample applications showing how to interact with PowerShell from IronRuby
IronRuby example - minsysreq

Clock – a simple Silverlight sample
IronRuby Silverlight example - Clock

Photoviewer – do AJAX programming with IronRuby (ARAX =P)
IronRuby Silverlight example - photoviewer

REPL – Interactive console in the browser.
IronRuby Silverlight example - REPL

Some more interesting changes:
  • Improved DLR Interop: adds support for GetMember/SetMember with method_missing, Binary/Unary operators, and indexers.
  • Handling of CLR protected and private methods and properties
  • Reimplemented File.expand_path such that it does not use System.IO.Path.
  • This allows us to get better compatibility with MRI. The motivating reason was
  • that RSpec does File.expand_path("filename:linenumber")
  • Improves the implementation of singleton method dispatch.
  • These changes improve running time of specs significantly (2x)
  • Renames Method, UnboundMethod#overloads (plural) to
  • Method, UnboundMethod#overload (singular).
  • The old name is still available for now and throws an exception.
  • Implements adaptively compiled rules
  • Improves performance of Array#- from quadratic algorithm to linear.
  • Improves implementation of RubyArray
Bugs closed

Here are all 37 bugs closed since the last release (2009-05-19). You can see more information about each one on CodePlex.

1521  Access is allowed to internal fields
1502  alias_method fails for :do
821   File.expand_path does not support a line number after filename
1509  Proc.to_s should include line number where the block was declared
1501  WinForms broken
1400  $? is not always Process::Status	
1345  load_assembly() should work
1344  System.Action.new does not work
1306  Cannot call CLR constructor of builtin type
1184  public(:foo) does not work correctly for mixed-in methods
1085  Cannot call new on subtypes of builtin classes whose "new" method has optional arguments
1060  visibility of send :define_method
917   Passing a Ruby array to a .NET method that expects an IEnumerable derivative fails with GetEnumerator call
783   Assert in SetMethodBasesNoLock when calling #== on Ruby class inheriting from CLR class which overrides Equals
761   Wrong behavior when calling redefined methods on object instances
1470  Can't call the BigIntegerOverload of a method with a DefaultProtocol Attribute on the BigInteger attribute
1426  The located assembly's manifest definition does not match the assembly reference. (ctp dev10 beta1)
1441  Error with cyrillyc text in Sharepoint	
1352  Test Defects	
814   Allocator underfined for  (TypeError)
572   Error when running Cucumber examples with IronRuby
718   IronRuby ignores RUBYLIB environment variable
727   to_proc not working
1351  redist-libs should have rubygems-1.3.1	
466   ''.split(//, -1) returns [""] instead of []	
940   Can't inherit from abstract classes	
1028  Missing conversion from Duration to Fixnum (ActiveSupport)?
374   irails Foo: undefined method for OpenSLL::Random.random_bytes
459   throw FileNotFoundException => rescue Errno.NoEntryError
499   Pathname#cleanpath messes up the pathname
467   "igem install rails" fails
375   "ir script\server" causes a YAML parser error
461   Generic type conversion from Fixnum to Integer
674   autoload does not use File::SEPARATOR
1021  Time class instance
578   yield fails in eval'd code
605   Array#hash should properly handle recursive arrays
Enjoy!

Please test out IronRuby 0.6 and let us know if you have any issues. We hope you enjoy this release!

-- The IronRuby team

Monday, June 29, 2009

Simple Python testing in Silverlight with unittest

Since doing a post about Ruby testing of Silverlight applications, I’ve felt a bit guilty about leaving Python fans in the dark. However, like Ruby, it takes very little work to run Python unit test frameworks in Silverlight, since IronPython is a very compatible implementation of Python. Though my results aren’t as exhaustive as the IronRuby examples, here’s one simple example:

http://github.com/jschementi/europycon2009

zip download

unittest-sl

The original example is from the Python website’s unittest documentation. Very little bootstrapping is required to get this running in Silverlight; this is u1.py code that is the start-script for the Silverlight app, which runs the tests:

I did have to make a modification to unittest.py; removing a call to sys.exit since Silverlight doesn’t support that, and just returning the exit code.

There’s also a GUI test runner (http://pyunit.sourceforge.net/pyunit.html#GUI), so it might be interesting to port that to Silverlight to get a nicer test run graphic along with the console, but it’s great that the REPL enables this to just work =) It also helped me find some bugs with the REPL, which will make their way to the IronPython source code shortly.

Let me know how it works for you. The next step is to tackle testing Silverlight C#/VB apps with Python.

Technorati Tags: ,

Tuesday, June 23, 2009

“The” IronRuby Tutorial

Hidden in yesterday’s commit to IronRuby’s GitHub repository is evidence of some polishing changes to the IronRuby tutorial app, which I’d like to introduce to you peoples:

ironruby-tutorial

To run yourself:

  1. Get IronRuby from GitHub and build it (in release mode preferably)
  2. cd Merlin/Main/Languages/Ruby/Samples/Tutorial
  3. ir.exe wpf_tutorial.rb

Isn’t he/she/it a bute!? This app makes Ruby-based tutorials interactive, guiding you through the material with a IronRuby REPL console and other visual aids such as another window, or whatever the tutorial writer sees fit. There is also a tutorial runner for the command-line, and a exporter for static HTML.

The IronRuby tutorial included covers topics such as using the interactive window, built-in libraries, exploring .NET libraries, generics, events, Windows Forms, and Windows Presentation Foundation.

While the tutorial is currently no where near a complete guide to IronRuby, it’s a great place to get started. Also, the first two chapters of the TryRuby tutorial is included as well for testing reasons, but may or may not be ever finished … unless someone wants to make it work, more on how to do that later.

But it can teach all by itself!

While the content of the tutorials can be awesome, and this app can teach the material very efficiently, it can never teach the real experience of building an app in IronRuby. So the IronRuby tutorial app is written in IronRuby as an example of doing all the things a tutorial can’t. Wow, very meta.

Currently, the tutorial app itself covers:

  • User Interfaces in Windows Presentation Foundation
  • Ruby as Data: the tutorial domain-specific language
  • Testing a Ruby application with test-spec
  • Developing a GUI application interactively
  • Anything else we can cram into it in the future :)

These area will be covered in a series of future posts, so keep an eye out for them!

Still plenty of work to be done

This app is far from done, so the exploration of IronRuby in WPF has just begun. Here are some known issues, so don’t complain about these =P

  • The REPL doesn’t have any history via up/down arrow keys.
  • The “Jump to another section” menu scrolls too much. This list can only be two items deep, so it's needs to change to arbitrary depth to have more nesting.
  • The content isn’t totally complete, though the IronRuby tutorial is in great shape. If you have suggestions on topics, please let me know.
  • Jumping between tutorials a bunch makes the memory usage increase to Rails-like proportions (160MB). Not sure why yet. :(
  • The code isn’t the best, but it works. =P I’ll be reorganizing it in future posts about client development, but it serves its purpose for now.

Of course there are a ton of other things that could be done. See the TODO file for some ideas.

Please try it out and let me know what you like about it, what you don’t like, and feel free to futz around with the code as well … contributions are welcome. Enjoy!

Technorati Tags: ,,

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

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!

Tuesday, April 14, 2009

Lang.NET 2009

Today is Lang.NET 2009!

Lang.NET Symposium 2009 is here! A gathering of language geeks, users and implementers alike; an awesome cross-section of developers.

There is a awesome assortment of topics scheduled, from Google Chrome’s V8 JavaScript engine to a bunch of F# talks, and a ton more awesome talks that can be seen on here:

http://langnetsymposium.com/2009/agenda.aspx

Jason Zander is setting up now, and we’re about 10 minutes away from starting, so I’m excited! Videos of the talks will be posted as soon as humanly possible, so keep an eye on the website for video links.