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!

Top 10 Commands In Your Shell History

Saw this post on objo’s blog, apparently it’s a meme of some kind, though his was the first I’ve seen.  But I thought it was pretty cool none the less.  Here’s mine:

$  history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn
| head
114 cd
84 ls
79 irb
39 git
31 pedump
10 ps
10 objdump
10 e
8 ssh
8 dd

You can see a bit of my dual developerness there, irb and git for ruby, and pedump and e for the windows side (this is in cygwin).  What does your shell history have to say?

Cleveland Day of .NET: May 17, 2008

badgeEarlier today the website went live and registrations started. What is a “Day of .NET”? And why is it happening in Cleveland? A “Day of .NET” is, as the Day of .NET website says, “a one-day conference on all things .NET organized by developers for developers.” And that last part is why it’s happening in Cleveland. A number of us have frankly been tired of nothing happening in the Cleveland/North East Ohio area, and decided to take the bull by the horns as it were.

One of the themes we’re trying to push is that Day of .NET is .NET centric, but not .NET exclusive. So we’re hoping to bring a few speakers from other worlds (Java, Ruby, Python, etc) and learn from them. As well as explore a number of the exciting new things coming out of Microsoft these days (like the DLR, Silverlight, et. al.).

Interested in speaking? Contact speakers@clevelanddodn.org. Want to sponsor or know someone who would want to sponsor? We got lot’s of logo space to fill up, just contact sponsors@clevelanddodn.org. Most of all, get to www.clevelanddodn.org and register!

Detroit Launch Event, Post Event.

 

Tuesday (3/18) was the Microsoft Launch event in Detroit.  Being the intrepid geek I am, I decided to take a road trip and go to the event 3 hours away, rather then the one in the same town a week earlier.  Madness you say?  Nay, for I got to enjoy the good company of Corey Haines and Nate Hoellein on the way there and back as we car polled together.  While leaving at 4:30am was a bit rough, the drive was worth it once we got there.  I got to interact with a slew of smart people that I get to see far to rarely.   Dustin Campbell has a good list of everyone I ran into there (don’t worry Dustin, your secret of feeling up Jeff at lunch is safe with me).

The event du jour however was by far the Geek Dinner put on by Keith Elder, and generously sponsored by the Microsoft Visual Studio Team System..err. . Team.  If you’re ever in downtown Detroit and looking for some killer deep dish and wings, I can’t recommend PizzaPapalis enough.

After a cold beer and some hot pizza, it was time to take the long haul back to Cleveland.  Corey did a fantastic job getting us through the fog alive, and by the time I hit the bed around midnight I was more then ready for sleep. 

Announcing Zliby — All Zlib, Pure Ruby

A few weeks ago Dr. Wayne Kelly posted on the IronRuby mailing list the set of libraries and methods that had to be implemented in order to perform a rubygems setup.  This is an important first step towards full rails support.  I volunteered to take on the task of porting the Zlib library.  I thought, why not implement it in pure Ruby, that way there would be no external dependencies.  It would have to be API compatible with the ruby-core Zlib implementation, so it could be used in place of the natively compiled libraries. 

After about a week of hacking on it, I’ve decided to make the initial public release of Zliby.  Right now the only thing that’s implemented is Zlib::Inflate’s inflate functionality and Zlib::GzipReader’s read functionality.  Eventually all of the ruby-core Zlib API will be implemented, and I hope to add other compression support going forward.  Before you ask, yes it’s slower then a native implementation, but it’s portable, and has not be optimized for speed in any way yet.  Also, since it’s being developed for use in IronRuby, there are a few constructs that I can’t currently use (Array#pack for instance) though I will be able to in the future. Comments, feedback, and suggestions welcome!

Links:

Zliby Project at RubyForge

Ruby-Core Zlib API Docs

Zlib Homepage

MbUnit, NCover, and TeamBuild Living Together, Mass Hysteria!

 

Recently I’ve been asked to make a case for using something other then MSTest, one of the arguments against using an xUnit framework was the lack of integration to Team Foundation Server.  Well, I took it upon myself to show that MbUnit and NCover could perform just as well in a TeamBuild environment.  Here’s how to get it all working.

First you’ll want to get MbUnit, NCover (1.5.8), NCoverExplorer (1.4.0.7) along with it’s Extras (1.4.0.5),  Note that NCover and NCoverExplorer are no longer free, but their past version were and are still available free of charge, just without official support.  They work quite well though!

Next you’ll need to edit the proj file for your unit tests, near the top of the file, enter some UsingTask directives for NCoverExplorer:

<UsingTask TaskName="NCoverExplorer.MSBuildTasks.NCoverExplorer" AssemblyFile="..\libs\NCoverExplorer.MSBuildTasks.dll"/>
<UsingTask TaskName="NCoverExplorer.MSBuildTasks.NCover" AssemblyFile="..\libs\NCoverExplorer.MSBuildTasks.dll"/>
<UsingTask TaskName="NCoverExplorer.MSBuildTasks.NUnitProject" AssemblyFile="..\libs\NCoverExplorer.MSBuildTasks.dll"/>

As you can see, I’m using a relative path to the MSBuildTask assemblies, you can put in whatever path you need, but there are good arguments for keeping your testing frameworks in the same project directory structure as your unit tests.

Near the bottom uncomment out the <Target> section with the name of "AfterBuild", this is were we’re going to tell our build system to run our tests and coverage analysis.

Remember we’re going to be doing TeamBuild, but we’d still like it to work outside that environment for local use.  So let’s add a couple of property groups that set up some variables for us depending on our build environment:

<PropertyGroup>
	<CoveragePath  Condition="'$(DropLocation)' != ''">$(DropLocation)\$(BuildNumber)\$(Configuration)\CodeCoverage</CoveragePath>
	<CoveragePath  Condition="'$(DropLocation)' == ''">$(TargetDir)\CodeCoverage</CoveragePath>
	<TestPath Condition="'$(DropLocation)' != ''">$(DropLocation)\$(BuildNumber)\$(Configuration)\TestResults</TestPath>
	<TestPath Condition="'$(DropLocation)' == ''">$(TargetDir)\TestResults</TestPath>
</PropertyGroup>

<PropertyGroup>
	<CoverageFile>$(CoveragePath)\Coverage.xml</CoverageFile>
	<TestReport>TestResults{0}{1}</TestReport>
</PropertyGroup> 

 

As you can see here we check to see if DropLocation is set and if it is or isn’t determines where we’re going to place our test and coverage reports. Next we’ll simply add some tasks to setup directories and actually run NCover and NCover explorer:

<MakeDir Condition="!Exists('$(CoveragePath)')" Directories="$(CoveragePath)" />
<MakeDir Condition="!Exists('$(TestPath)')" Directories="$(TestPath)" />

<NCover CoverageFile="$(CoverageFile)" CommandLineExe="C:\Program Files\MbUnit\mbunit.cons.exe" CommandLineArgs='"$(TargetPath)" /rf:"$(TestPath)" /rt:HTML /rnf:"$(TestReport)"'  />

<NCoverExplorer
	ToolPath="C:\Program Files\NCoverExplorer"
	OutputDir="$(CoveragePath)"
	XmlReportName="CoverageSummary.xml"
	HtmlReportName="CoverageSummary.html"
	CoverageFiles="$(CoverageFile)"
	ShowExcluded="False"
	MinimumCoverage="75"
	SatisfactoryCoverage="80"
	Exclusions="Assembly=.*Tests.*"
/>

And that’s it really, when you build via a TeamBuild, local MSBuild, or even from Visual Studio, you’ll have two extra directories in your output location, CodeCoverage and TestResults, in there you’ll find nicely formatted HTML reports informing you of tests and code coverage.  If any tests fail then the build will fail, if code coverage doesn’t meet the minimum your build will fail.  NCoverExplorer’s build task has an option called "FailMinimum", if you set this to false then the build will succeed even if your code coverage doesn’t meet the "minimum".  With TFS 2008’s "build on check-in" feature, you start to see possibilities here.  With the NCover and MbUnit reports having xml equivalents the reporting/analytic possibilities are endless. 

Welcome to the new digs!

Make yourself at home… I’m still unpacking a bit, but expect new posts very soon!