Scott Hanselman

John Lam presenting at PADNUG on Thursday

July 23, '07 Comments [1] Posted in Programming | Ruby | Silverlight | Speaking
Sponsored By

Just to make sure you're getting the full court press on IronRuby, if you're NOT at OSCON (the O'Reilly Open Source Conference), but you are in the Portland/Southwest Washington area you'll be interested in this little tidbit.

John is presenting on IronRuby at OSCON on Thursday at 5:20pm, but just afterwards he'll come by Corillian and speak to us at PADNUG, the Portland Area .NET Users Group (details on Rich's Blog).

"John Lam, creator of RubyCLR, will discuss IronRuby, an implementation of Ruby on the .NET platform that will be released under the MS-PL licence (BSD-style license). We will look at the implementation of IronRuby on top of the recently announced Dynamic Language Runtime to better understand how the DLR deferred compilation model can be used to obtain excellent performance and cross-language interoperability. We will also look at different scenarios where IronRuby can be used, including the recently announced Silverlight platform."

The presentation will start at 6:45pm with Pizza and Socializing at 6:00pm. Click the image for Driving Directions. The meeting will be in the small middle building (the café). Hope to see you all there.

Technorati Tags: , ,

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

WPF Sample in IronRuby talking via C# to Wesabe

July 23, '07 Comments [12] Posted in eFinance | Programming | Ruby | Web Services | XML | XmlSerializer
Sponsored By

wesabeironrubymoney John Lam and team have released their first drop the IronRubySource code. It's super-pre-alpha so don't hate, but it's looking pretty sweet, if you're a burgeoning Ruby-head like myself. There's incomplete support for some of the cooler Ruby syntax things, but I have full confidence that it's only going to get better. All the underpinnings are there.

John also announce that the team will host IronRuby source on Rubyforge (which is quite the coup, actually) and that they'll be taking external contributions very soon (this being the open part of open source.) 

Not every sample (initially) will look and feel and smell good like Ruby, and this one is no exception. You might remember that last week I did a quicky Wesabe client in C# and put it up on Google Code. We've got four folks up there improving the code, which is cool.

Today, Shady the intern and I decided to do a sample in IronRuby that would call the C# Wesabe client API and display some account data via WPF. This is part of my new plan to take over Money and Quicken's business and you can tell from the hours of intense UI design that Shady and I did, that my plan is inevitable.

We started from ScottGu's HelloWorld sample, and slogged creatively coded our way forward. Here's how it went.

imageFirst, get the IronRuby source and upzip. Open on Visual Studio 2005 command prompt and compile the DLR and IronRuby by running build.cmd.

All the interesting stuff will show up in bin/release, including the IronRuby equivalent of IRB, the interactive Ruby Interpreter.  You can run this from the command line and try things out interactively if you like.

We used Notepad2 with Ruby Support for our editor, although I'm deeply digging "e" the TextMate for Windows and will likely move over to it for my text editor of choice when I start at Microsoft in September.

Next, we tried to add a require statement to bring in the Wesabe library. You run a IronRuby app (today, in this build) by running rbx.exe YourApp.rb. We put our .rb text file in one folder and had rbx.exe in another, so when we added our wesabelib.dll we had to add it to the same folder that rbx.exe was in, otherwise the Assembly load would fail. You can also put things in the GAC and get to them there. Just remember that Fusion will load from the same folder rbx.exe is in, not the folder that your program is in.

For debugging, we used the classic "got here" debugging of old, via the standard MessageBox, so we added a requre for Windows Forms also and a constant as a alias for the MessageBox class:

require 'System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'
require 'wesabelib, Version='
MessageBox = System::Windows::Forms::MessageBox

As this build is a pre-Alpha, likely created in the dark of the night just hours ago, there's all sorts of weirdness and stuff that didn't "just work."

The naming integration with .NET is persnickety at best. The C# Wesabe client had a lowercase class called "wesaberest" that IronRuby just couldn't see, so I changed it to uppercase and aliased it with a constant.

#this build of IronRuby doesn't like Class Names that are lowercase,
# so I made mine Uppercase
Wesabe = Wesaberest

As I said, The Wesabe client API that we created is written in C#, and returns a array of Account objects. In the click event of a button, we pass in the username and password from our TextBox and PasswordBox respectively and store our Account object.

Our goal is to spin through the list of Account objects in the Array, but there's a few gotchas, again because of the pre-alphaness. First, we can't use for because in Ruby for is a sugar syntax on top of "each" that assumes an each method exists. Each isn't implemented yet, but the plan is to have for syntax just work over IEnumerable things.

Second, we can't index into arrays because the [] operator isn't implemented yet, but we can call GetValue(), which is the same thing.

#in the future we'll be able to index into CLR arrays...
#oneAccount = myAccounts[i]
oneAccount = myAccounts.GetValue(i)

Thirdly, in IronRuby there's FixNum, which is a DLR extension of Integer and there's MutableStrings, that have private StringBuilder. A lot of this will be hidden in the future, but in this build I had to be aware of some of the impedance mismatches as I tried to coerce my numbers into strings for output.

For example, none of these worked, but I expect they will one day.

Lastly, currentBalance is a float (System.Single) and IronRuby wouldn't respect it's ToString method, so I changed the value to a System.Double and all was fine.

Here's some failed attempts at String Concatenation. Notice the "secret" call to to_clr_string. Those should all go away and the Ruby types should marshal cleanly in most cases. Note that I'm assuming a lot, and in some cases basing these assumptions on my chats with John, but also as educated guesses as to how it ought to work.

#Ruby string concatenation works fine...
my_message.content = "scott" + " hanselman"

my_message.content = + oneAccount.currentBalance.to_string("C").to_clr_string

my_message.content = + "$" + oneAccount.currentBalance.to_s.to_clr_string

my_message.content = System::String.Concat("$" + oneAccount.currentBalance.to_s.to_clr_string)

#There's a name conflict when trying to use the StringBuilder:
# System.MemberAccessException: uninitialized constant ScriptModule::Text
s =
my_message.content = s.to_string

At this point, I just added a new property called "DisplayString" in the Wesabe Account class and moved on. As for the loop we used a while. It's not clean, but it's clean enough: do |sender, args|
   a = Wesabe.getAccounts(text_user.text,text_password.password)
   myAccounts = a.Items
   i = 0
   while (i < a.Items.Length)
      oneAccount = myAccounts.GetValue(i) #GetValue is on System.Array

      i+=1 #needed for the while
      # Create new label
      my_message =
      my_message.font_size = 36
      my_message.content = oneAccount.DisplayString

      #Add the Label to the ListBox

There's a couple of ways to make this even more clean, and those ways will come. I'll update this sample as the new features roll into IronRuby.

I think it'd be nice to add some charts and graphs, make the whole thing a ClickOnce app, etc. Probably, for now, it'll be easier in C#, but it was fun to hack it together in today's drop of IronRuby and the interns learned something.

You can get my source for this Ruby App, along with a custom build of the Wesabe client (with my changes) here. Remember to get the IronRuby source, compile it, then copy the Wesabe client to the bin\release folder (or move the .rb files into there along with the Wesabe dll). I've left all the comments in the source for fun.

Technorati Tags: , , , ,

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Blue Badge

July 21, '07 Comments [177] Posted in Musings | Microsoft
Sponsored By
imageI'm going to work for Microsoft. There, I said it. I'm going to work for ScottGu's team in the Developer Division.

Someone once showed me a diagram that looked something like the one at right. Most of us spend our time over in the red circle doing stuff someone will pay us to do. If you're lucky, you spend your time in-between them, doing stuff you're good at also. Sometimes something comes along that puts you right in that sweet spot and you have to go for it. Will this be my dream job? Could be, I don't know, but if it's not, it might get me a lot closer.

What's this mean for this blog and the podcast?

Fortunately, nothing. The blog is still mine. The podcast is still Carl's and mine, and while having a Blue Badge will get me access to more interesting people to interview (Hopefully some smarties in Microsoft Research. Maybe Bill, or that elusive Ray Ozzie interview...he's only turned me down twice, and he was very nice about it) as well as, hopefully, some exclusives. I'm still going to talk about what I want to talk about. ScottGu and team were very cool and explicit that the blog and podcast are mine.

Will the voice of this blog change?

If it does, then I'm doing something wrong. I've been an advocate for some things Microsoft for years, while other things, not so much. That's why I'm going to work for the DevDiv (Developer Division) and not Marketing. I might be a fanboy, but I'm not evil.

All the blog stuff, the articles, the podcasting, screencasts, etc, that I've done over the years have been done on my own time, usually very late at night for no money save what I can get from Google Adsense and a few advertisers that pay for my hosting.

When someone is a starving artist, they paint for the love of it. They starve, and paint, and starve and paint, and lament that no one will pay them for their art. Then one day, a benefactor comes along and says, "You're brilliant! I'll give you $ if you paint me 10 more just like it, with these small changes, and have those done by Tuesday, m'kay?" And the painter sometimes regrets it. Everyone that I've talked to has been totally up front and cool about things and while my job will be to Spread the Good Word, it's not like I wasn't already doing that anyway. However, no one will be editorializing my content and I'll likely get into trouble occasionally.

What's my job?

The HR title is a nice generic one like "Program Manager" (I was thinking to get this on my business card - Scott Hanselman - progman.exe, what do you think? ;) ) but in essence I'm going to talk about .NET and Visual Studio - the whole of DevDiv, including ASP.NET, WinForms, WPF, Silverlight, CLR, LINQ, IIS, DLR, .NET CF, everything. This means videos, screencasts, podcasts, maybe some Channel 9 stuff, doing articles, wikis, speaking at conferences and large events (invite me!), creating starter kits, samples, as well as my regular hobby of plugging things into other things. I'll also be working on understanding our community (that means you, Dear Reader) thr  ough conversations, visits, and trying to bring some big picture analysis (the kind of stuff I do now, again) to the .NET 3.5 and .NET Futures stack. I am also obsessed with getting my new Apple Newton Messagepad 2000 to sync with Outlook 2007, so watch for that.

What about Corillian/Checkfree?

The combination of CheckFree and Corillian promises to change the way people manage their money online, and I gave careful and serious consideration to the opportunities I had to continue to contribute to that vision. There's rarely a good time to leave a company, especially one that you love, but this was as close to a "it's not you, it's me" kind of breakup as one can have. I've been spreading the Computer Zen on the side for five years now. I've been speaking as part of INETA, doing the MVP and RD thing for years. While there's huge opportunity at Corillian/Checkfree right now, the bosses (and my friends) made it clear that I could be a big part of the future, this opportunity just happened (at Foo Camp, actually) to come together in such a cool way that I decided I wanted to move out of my comfort zone and take a leap of faith.

I've grown to know ScottGu and many of the folks in MSFT Building 42 and have decided that they are good people. Sure, there are some odd decisions that are made in the big house, but now I'll be on the inside, trying to make sense of them, and hopefully I'll be able to influence things for the better.

What's next?

HanselborgStewardship is defined many ways, but I like these two:

"Taking responsibility for the survival and well-being of something that is valued, such as a natural resource" and "an individual's responsibility to exercise care over possessions entrusted to him or her"

If you trust me, you know that I'm not evil, and that I'm going to Microsoft in order to bring additional trust into the relationship between developer and platform. There needs to be a sense of stewardship and a deep valuing of the trust that developers put into their tools.

All this said, I've gone ahead, Dear Reader, by creating a Hanselborg image for you, in the interest of saving you the time of doing it yourself.

I now return you to your regularly scheduled blog.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Task: Remove a Programmatic Crutch

July 21, '07 Comments [17] Posted in Musings | Programming
Sponsored By

Phil DeVeau left a great comment about Podcast 72 on Becoming a Better Developer in Six Months. He said:

Remove a Programmatic Crutch.  Everyone has programmatic crutches, maybe you can't code without coffee, or without music, or more likely you can't do anything without an IDE.

I love the way he phrased it. A while back (do forgive me the self-quoting, you know you're an idiot when you start quoting yourself but...) I said If you're going to develop a habit, why not make it a best-practice-habit?

That was a true and pithy statement, but I was thinking about new habits. I often forget about all the old ones. Here's my "crutches" and I resolve to do something about them...even if that something means deciding that they, in fact, work for me and I decided to keep on doing them. At least I'll be able to say that I haven't lived an unexamined programmer-life.

  • Email Checking: I tend to roll directly out of bed and roll, roll, roll, down the hall, roll into my chair, and immediately check my email. This is insane. There's rarely something crucial that's happened between 2am and 7am that needs my attention.
  • Crackberry: I'm getting better with this one, but still, the "urgency addiction" is strong in this one. I'll try to embrace the freedom of only checking email forty, er, um, I mean, four, times a day.
  • Caffeine: I thought I kicked the junk, but I'm back on it. The Diet Coke is going to destroy me. In the words of Dennis Miller, do I need a soft drink with an undertow? I'll start reaching for water unless I really need a kick to get some code working. Actually, I think that Diet 7UP is probably an appropriate methadone for Diet Coke, no?
  • XM 150-154: I love my XM Radio, especially the four twenty-four hour comedy channels...I listen to them while I code...wait...why is this a crutch? Screw that, I'm keeping this one.

What programmatic crutch are you going to remove during your quest to be a better developer in the coming months?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

First Rule of Software Development

July 20, '07 Comments [19] Posted in Programming
Sponsored By

fight-club-dvd We had a great email go out today from Brian Windheim, one of the Architects here. He said I could share it. It was sent internally to his team. I like Brian's style.

Frank broke the First Rule of Fight Club Software Development yesterday:

Never commit code just before you leave for the day.

The CCNET (Continuous Integration) build subsequently broke – despite the fact that he ran a local build first – and team members who were still in the office had difficulty progressing with their work for several hours.

First, the remedy.  If this ever happens again, simply revert the source repository to the prior known-good state using SVN’s revert changes.  Don’t try to apply band-aids, and don’t waste time solving a problem that the original developer could probably solve in about two minutes.  Using the tools correctly saves oodles of time. 

Second, the reaction.  Folks, don’t panic.  Ever.  If a quick peek doesn’t find the answer, don’t be afraid to pick up the phone and call the dude who broke the build.  In 15 years of software development I have many times been the guy that broke the build, fixed the build, got mad when I was working at midnight to fix something broken by the guy that just went to Mexico on vacation for two weeks, reprimanded the guy the broke the build, been reprimanded for breaking the build, and so on.  Get used to it.

Third, the lesson.  Don’t commit things without waiting for CCNET to tell you that you can go home.  All the more reason to have a faster build, no?

Broken builds break hearts, I say.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.