Cook Computing

 

« August 2004 »

Musing on Programming Languages

Saturday 28 August

From an Advogato diary entry by Xavier Noria:

I have been using Python almost on a daily basis for seven months now, mainly due to the fact that we are writing an application in Jython at work. After it, I think I can make an objective remark about something I feel using the language. I would like to find the exact words, but I see an excellent balance between conciseness and density, and a feeling of having a relaxed concentration while programming, which is not only pleasant but I am sure it has several positive implications.

I was thinking along similar lines while doing some coding in C# yesterday, realizing how pleasant and productive it felt compared to working in C++. Once IronPython becomes usable I'd like to something substantial with Python and see whether it has a similar relationship to C#.

Posted by at 03:13 PM. Permalink.

Longhorn Changes

Saturday 28 August

As you've probably heard already, Microsoft has announced that two of the so-called "Pillars of Longhorn" are going to be supported on Windows XP and 2003 Server: Avalon and Indigo. We knew this already for Indigo but its a volte-face for Avalon because Microsoft had previously being saying that Avalon was so deeply embedded in Longhorn that it was not possible to support it on the earlier operating systems. This is good news for those of us who were looking forward to doing serious development with the WinFX and Avalon technologies but realized it might be at least 2009 or 2010 before Longhorn-only projects were started by more than a small minority of software vendors and IT departments.

WinFS will only be supported on the client and server versions of Longhorn from 2007 and I wonder whether it will be delayed even further because of performance problems. After all, Microsoft have been working on this technology since the Cairo concept of 1992 or earlier and you would have thought by now they would have sorted out the basic architecture and design. Unfortunately disk drive performance has not been improving at the same rate as CPU performance and even if it improves enough by 2007 or 2008. other applications will also take the advantage of this and may appear lightning fast in comparison to WinFS. I hope I'm wrong about this because WinFS does sound very interesting.

According to this report by Paul Thurrott its unlikely there will be another alpha release of Longhorn and the first beta will be early to mid 2005 (to coincide with the PDC slated for next year?).

Posted by at 02:33 PM. Permalink.

Nested Using Statements

Friday 6 August

Nested using statements can soak up a lot of indentation so Eric Gunnerson has posted a tip on how to code them more succinctly. Taking his example, instead of this:

using (StreamWriter w1 = File.CreateText("W1"))
{
    using (StreamWriter w2 = File.CreateText("W2"))
    {
        // code here
    }
}

you can write this:

using (StreamWriter w1 = File.CreateText("W1"))
using (StreamWriter w2 = File.CreateText("W2"))
{
    // code here
}

The comments are interesting. Michael Teper points out this is just a case of dropping the curly brackets for a one statement code block:

using (StreamWriter w1 = File.CreateText("W1"))
    using (StreamWriter w2 = File.CreateText("W2"))
    {
    // code here
    }
and John Rusk asks why you can't do something like this
using (StreamWriter w1 = File.CreateText("W1"), 
    StreamWriter w2 = File.CreateText("W2"))
{
    // code here
}

which I optimistically tried the first time I came across nested Using statements.

UPDATE: You can of course write:

using (StreamWriter w1 = File.CreateText("W1"), 
    w2 = File.CreateText("W2"))
{
    // code here
}

but this only works because the variables are both of the same type. It doesn't work in the more general case where different types are being declared.

Posted by at 07:23 AM. Permalink.