Monday, May 31, 2004

FwSync 1.0 - Code Name Perserverance

It was a busy weekend - my wife was accepted to the Wharton Executive MBA program, and she started class yesterday. We drove up and got her settled in to her new, incredibly busy life. While she was listening to introductory speeches, I got some time to spend with my computer. I'd recently run into some issues with my offline FlexWiki editing tools, and finally needed the ability to merge offline and online changes. About eight hours of effort later, I've completed it. With this feature out of the way, I feel like I can finally slap a 1.0 label on FwSync. Woohoo!


This is really a milestone for me. Like many people in my line of work, I have a fairly short attention span - I tend to focus on something intently for a while, figure out about 80% of it, and then move on to the next thing. That's an asset when you're teaching a class or researching a new technology, but I've long been aware that “real” developers don't have the luxury of moving on once the interesting bits are finished. So I've been looking at FwSync and FlexWikiPad as ways to see if I can follow a project all the way through to the end.


I still have a fair way to go in my journey. If nothing else, I'd like to ship version 1.0 of FlexWikiPad as well. And beyond that, I want to spend some time supporting the products, because I think you learn a lot by hearing how the choices you make screw other people over. You learn even more when you then have to fix them. :)

Wednesday, May 26, 2004

PluralSight Online

I'm happy to see that Keith, Fritz, and Aaron have gotten the PluralSight website properly launched. I'm particularly pleased that Keith, Fritz, and Mike Woodring all now have proper blogs. These guys were some of the sharpest dudes at DevelopMentor...seriously.

Processing Command Line Wildcards

I can use a keyboard so much faster than a mouse that I just hate it when an app makes me click things instead of letting me type in shortcuts. So it's no surprise that I love working at the command line. One thing that distinguishes a good command line application from a bad one is whether or not it lets you use wildcards. For example, being able to do:


  fooutil blah.txt *.cs abc????.xml


is a good thing - it lets me say, “Run fooutil on the file blah.txt, any file with a .cs extension, and files that have a name that start with abc, are seven characters long, and have an xml extension” all in one fell swoop.


As it turns out, getting this behavior in your app is pretty easy. Here's the code:


public static int Main(string[] args) {
  foreach (string filespec in args) {
    string specdir = Path.GetDirectoryName(filespec);
    string specpart = Path.GetFileName(filespec);

    // GetFiles will vomit on an empty specdir
    if (specdir.Length == 0) {
      specdir = Environment.CurrentDirectory;
    }
    foreach (string file in Directory.GetFiles(specdir, specpart)) {
      string path = Path.Combine(specdir, file);
      // Your code to process the file identified by path goes here
    }
  }
}


The key magic here is Directory.GetFiles, which will return you a string array of file names that match a given directory a pattern. Check out the docs for Directory.GetFiles to get the full scoop on what patterns are legal. Also note the use of Path.Combine - never combine path elements with +.

Tuesday, May 25, 2004

XPQ

Since Eric mentioned me, I feel all this pressure to post something cool and C#-related. OK, here's a neat little number:


public class App {
  const string USAGE = @"Usage: xpq <xpath> <input>"; 
  public static void Main(string[] args) {
   
if (args.Length != 2) {
     
Console.WriteLine(USAGE);
     
return;
   
}

   
XPathDocument doc = new XPathDocument(args[1]);
   
XPathNavigator nav = doc.CreateNavigator();

   
object o = nav.Evaluate(args[0]);

   
if (o is XPathNodeIterator) {
     
XPathNodeIterator iter = o as XPathNodeIterator;
     
while (iter.MoveNext()) {
       
Console.WriteLine(iter.Current.Value); 
      
}
   
}
   
else {
     
Console.WriteLine(o);
   
}
  }
}


What does it do? It lets you run XPath queries against files from the command line. I call it XPQ for XPath Query. So, for example, I can print the number of “foo” nodes in a doc by running:


   xpq count(//foo) doc.xml


Or I can print the value of every “bar” attribute in a document by running:


  xpq //*/@bar doc.xml


The way it works is by taking advantage of the XPathNavigator.Evaluate method, which runs the supplied XPath expression and returns an object. The type of the object you get back depends on the expression you provide. If the XPath expression evaluates to a number, you get a double. If it evaluates to a string, you get a string. And if it evaluates to a identify more than one node in the document, you get an XPathNodeIterator.


I'm sure there are 999 tools out there that do all this and more, but I love that the framework lets you do so much with just a few lines of code. And this one covers about 90% of the cases where I just need to know something quick about an XML document.

Monday, May 24, 2004

I'd Like to Thank the Academy

It's an honor just to be nominated, of course.  I want to thank my parents, my director, and my dog Jimmy.

Wednesday, May 19, 2004

More Direct3D Afrikaans Translations

The third and fourth installments in the Direct3D tutorial series, are now available in Afrikaans. Thanks to Ernst Kuschke.

Tuesday, May 18, 2004

Moore of the Beginning of the End


I've been saying for years that Moore's Law will end in the next two decades. The typical response I get to this assertion is, “Oh, they'll just move on to the next thing...quantuum computing, multi-core processors, optical, whatever.“ This is basically an assertion of faith against an argument of physics - a typically human response. Which is why I'm pretty sure the computing industry is going to get totally blindsided when suddenly things stop getting exponentially smaller/faster/cheaper. What's Microsoft's business model when you have to buy a computer that's five times as expensive as the one you own now in order to support the features they're working on?


The key, of course, is to figure out a way to profit by announcing something that solves the problems while everyone else reels around in the smoke. My current best guess is “compiler technology,“ but that's another post.


It seems that Intel may already be experiencing an early little speed bump on the way to the giant brick wall.



The warning came first from a group of hobbyists that tests the speeds of computer chips. This year, the group discovered that Intel's newest microprocessor was running slower and hotter than its predecessor. What they had stumbled upon was a major threat to Intel's longstanding approach to dominating the semiconductor industry - relentlessly raising the clock speed of its chips. Then two weeks ago, Intel, the world's largest chip maker, publicly acknowledged that it had hit a "thermal wall" on its microprocessor line.