Caps 4, Canadians 3 (SO)

I don’t get the chance to see many Caps games, being as I live over 2000 miles away from Washington D.C. I got to see them tonight live and in person for the first time in like four years, and it was awesome. Awesome to be there that is, even if the Caps were less than awesome in the third period. Frankly, I think the Caps were lucky to get one, much less two points in this game.

But before I talk about bad, let’s start with the amazing. Ovechkin’s goal was the most amazing a goal I’ve ever seen live. He leaves Hamrlik in the dust by banking the puck off the boards to himself while he does a 180 to reverse direction. Then he gets knocked down by Chipchura but still manages to slide the puck into the net under Price while lying on his side on the ice before Chipchura’s momentum knocks the net off it’s moorings. You’ve got to see it to believe it.

Crosby Sucks Caps Jersey

Honestly, I think this is even better than “The Goal” from Ovechkin’s rookie season. The goal itself maybe wasn’t quite as amazing, but the bank pass to himself while reversing direction that set up the goal was literally jaw-dropping. That with the knocked down goal in succession was truly a work of art. They showed it about a dozen times on the jumbo-tron, several times on the NHL network highlight show and I’ve watched the embedded video maybe a dozen times while writing this post. Anyone who thinks Ovechkin isn’t the best player in the league is frakking crazy.

Backstom’s give and go with Federov for the second goal wasn’t bad either.

But here’s the stat of the game that should give Caps fans nightmares: All three of Montreal’s goals came on the powerplay. Caps did fairly well in the penalty taking department – only taking four penalties on the night. But going 25% on the penalty kill? There’s no way to spin how ugly that is. To add insult to injury, two of the three goals came less than ten seconds into the penalty – Montreal scored before the Caps could even get their kill set up. Ugh. The first was had two Caps getting tied up in the faceoff circle, leaving Higgins open to score. The second I think went off Erskine’s stick and over Theodore. And the third looked like one Theodore should have had.

The third period, the Caps looked totally flat until Steckel’s nice tip in to tie the game. They didn’t seem to be winning any one-on-one battles for the puck. I know the Caps have talent to spare, but they need to win on the boards if they’re going to win on the scoreboard. They picked it up for the last three minutes of the third and Overtime (except for very scary giveaway by I think Nylander near the end of OT that the Habs couldn’t capitalize on).

Giveaways were a problem – Caps had 12 to Montreal’s 6 – and Backstrom got slapped around in the faceoff circle, winning only 6 of 18. Nylander had a bad night on the dot, going 2 of 8. On the plus side, Caps had 17 takeaways to Montreal’s 7 and Gordon, Steckel and Laich and Federov all were over 50% on the faceoffs (team as a whole won 27 of 58, or 47%.)

As I said, I don’t get to see the Caps often, but I hear they aren’t that good in the shootout, which is kinda surprising given the surplus of offensive talent on the team. They were 2-3 in the shootout going into tonight, while the Habs were 7-4. But the Caps were perfect, Semin and Backstrom scoring while Theodore stoned Plekanec and Markov.

In the end, it’s two points which puts us a full game up on the Devils for 2nd in the East and seven games up on Florida who’s technically chasing us for the SouthEast division crown. Not quite in the bag, but making up that much ground in the 24 games remaining is pretty daunting. The Caps trail Boston by four and a half games for the top seed in the east, which is also a daunting task given the amount of season remaining. I’d love to be in first, but I’m pretty happy with where the Caps are right now – except maybe for the PK.

IronPython 2.0.1

I’m on vacation this week, but I wanted to quickly point out that we shipped IronPython v2.0.1 last Friday. This has been a performance focused release, as you can see via our 2.0 vs. 2.0.1 benchmarks. We have improved our PyStone performance by about 11.5% and our Richards performance by just over 4%. Thanks to Dino for the perf improvements and Dave for the great performance report.

Register now for Lang.NET Symposium 2009

We’re now accepting registrations and talk proposals for the 2009 Lang.NET Symposium, which will be held on the Microsoft campus April 14th-16th.

For those who aren’t familiar with this event, the Lang.NET Symposium is an opportunity for programming language designers and researchers from industry and academia to get together and basically geek out for two and a half days. And it’s not just Microsoft language wonks like Anders Hejlsberg or platform wonks like Don Box. For example, last year we had Dan Ingalls from Sun, Gilad Bracha from Cadence, John Rose from OpenJDK and Wez Furlong from the PHP Project among many others.

If you’re curious about the kind of talks we typically have at Lang.NET, the talks from 2006 and 2008 are available online.

I’ve attended both previous Lang.NET Symposiums and spoke at last year’s event, but this will be my first as a part of the team driving the event itself. We’ve expanded a little this year, though we’re still a small conference so the signal-to-noise ratio should still be very high. We barely fit in the Platform Lab last year, so we moved this year’s event to Microsoft Research’s sweet new building #99.

This year, we’re very excited to be joined at the hip with Chris Sells’ DSL Developers Conference. Those guys over in CSD are working on some cool language stuff of their own, so it just made sense to hold the two events in the same space, one right after the other. Note, registration for each event is separate. You’re welcome to attend both – we’d love it if you did – just make sure you register for both.

As in the past, there is no cost to attend Lang.NET. You get yourself here and find place to stay and we’ll take care of the content, meals and beers in the evening. Just make sure you let us know you’re coming and what, if anything, you’re interested in getting up and talking about by registering at the Lang.NET Symposium website.

IronPython and CodeDOM: Dynamically Compiling C# Files

As part of my series on using IronPython with WPF [1], I built an extension method in C# that does dynamic member resolution on WPF FrameworkElements. The upshot of this code is that I can write win1.listbox1 instead of win1.FindName('listbox1') when using WPF objects from Python or any DLR language. Convenient, right?

The problem with this approach is that the C# extension method gets compiled into an assembly that’s bound to a specific version of the DLR. I recently started experimenting with a more recent build of IronPython and I couldn’t load the extension method assembly due to a conflict between the different versions of Microsoft.Scripting.dll. Of course, I could have simply re-compiled the assembly against the new bits, but that would mean every time I moved to a new version of IronPython, I’d have to recompile. Worse, it would limit my ability to run multiple versions of IronPython on my machine at once. I currently have three – count ‘em, three – copies of IronPython installed: 2.0 RTM, nightly build version 46242, and an internal version without the mangled namespaces of our public CodePlex releases. Having to manage multiple copies of my extension assembly would get annoying very quickly.

Instead of adding a reference to the compiled assembly, what if I could add a reference to a C# file directly? Kinda like how adding references to Python files works, but for statically compiled C#. That would let me write code like the following, which falls back to adding a reference to the C# file directly if adding a reference to the compiled assembly fails.

try:
  clr.AddReference('Microsoft.Scripting.Extension.Wpf.dll')
except:
  import codedom
  codedom.add_reference_cs_file('FrameworkElementExtension.cs',
    ['System', 'WindowsBase', 'PresentationFramework',
     'PresentationCore', 'Microsoft.Scripting'])

Since this technique uses CodeDOM, I decided to encapsulate the code in a Python module named codedom, which is frankly pretty simple. As a shout-out to my pals on the VB team, I broke compiling out into it’s own separate function so I could easily support adding VB as well as C# files.

def compile(prov, file, references):
  cp = CompilerParameters()
  cp.GenerateInMemory = True
  for ref in references:
    a = Assembly.LoadWithPartialName(ref)
    cp.ReferencedAssemblies.Add(a.Location)
  cr = prov.CompileAssemblyFromFile(cp, file)
  if cr.Errors.Count > 0:
    raise Exception(cr.Errors)
  return cr.CompiledAssembly

def add_reference_cs_file(file, references):
  clr.AddReference(compile(CSharpCodeProvider(), file, references))

def add_reference_vb_file(file, references):
  clr.AddReference(compile(VBCodeProvider(), file, references))

The compile function uses a CodeDOM provider, which provides a convenient function to compile an assembly from a single file. The only tricky part was adding the references correctly. Of the five references in this example, the only one CodeDOM can locate automatically is System.dll. For the others, it appears that CodeDOM needs the full path to the assembly in question.

Of course, hard-coding the assembly paths in my script would be too fragile, so instead I use partial names. I load each referenced assembly via Assembly.LoadWithPartialName then pass it’s Location to the CodeDOM provider via the CompilerParameters object. I realize that loading an assembly just to find its location it kind of overkill but a) I couldn’t find another mechanism to locate an assemblies location given only a partial name and b) I’m going to be loading the referenced assemblies when I load the generated assembly anyway, so I figured it loading them to find their location wasn’t a big deal. Note, that typically you’re used to passing a string to clr.AddReference, but it also can accept an assembly object directly.

Of course, this approach isn’t what you would call “fast”. Loading the pre-compiled assembly is much, much faster than compiling the C# file on the fly. But I figure slow code is better than code that doesn’t work at all. Besides, the way the code is written, I only take the extra compile hit if the pre-compiled assembly won’t load.

I stuck my codedom.py file up on my SkyDrive. Feel free to leverage as you need.


  1. I had to put that series on the back burner in part because the December update to Windows Live totally broke my WPF photo viewing app. I’ve got a new WPF app I’m working on, but I’m not quite ready to blog about it yet. ↩︎

Thoughts from Inauguration Day

A few random thoughts on yesterday:

Though some in the progressive blogosphere disagree, I thought Obama’s inaugural speech was very good. His start, contrasting taking the oath of office “during rising tides of prosperity and the still waters of peace” (as now-former President Bush did [1]) versus taking the oath as he does “amidst gathering clouds and raging storms” really set the tone for the whole speech. With Bush sitting right there – mere feet from the podium – Obama categorically rejected almost every policy of the Bush administration. When they cut to a shot of Bush in the middle, he didn’t seem to be enjoying Obama’s speech very much. In a way, I was reminded of Steven Colbert’s epic performance at the White House Correspondents Dinner a few years ago. Of course, the difference was that Colbert was speaking truth to power while Obama is speaking truth from power.

Speaking of Ex-President Bush (man, I love writing that) I can say a lot of negative things about him, but I will grudgingly commend him on handling the transition. However, it does feel like it’s grading him on a massive curve: “Sure he’s been an abysmal president, but at least he was able to peacefully hand over the reigns of power without fucking that up too.”

I felt sorry for Elizabeth Alexander, the poet who had to speak after President Obama’s inaugural speech. Everyone started heading for the exits after Obama was done. I hope those early exiters could hear Reverend Lowery’s benediction, it was awesome. I realize Reverend Warren was a controversial pick to deliver the invocation – certainly, I’m not a fan – but I respect Obama for being inclusive of all-viewpoints. And while having a quartet with the likes of Itzhak Perlman and Yo-Yo Ma was awesome, I especially liked John Williams’ inaugural piece “Air and Simple Gifts”. But wouldn’t the theme to Superman have been more appropriate? 😄

Finally, I skipped the rest of the pre and post inauguration analysis and commentary other than the Countdown podcast which I listen to on my way to work most days. Frankly, I didn’t need to be reminded of what an historic day it was. Res ipsa loquitur.


  1. The Onion was disturbingly prescient with their article eight years ago “Bush: ‘Our Long National Nightmare Of Peace And Prosperity Is Finally Over’” ↩︎