Monday, April 14, 2008
I'm presenting at the Wellington .NET Users Group this Wednesday night.

The aim is to have a bit of a run-through some of the interesting bits I pulled out of the Lang.NET Symposium videos, run through how the different CLR languages fit together and into the CLR, and talk about some of the things we have been hinted at for the future.

More details on the Wellington .NET Users Group site.

posted on Monday, April 14, 2008 10:46:04 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]

These guys crack me up:

And congratulations to Stephen and Melanie :)

posted on Monday, April 14, 2008 4:00:23 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Tuesday, April 08, 2008
Cool - Igor Moochnick has announced the release of pash, an open source implementation of PowerShell that runs on Mono or Microsoft's CLR.

I will be interested in seeing the uptake of Posh among Unix developers -- Powershell is more of an evolution of the standard Unix scripting environments such as bash, perl, and tcl, so should feel right at home.

posted on Tuesday, April 08, 2008 9:22:20 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Wednesday, April 02, 2008
This Star Trek parody to the tune of Ruby is quite nerdy and fun:

From 2006 - you may have seen it already, I hadn't.

posted on Wednesday, April 02, 2008 11:19:14 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Tuesday, April 01, 2008

I've been reading Charlie Calvert's blog, and his list of LINQ providers, and watching both the Lightspeed and LLBLGen Pro LINQ beta's with interest.

There's an available product that you can buy - the CHI69 "Computer Human Interface" - I have written a LINQ provider over the API provided within the supplied SDK.

Download the beta LINQ to Spouse provider here.

Connect to the CHI69 device, and read in the environment:

// Open environmental interface
Environment environment = CHIConnector.Connect<Environment>();

Build the representation of the user:

// Open self-representation
Husband me = CHIConnector.Self<Husband>();

The device allows querying the local environment for objects of different types using LINQ: 

// Search all available for a girlfriend
var prospects = CHIConnector.AllAvailable<Girlfriend>();

Girlfriend girlfriend =

from prospect in prospects
(prospect.Husband ==
null || prospect.MaritalStatus == MaritalStatus.Rocky)
select prospect

Peform some realistic actions with returned objects:


The library exposes a rich interface:

// Test marriage criteria

if (me.Mood == Mood.Romantic &&
    environment.Lighting <=
Lighting.Flattering &&

// Note the downcast. Some functionality will become unavailable
me.Wife = (Wife)girlfriend;


So go ahead and test the library and provider. I'm interested in any feedback you can give.

Some notes:

  • Wife inherits from Husband (by definition, the functionality is a superset)
  • Version 69 of the CHI device only allows for monogamous relationships. Due to demand, apparently this requirement will be removed in an upcoming release
  • As an optimisation, some inherited properties are implemented or cached in the class library, rather than querying the real-world object (e.g. wife.IsRight does not require a remote call as the result is deterministic)
  • The default device communication protocol is messy. Using SOAP would clean it up.
  • Setting me.Salary = 0 will throw an OutOfLuck exception, terminating the program.
  • High intensity emotions (e.g. wife.Emotion.Intensity >= Intensity.Danger) result in unpredictible behaviour. (14.36 KB)
posted on Tuesday, April 01, 2008 12:39:33 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]
 Thursday, February 21, 2008
It's good to see on John Lam's blog that videos from Lang.NET are now available.

They are Silverlight hosted, but if you want to download them directly, here are the links to the WMV files (right-click to save them to your disk):

Videos/1-00 - Keynote - Jason Zander

Videos/1-01 - CSharp3 - Anders Hejlsberg

Videos/1-05 - Lively Kernel - Dan Ingalls - Sun

Videos/1-06 - JScript - Pratap Lakshman

Videos/1-07 - Irony and ERP Language Challenges - Roman Ivantsov

Videos/2-00 - Democratizing the Cloud with Volta - Erik Meijer

Videos/2-01 - Newspeak - Gilad Braha - Cadence

Videos/2-02 - Resolver One - Giles Thomas - Resolver

Videos/2-03 - Retargeting DLR - Seo Sanghyeon

Videos/2-04 - Visual Basic - Paul Vick

Videos/2-06 - PHP - Wez Furlong

Videos/2-07 - Phalanger - Tomas Petricek

Videos/2-08 - Pex - Peli de Halleux

Videos/2-09 - Numerical Computing with the CLR - Jeffrey Sax - Extreme Optimization

Videos/2-10 - remotion Mixins - Stefan Wenig and Fabian Schmied - rubicon

Videos/2-11 - CodeIt - Serge Baranovsky - submain

Videos/3-00 - IronRuby - John Lam

Videos/3-01 - Ruby.NET - Wayne Kelly

Videos/3-02 - FSharp - Luke Hoban

Videos/3-03 - Parsing Expression Grammars in FSharp - Harry Pierson

Videos/3-04 - NStatic - Wesner Moise - SoftPerson

Videos/3-05 - Moonlight and Mono - Miguel de Icaza

Videos/3-06 - Visual Studio Shell - Aaron Marten

Videos/3-07 - Modeling and Languages - Don Box

Videos/3-07 - Modeling and Languages - Don Box_1

Videos/3-08 - Cobra - Chuck Esterbrook

Videos/3-09 - Intentional - Magnus Christerson

posted on Thursday, February 21, 2008 12:12:54 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Friday, February 08, 2008
The .NET user group is kick-starting the year with a country-wide road trip around New Zealand. Chris Auld and Jeremy Boyd are travelling to 11 towns and cities around NZ, and this Wednesday Feb 13, they come to Wellington:

Please come along and check it out. The event is shaping up to be the biggest .NET user group event that Wellington has seen yet, with over 350 people registered! I remember the first .NET user group meeting I organised, it had less than 10 people...

The session starts at 1:30 (doors open at 1pm), and will cover lots of cool new things, including Windows Server 2008, SQL Server 2008 and Visual Studio 2008, as well as covering some other cool related technology such as HyperV.

See you there!


posted on Friday, February 08, 2008 9:22:30 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
A few years ago I wrote a guid shrinker, so that I could send out urls with guids in them, but have shorter messages. This was for mobile work, and so I called them "Muid's" (for mobile unique identifier).

To do this, I wrote a converter that converted from a 16 byte guid to a 21 or 22 character string, increasing the character set to 64 characters instead of the 16 characters used by guid's default ToString() (A-Z, a-z, 0-9, - and $).

It was with a little embarrassment that I read Dave Transom and Mads Kristensen's posts, where they use the Base64 encoder to do the character encoding, while I didn't think of that, and wrote an encoder / decoder myself.

So check out Dave's ShortGuid if you want shorter urls with all the benefits of guids (very hard to guess, globally unique), but don't want to sacrifice the extra 10-14 characters in every url.

posted on Friday, February 08, 2008 9:16:35 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Tuesday, February 05, 2008
Ever wondered which website stole your address and sold it to nasty spammers?

If you use GMail you can use a handy feature known as "Plus Addressing", which lets you receive emails into one GMail account using a variety of email addresses.

When spam arrives in your inbox, you can use the extra information you put into your email address to figure out which website sold your email address or spammed you.

How to do it:

You don't need to make any changes to your GMail account. When signing up to each new website or mailing address, use a slightly different email address.

For example, if your email address is, when you sign up to, you can use the email address and the mail will still come through to your GMail account.

e.g. Sign up to each site with a distinctive email address: - - -

When you receive emails:

Each email you receive in GMail will have a different "to" address, with the site that sent it to you. Click "Show details" on the message to see the full address that the email was sent to.

If you're receiving spam to a particular email address (e.g., then you know which site to complain to -- although that probably won't work. But better than that, you can write quite a simple filter in GMail delete messages as soon as they arrive.


This works best for sign up emails to sites that you don't trust, and that you don't expect to use again. It can be hard to remember your email address to log in if you need to return to Facebook.

If spammers get smart, they could just send email to your base email address (e.g., even if you entered into their site.

Some websites won't allow you to enter +'s into an email address form -- because they haven't read RFC 2882.

posted on Tuesday, February 05, 2008 4:58:47 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Wednesday, January 02, 2008
Another year coming up. Back to work tomorrow after a relaxing few days off.

Today I was awarded a Microsoft MVP again, so that's a good start to the year.

posted on Wednesday, January 02, 2008 10:07:17 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]
 Saturday, December 22, 2007
The Australian Windows Server team have done a good job with the new comic strip Server vs Client:

Not sure how you subscribe, but they're going to update weekly. Check it out.

posted on Saturday, December 22, 2007 10:53:53 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Saturday, November 24, 2007
On Wednesday I listened to an interesting talk on IronRuby by Ivan Porto Carrero.

Ivan has a set of interesting posts on IronRuby on his blog, including a few examples on how to wire up WPF apps using IronRuby rather than XAML.

The slides from his talk are available.

Thanks Ivan!

Next session at the Wellington .NET User Group is 5 December. More details to follow.

posted on Saturday, November 24, 2007 7:51:10 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Friday, November 16, 2007
Wellington is a happening place if you want to learn something new. Last week at the .NET user group we had a great presentation by Jeremy Boyd on the developer features in SQL 2008.

Next Wednesday we've got a presentation on IronRuby by Ivan Porto Carrero.

Mark Carroll is starting a new Team System user group in Wellington, the first meeting is 28 November (Jeremy has the details).

As well as .NET and Team System, other user groups in Wellington are:

If you managed to go to all of them, you'd be eating lots of pizza!


posted on Friday, November 16, 2007 9:45:09 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Wednesday, November 14, 2007
Perhaps more interesting than the other PowerShell features announced in the past week, the SQL 2008 team will release a PowerShell provider in their latest CTP.

For a little more on providers, see my earlier post. I hope the provider allows data access, and not just management capability.

Looking forward to having a play with that when I can get my hands on it!

posted on Wednesday, November 14, 2007 11:10:50 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
Reading, transforming and instrumenting MSIL has been something that has kept me interested (and sometimes over-wraught) since the .NET framework came out in 2000.

It's interesting to see the benefits that a common intermediary language and a virtual machine bring to the party: difficult problems can be dodged by programming language designers (such as garbage collection); languages can interoperate; compiled code can be platform independant, and JIT compiled when needed -- and doing fun stuff with compiled code is easier (and more fun!) with MSIL or Java bytecode.

A few interesting things have happened with Java bytecode over the past few years, with a couple of high profile cases recently. Java bytecode is no longer just the output of a java compiler and the input for the Java Virtual Machine:
  • Google's new Android phone platform translates from Java bytecode to its own virtual machine -- which is not a JVM (via Miguel and Stefano)
  • IKVM.NET, a runtime and set of libraries that convert Java bytecode to .NET MSIL
  • Jython, a version of the python language that compiles to the JVM
Of course the same thing happens in the .NET land -- there are a multitude of languages that compile to MSIL, and MSIL can be run on the Microsoft .NET CLR, Mono's runtime engine and a few other runtimes built by Microsoft and third parties.

The angle taken by Google in developing an alternative virtual machine, rather than using the CLR or Sun's JVM is very interesting. On one hand, they have the benefit of full control of their platform, and this move means that they are not reliant on other vendors solutions. They promise to open source the platform, so the typical arguments about closed proprietary platforms may not apply, but it will still be interesting to see how another VM fits into the ecosystem.

posted on Wednesday, November 14, 2007 10:14:33 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Thursday, November 08, 2007
I think it was Derek that first convinced me of the beauty of the Guid, and I have been using them in databases ever since.

Wade Wright has written up the "Gospel of the Guid". It has a humorous coverage of some of the good Guid reasons:

  • No database roundtrips to get the next integer ID
  • Easy merging, mirroring and deletion of erroneous merges
  • Ability to wire up relationships in memory before saving
I remember when I first started using Guids there was talk of them not being unique, due to dodgy network cards having the same MAC address. Thankfully that's no longer a problem.

Something that I struggle with though, is the lack of type safety when using Guids. e.g.

Guid personId = Guid.NewGuid();
Guid bookId = Guid.NewGuid();

Library.BorrowBook(personId, bookId);

...or is it this way around?

Library.BorrowBook(bookId, personId);

There's no compiler checking that the correct Guid is passed to the right parameter. I've been toying with a Guid wrapper that would be a bit like a typedef in C++, but typesafe. Has anyone already done this?
posted on Thursday, November 08, 2007 9:10:30 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [3]
I seem to spend less time in Virtual PC and more time in (nested) remote desktop sessions these days. I'm not a huge mouse fan, and when using the keyboard I need to do this when I'm in a windowed remote-desktop session:
  • ALT+PgDn / ALT+PgUp - cycle through programs (ala ALT-TAB)
  • ALT+Home - display start menu (ala CTRL-ESC)
My fingers still do the regular ALT-TAB / CTRL-ESC the first time round, but after a while I remember to use the alternate shortcuts.

Thanks to Mark Wagner.

posted on Thursday, November 08, 2007 8:36:14 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Wednesday, November 07, 2007
Adam from Xero and I went to look at the Eee PC at Dick Smith's today. Quite a cute little PC that has no spinning hard drive, no fans and only weighs 900 grams.

Looks like a nice little email / web PC, but the screen is a little tiny for my liking. The install of Linux is quite smooth, and Firefox is integrated nicely onto the desktop.

Quite good for $600NZ though!


posted on Wednesday, November 07, 2007 9:13:35 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [4]
I've been looking forward to the CTP of PowerShell 2 for a while, and it's finally here.

I'm looking forward to installing it on a VM tonight (don't install it on your production / main desktop system just yet).

The stand-out features from the two blog posts (The Community Technology Preview (CTP) of Windows PowerShell 2.0, What's New in CTP of PowerShell 2.0) are:

PowerShell Remoting

"Windows PowerShell 2.0 provides support for executing Cmdlets and Scripts remotely. PowerShell Remoting allows managing a collection of remote machines from a single client. Managing remote computers using PowerShell 2.0, requires that PowerShell 2.0 be installed on all the computers taking part in the operation; that is the client computer and the computer(s) being managed."

This solves a problem that a lot of sysadmins have - being able to nicely administer many machines in their farm / network using PowerShell.

Background Jobs

"Windows PowerShell 2.0 introduces the concept of a background job (PsJob).  A PsJob runs a command or expression asynchronously and "in the background" without interacting with the console. The command prompt returns immediately and you can query for the job results at your convenience.  You can run background jobs on a local or remote computer."

Hurrah! I was surprised how much I missed this unix feature, so it's good to see background jobs make an appearance. I'll be interested to see if they have changed the threading model within PowerShell.

Graphical PowerShell

"This release includes a very early alpha version of the new graphical shell..."

Definitely something that people want, although others have filled the void quite well up until now. Looking forward to playing with this.

Well done PowerShell team!


posted on Wednesday, November 07, 2007 9:27:23 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Thursday, September 27, 2007
No, not PowerShell.
I have been having fun measuring how much electricity our house uses, and which appliances are the worst offenders (Oil column heaters = bad, heat pump = good).
The tool I have been using is a Centameter, which is a clever little gadget that you clip onto your mains feed into your house ( You can also get one for a single power point from Jaycar.
A good idea if you want to reduce the impact your consumption has on the world (and your wallet!)


posted on Thursday, September 27, 2007 9:16:32 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [2]
 Friday, September 21, 2007
James Newkirk and Brad Wilson have cooked up a new testing framework for .NET development:

In his blog post announcing, James outlined the reasons why they have created a new framework -- primarily to bake best practice techniques into the test framework, and leverage some of the newer .NET features.

The Comparison between Nunit, MSTest and page on the site lists some of the differences between and Nunit / MSTest. Removing setup and teardown, and providing aspect-like functionality are both interesting angles which I want to spend some time with.

Here's a couple of examples from the samples download. First, an example of usage of BeforeAfterTestAttributes, which let you add behaviour before and after the execution of a test (ala AOP):

[Test, TracingSplicer]
public void TestThis()


public class TracingSplicerAttribute : BeforeAfterTestAttribute
    public override void Before(MethodInfo methodUnderTest)
        Console.WriteLine("Before : {0}.{1}",
            methodUnderTest.DeclaringType.FullName, methodUnderTest.Name);

    public override void After(MethodInfo methodUnderTest)
        Console.WriteLine("After : {0}.{1}",
            methodUnderTest.DeclaringType.FullName, methodUnderTest.Name);

Here's an example of test method extensibility:

[RepeatTest(5, Timeout=500)]
public void RepeatingTestMethod()

You can create your own attributes that inherit from the TestAttribute base class, and define what will happen when the test runs (in this example, the test will run 5 times).

Good work guys, looks useful!

posted on Friday, September 21, 2007 10:03:26 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Thursday, September 20, 2007
If you've been a Perl programmer, you've probably used File::Temp occasionally, to generate unique filenames for temporary files and clean up afterwards. In other lanuages you may have used a variation of the standard POSIX tmpnam or tmpfile.

In PowerShell, you'll often need to generate temporary files, especially if you're working with import-csv or import-clixml -- as they don't support data on the pipeline.

There's not (yet) anything I could find that is quite as nice as File::Temp, but if you want to generate a unique filename or directory name, or create a temp file on disk ready to be used, you can use these methods on System.IO.Path:

System.IO.Path.GetRandomFileName() [msdn]
Returns a random folder name or file name. The filename generated is cryptographically secure, meaning that no malicious script should be able to guess what filename you've just been given.

To use from PowerShell:
53> $filename = [System.IO.Path]::GetRandomFileName()
54> $filename
55> Get-ChildItem > $filename

System.IO.Path.GetTempFileName() [msdn]
This method will actually create a temporary file on disk, in your temp directory (returned by System.IO.Path.GetTempPath). The file is 0 bytes, and ready for you to clobber with your own content. You can be sure that no other process has generated the same filename, but it's not exactly a secret what filename you've got -- you should use the GetRandomFileName method if you need a bit of security.

To use from PowerShell:
59> $filename = [System.IO.Path]::GetTempFileName()
60> get-childitem | export-csv $filename

The other thing to remember with GetTempFileName is that you need to remember to delete the temp file after you're finished (something that File::Temp does quite nicely for Perl'ers). Some day I might write a wrapper that deletes the file when the variable goes out of scope.

posted on Thursday, September 20, 2007 9:08:25 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Monday, September 17, 2007
Darryl Burling has been posting a series on starting and running a user group for the new site He asked me to write a post on "Speakers, topics, costs, refreshments", which he has now posted:

"Continuity, speakers and good running"

The most interesting part for me was adding up how many user group events we have had in Wellington (about 45), and how many pizzas I have ordered (approx 800!). If anyone from Pizza Hut or Dominos is reading this, they should get in touch with a discount offer!

Details of all our previous meetings are available on the Wellington .NET user group site, and on the old website.

As I posted earlier, this week Andrew Tokeley is presenting Dynamic Data Controls - come along.

posted on Monday, September 17, 2007 8:09:15 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]
 Sunday, September 16, 2007
Joe Duffy links to a new MSDN Magazine article on PLINQ: "Parallel LINQ - Running Queries on Multiple Processors".

We have been hearing little bits about PLINQ, and a CTP is on the way. PLINQ redefines the query operators from standard LINQ and makes them split the work across multiple processors.

One of the big challenges that we will have as software developers over the coming years is developing for multiple cores. As extra processors and cores are added to our PC's, the clock speed of the machine isn't increasing as rapidly as in the past, so single-threaded applications may actually run slower than on a high-end single processor machine.

PLINQ takes an interesting approach, and redefines the standard LINQ operators that are used for in-memory queries (such as OrderBy, Join, Where etc), and spreads the work over the available CPUs. As LINQ uses a declarative "Tell me what to do, not how to do it" query syntax, there are hardly any changes to the programming model:
  • Reference the System.Concurrency.dll assembly during compilation.
  • Wrap your data source in an IParallelEnumerable<T> with a call to the System.Linq.ParallelEnumerable.AsParallel extension method.
    • i.e. var q = from x in data.AsParallel() ...
  • Optional: choose your pipelining model: pipelined, stop and go, inverted enumeration. You choose this when processing the results.
  • Don't rely on LINQ's default ordering of results. Explicitly order results if it's important to your program.
  • Change the way you handle exceptions. Multiple exceptions may be thrown in the course of one query, and with PLINQ will be wrapped into a MultipleFailuresException.
  • Avoid modifying data in your where clause, or otherwise mutating shared state during the course of your LINQ query. You may open yourself to race conditions.
All of these steps are covered in depth in the article, but on the surface of it, it looks like Joe and the PLINQ team have made the transition from single to parallel LINQ require as little work as possible. I can't wait to try it out when the CTP drops!

Note that PLINQ only applies to LINQ to Objects and LINQ to Xml queries -- SQL Server still does it's own parallel processing. PLINQ parallelises the query execution that occurs within the .NET program.

posted on Sunday, September 16, 2007 6:56:32 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]
 Thursday, September 13, 2007
I really enjoy organising the Wellington user group sessions.

Last week, Matti Seikula did an interesting session on spatial software development and Virtual Earth. I've seen a bit of mapping stuff over the past few years, but Matti did a really good job of explaining the various coordinate systems, and how you can layer different information over (and under) the data displayed in two and three dimensions in Virtual Earth.

Next week on Wednesday 19th, Andrew Tokeley is going to be presenting the Dynamic Data Controls (from ASP.NET futures), which are useful for making data-driven web apps.

Have a look at the Wellington user group page, and RSVP now :)

posted on Thursday, September 13, 2007 9:22:07 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]