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: ,,

4 comments:

Miroslav Paskov said...

I just finished the tutorial and it did get me hooked :)

IronRuby has come a long way since I last played with it. Great work!

Just couple of observations:
1. The FileSystemWatcher part did not work for me. I did not get an error, but no notification for the file creation either. I did check that I was creating a file in the Path.get_full_path('.') folder.

2. Could enums be resolved without having to specify the full type with System::SomeEnum.some_value? Something like :some_value will be more suitable IMO. I imagine that it will be easy to map it to the correct enum value if it is set to a typed property.

3. I really liked the calculator. A thing to note here though is that there was an exception that killed the Calculator, tutorial and ir console at once. It happened after I entered 5313// or something like that.

BTW, I also just discovered your blog. Amazing stuff!

I will look into the testing now :)

niclasnilsson said...

Hi Jimmy!

I have a problem getting the tutorial to run. All dependencies seems satisfied and the wpf_tutorial.rb runs without showing any problems.

However, the windows that comes up has a border and a title ("IronRuby Tutorial"), but the windows itself gets no content, and the content area is actually transparent. At this state, it "hangs" forever (or waits for input, but I wouldn't know).

I tried the DiskUse app as well, and it behaves similar. The "Choose directory" shows up (looks normal) and the title bar on the disk usage window changes text as it's workning, but the content area is just transparent.

Any idea what could be wrong? I've developed WPF apps in Visual Studio (C#) on this (virtual) machine before and that works.

Kind regards
Niclas Nilsson

---
blog: http://niclasnilsson.se
twitter: http://twitter.com/niclasnilsson

niclasnilsson said...

Ah, 2 minutes after I "gave up" and posted the question here, I found the solution (the Rubber Duck syndrom perhaps).

In VMWare Fusion under OS X, I didn't run Windows in full screen (not Unity either, just a normal window), and that's obviously what caused the problem. Switching to full screen made it work. Odd? But at least a workaround.

Kind regards
Niclas

---
blog: http://niclasnilsson.se
twitter: http://twitter.com/niclasnilsson

Karnautrahl said...

Sadly I can't find an answer to this, and I'm too newbie at Ruby to fix it.

./app/gui_tutorial.rb:87: syntax error, unexpected ':' when ::Tutorial::Section: select_section item

Can you help?