Archive: June, 2008

Boy Howdy! The Elder and Woody Get It On!

There’s a new podcast in town y’all, and wooeee is it good. (A little Southern lingo for you there).  Keith “The Elder”  Elder and Chris “Woody” Woodruff, two extremely smart gentlemen who I have the honor of knowing, have recently begun podcasting about Development and Technology with a Southern TwangThe title and theme of this endeavor?  Why, Deep Fried Bytes of course!

The first episodes are based at the MVP summit that took place in April.  From a discussion on what interface a Chicken should implement to lay eggs (my vote is for IEggLayer) to extolling the Power of Twitter, each episode has been filled with warm humor and good information.  The passion they, and their guests, have for technology really comes shining through.  Leaving you with a contented, full feeling, similar to eating a good bucket of wings fresh from the deep fryer.

The production values are surprisingly high for such a new podcast.  Even though the podcast is only 3 episodes old (really two, the intro one almost doesn’t count ;) ), you would think these guys have at LEAST 10 episodes under their belts, minimum.  And there has been steady improvement. In the first episode or two, Woody sounded much quieter then Keith, by the third episode that’s been resolved.  The new intro from Elly Mae is top notch, leading you in that this is a serious (but not too serious) affair. The last episode shows a marked improvement in over all production (though you can tell they are still playing with editing, in the beginning there are parts where it sounds "clippy").  If better is yet to come, you’ll find me there!  And now that they have a sponsor, the future is looking bright.

So come on down, take yer shoes off, and pop a squat with the Paula Deens of Podcasting!

Links

Speaking at eRubyCon

Just a heads up to my faithful readership, I’ll be speaking about IronRuby at erubycon this August.  It’ll be my first  public speaking engagement at a technical conference, and my first real public speaking since High School (in-house presentations don’t count in my book).  I’m quite nervous but it’s a topic I’m passionate about so I’m really excited as well.  The title of the talk is "Because Iron is Battleship Gray: IronRuby In The Real World", and it won’t mention Silverlight or Rails.  Ruby is so much more than glitz and glam, and I think that tends to get lost in the hype.  She’s a sexy lady, but she’s got brains too!

Hope to see you there!

IronRuby QuickStart ReDuex

Back in January I did a post on getting started with IronRuby.  That post was based on Rev. 75 of the SVN tree.  As of  today (June 9th) the SVN tree is up to Rev. 113.  Obviously with things like RailsConf and TechEd driving a lot of the core teams work, a number of things have changed since January.  This post will basically be a rehash of the previous one, but updated for all the new quirks that have been introduced.

Getting The Source

As before, I recommend using TortoiseSVN to grab the source. Downloading will take a bit, after the 3.5MB of source is downloaded you should end up with a directory structure like the following:

image

Compiling IronRuby

Inside of the trunk directory you will find the IronRuby.sln file, double-clicking it will open the solution (note that the solution file is now in VS2008 format instead of the previous VS2005 format).  You may get a warning, you can select “Load the Project Normally” and uncheck “Ask me this for all projects in the solution.”

Once the solution is loaded, keep the solution on the “Debug” configuration.  Do NOT select “ExternalDebug” (you’ll get broken references if you do):

image

Next we will manually remove the “SIGNED” compilation symbol from all the projects, as of Rev. 113 you have to manually remove it from the IronRuby.Libraries, Microsoft.Scripting, and Microsoft.Scripting.Core (be sure not to delete the DLR symbol) projects.

image

Once those are removed you can build the source!

Running That Which You Have Wrought

Where has previously our compilation would output into a bin\Debug folder, the resulting files are now found in \trunk\build\debug, which should look like this:

image

Due to a conflict with rubinius, the rbx executable is now ir.

As before you can just run ir.exe and enter the wonderful world of ruby, or you can continue on to see how we roll in the .NET world.

Speaking C# With A Ruby Accent

The initial steps are basically the same as before, start a new C# console project and add references to Microsoft.Scripting.dll, Microsoft.Scripting.Core.dll, IronRuby.dll, and IronRuby.Libraries.dll.

We are going to create a simple console app that shows passing variables into and out of a ruby script.

The below program should be a good example:

 


using System;

using Ruby;

using Microsoft.Scripting.Hosting;
namespace IronRubyConsoleApp

{

    class Program

    {

        static void Main(string[] args)

        {
ScriptRuntime irruntime = IronRuby.CreateRuntime();

            ScriptEngine ir = IronRuby.GetEngine(irruntime);

            ScriptScope scope = ir.CreateScope();

            ScriptSource script = ir.CreateScriptSourceFromString(“puts \”Hello, #{name}!\”\ninput + 2″);

            scope.SetVariable(“name”, “.NET”);

            scope.SetVariable(“input”, 2);

            int x = script.Execute<int>(scope);

            Console.WriteLine(string.Format(“The Result was {0}”, x));

            Console.ReadLine();

        }

    }

}

You can see a clear hierarchy here:

We have a Runtime

That has an Engine

That has a Scope

That has a Source

We create a runtime, and we get our IronRuby engine into the runtime, we create a scope and load a script using that engine.  Set a couple of variables in the scope and then execute the script within the scope that we have set the variables in.

Hopefully this is enough to get you started, you should probably check out the other CreateScriptSource methods that the engine contains, you have a veritable cornucopia of options:

image

Ruby with a .NET Accent

Another of the popular activities with IronRuby, if not the most popular, is going to be interfacing with both the .NET framework and other .NET code.  The below example shows us interfacing with System.Windows.Forms and making a simple GUI app.

 

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’ Swf=System::Windows::Forms Sd=System::Drawing class RubyForm <Swf::Form def add_button text, location button = Swf::Button.new button.Text = text button.Location = location self.Controls.Add button button end def initialize self.Text = “RubyForm” @rbutton = add_button “Click Me!”,  Sd::Point.new(150, 150) @rbutton2 = add_button “Click Me!”, Sd::Point.new(150, 100) @rbutton.Click {|sender, e| Swf::MessageBox.show ‘Hello World!’} @rbutton2.Click {|sender, e| Swf::MessageBox.show ‘Hello, .NET!’} end end rf = RubyForm.new rf.ShowDialog

As you can see above, when requiring items from the GAC we must include the Fully Qualified Name, including version and StrongNameToken if applicable. The above code inherits from System.Windows.Forms.Form and adds a helper class for adding buttons and wires up a couple of event handlers.  Again this is just a simple example to get you started.

Summary

In this post we downloaded the IronRuby source, compiled it, and worked with IronRuby both from C# and by running a ruby script against .NET objects.  Hopefully this gets you going a little faster and onto the fun stuff quicker!

Links

IronRuby Homepage

IronRuby RubyForge Project

Ruby Language Homepage

John Lam’s homepage

How I Got Started In Software Development

Michael Eaton started it, and others took off and ran with it.  Now it’s a certified meme. So I guess I might as well join in the fray and relate the beginnings of my geekdom.

A Long, Long Time Ago…

How old were you when you started programming?

I was about 7ish when I first started. Read on for more details…

How did you you get started in programming?

When I was around 7, my uncle had an Atari 400.  I initially just played games on it, but one day I noticed a stack of Byte magazines in the corner.  Inside this magazine was source code, it said it was “BASIC” and needed to be typed in… hmm.. there’s this Atari-BASIC cartridge, and there’s a keyboard.  A light went off, I can make this machine /do/ something?  So I typed in the program, saved it to the cassette drive, and then tweaked it.

Next thing I know I’m begging my parent’s for a computer.  For my 8th birthday I got an Atari 65XE and a couple of BASIC games books, and I’ve been totally hooked ever since.  Time passed, and eventually I got into things like QBASIC, DOS Batch, and C/C++ (via an old copy of TurboC a friend loaned me).  Then in high school someone gave me a Linux CD and having a whole slew of development tools really helped.

I just kept hacking away…

What’s the most fun you’ve ever had … programming?

Staying awake for 48 hours straight and hacking an ANSI art viewer in C with Jim Balcomb.  We were probably 15 and 16 at the time and just didn’t need to rest when programming was to be had.  I think it’d kill me today.  Oh yeah, and then I delivered papers in the morning after being jacked up on coffee and Jolt and my father was convinced I was on speed…

Googoo gah gah?

What was your first language?

Well it was BASIC obviously, from Atari-BASIC, to BASICA, to QBasic, eventually to QuickBasic…

What was the first real program you wrote?

One that really stands out was a grading program I wrote in high school for the Learning department at the school.  It was all done in QBasic and had menus that were keyboard driven, grid data entry, and a printing subsystem.  I wish I still had that code…

What languages have you used since you started programming?

Define use? Here are all the languages I have written something of some complexity in:

  • AutoIT (don’t ask…)
  • Bash Shell
  • BASIC (variations there of)
  • C/C++
  • C#
  • DOS Batch
  • JavaScript
  • PHP
  • Ruby
  • TSQL (don’t ask)

..and [Insert Deity Here] knows what else…

Get a good job with more pay and you’re okay.

What was your first programming gig?

I’ve always loved programming, and have been doing it has a hobbyist since as far back as I can remember.  However, without experience (and never having finished college) I was never able to really get a foot in the door.  I worked in support at Harley-Davidson Dealer Systems for 6 years and had a chance to do some development work (I had written a number of utilities for support including SetPrinter) I jumped at the opportunity.  I actually took a “demotion” from Team Lead to Developer for the chance.

After a couple years of doing development work there I had pretty much tapped out all I could do and was stuck, that’s when I was introduced to PreEmptive Solutions and am currently doing development there.  My work at PreEmptive is much more like a “real” development job then HDDS.  At HDDS I was pretty much a cowboy left on my own.  Here I’m working with a true development team.

If you knew then what you know now, would you have started programming?

Oh hell yes, I truly believe I was born to be a computer programmer, I can imagine doing nothing else.

If there is one thing you learned along the way that you would tell new developers, what would it be?

RTFM.

Thanks Mike!

A big thank you to Mike Eaton for getting the ball rolling on this, it’s fascinating to see how my fellow tweeps and hackers got started.  I’m not going to “tag” anyone, because that’s silly, but I do encourage anyone who reads this post to do the same and link back to mike’s blog, he’s keeping a list of people responding!