Thoughts from the office by Ed Ball
Friday, October 31, 2003

Have you read The Lord of the Rings more than once? Have you at least tried to read The Silmarillion? If so, you might enjoy J.R.R. Tolkien: Author of the Century, by Tom Shippey. I thought that the book would be mostly biographical, but it is primarily a discussion of Tolkien's works -- what he wrote, what influenced his writing, where he got his ideas, why he wrote what he did, what themes emerge from his works, how he compares to other authors, what attracts readers to his works, how to respond to his critics, and, ultimately, why he deserves the title "author of the century." The book was a nice reminder of how much I've enjoyed Tolkien, and helped me to better understand why I enjoy his books. In fact, I may be inspired to start reading my Tolkien collection yet again...

10/31/2003 10:30:48 PM (Pacific Daylight Time, UTC-07:00) | Comments [1] | Books#

I've been a fair-weather fan of the Seattle Mariners ever since their 1995 season, so the late-season success of the Oakland A's these past few years has been a source of some frustration. Moneyball, by Michael Lewis, describes the secret of the A's success. It's a very interesting read that gave me some insight into baseball team management. The differences between the strategies of the Mariners and the A's were quite apparent; I'll never think about "manufactured runs" the same again. The book has a smattering of profanities, likely indicative of the langauge found in the baseball community. I'd recommend this book to anyone who has wondered how the A's do so well with so little money -- or to anyone who simply wants to read a good baseball story.

10/31/2003 10:26:00 PM (Pacific Daylight Time, UTC-07:00) | Comments [1] | Books#
Thursday, October 30, 2003

Happy 0th Birthday to Rebecca Lily Ball, born Tuesday, October 28, at 4:45 p.m. Praise God for healthy and happy mom and baby!

10/30/2003 11:37:27 PM (Pacific Daylight Time, UTC-07:00) | Comments [0] | Misc#
Monday, October 27, 2003

Since Ed-at-work is mainly still in the land of C++, COM, DHTML, and JScript, it is primarily Ed-at-home's responsibility to keep me as current as possible on the cool new programming technologies from Microsoft, i.e., .NET. To that end, I recently created my first GotDotNet workspace, DocExtensions.

I love the idea of supplying object library documentation in special C# comments, but don't love the bulky XML syntax that is required. So, I wrote a console application that allows me to use a more pleasant Wiki-style syntax in my documentation comments. Check it out, and please let me know if you like the idea!

10/27/2003 1:15:51 AM (Pacific Daylight Time, UTC-07:00) | Comments [0] | Code#

I've done plenty of Windows programming, but very little Web programming, so I borrowed a copy of Beginning ASP.NET using C# from a coworker. I wanted an introduction to the basics of ASP.NET programming so that I could begin to feel comfortable with the technology. This book fulfilled my three primary requirements for such a book:

  • First, it doesn't use Visual Studio .NET, so I never had the nagging feeling that the IDE was doing anything mysterious behind the scenes.
  • Second, the samples are written in C#, which I'm quite comfortable with, rather than VB.NET, whose syntax remains a mystery to me.
  • Third, it doesn't spend too much time with databases. One of these days I'll get some database development under my belt, but I'm not there yet.

I didn't need the introductions to C# and OOP, but those sections were easy to skim. All in all, the book served as a good introduction to ASP.NET. Of course, if I ever end up needing to write a serious ASP.NET application, I'll be looking for a book with a little more substance. Hopefully, now that I've read this book, I'll be ready.

10/27/2003 12:15:22 AM (Pacific Daylight Time, UTC-07:00) | Comments [0] | Books#
Wednesday, October 22, 2003

A coworker of mine found a bug in my code that was basically a result of a typo -- brain thinks one thing, fingers type something else -- and it got me to wondering if a really good compiler could have warned me about it. The offending statement:

if (nSelectedIndex == 0 && strColor == "other" && strColor != "")

Wouldn't it be cool if a compiler could notice that there's probably a bug here? The third comparison is pointless, since if the second comparison is true, the third comparison will always be true, and if the second comparison is false, the third comparison won't even be evaluated.

10/22/2003 9:53:27 AM (Pacific Daylight Time, UTC-07:00) | Comments [0] | Code#
Tuesday, October 14, 2003

In .NET, strings are immutable, so string concatenation always creates a new string. If you perform many such concatenations, in a loop, for example, such that the string gets very long, this can become very inefficient. Hence the StringBuilder class in System.Text, which allows, among other things, more efficient concatenation of strings.

Since JScript (JavaScript, ECMAScript) strings are also immutable, the scripting language has the same efficiency problems. While there's no StringBuilder object defined for JScript, you can use an array of strings as a poor man's StringBuilder. Instead of concatentating to a string, push to a string array. Then, when you need the big string, call join("") on the string array, which is considerably faster than the traditional approach.

// very slow
var strSlowText = "";
for (var nSlow = 1; nSlow < 10000; nSlow++)
  strSlowText += nSlow + " ";
 
// very fast
var astrFastText = [];
for (var nFast = 1; nFast < 10000; nFast++)
  astrFastText.push(nFast + " ");
var strFastText = astrFastText.join("");

I didn't invent this technique, of course, though I don't remember where I first read about it.

10/14/2003 4:38:00 PM (Pacific Daylight Time, UTC-07:00) | Comments [0] | Code#

I use a Microsoft Natural Keyboard Elite, and, for the most part, I love it. It has a good feel and doesn't take much desk space. The rearranging of the navigation keys took some getting used to, of course, but that was a long time ago. What don't I like about this keyboard? Well, it would be cool if it had USB ports on it, but I can live without that. Also, the keyboard is extremely sensitive to liquids, so I have to be extra careful not to keep water nearby.

The only other thing I sometimes wish for are those cool multimedia keys on the new keyboards. In particular, the Play/Pause key seems like a great way to interrupt whatever music you happen to be listening to. However, I have a coworker with the Natural Multimedia Keyboard, and there are lots of things about it that would drive me nuts, so I'm not going to get one of those. (What exactly? Well, for starters, "enhanced F-key functionality," the navigation keys are rearranged again, there's no Insert key above the arrow keys (call me crazy, but I still use Ctrl+Insert to copy from time to time), and the right Windows key is missing, which makes Win+L more difficult to type (to lock the workstation), and shifts the right Ctrl key to the left, leaving an empty space where that key should be.)

In any case, there must be a point here somewhere, because this isn't really supposed to be a keyboard review. Well, I ran into Chris Sells' Scancode Mapper while browsing around and wondered if I could use it to convert a key that I never use, say, the Scroll Lock key, to work like the Play/Pause key on the multimedia keyboards. It looked promising, but alas, it didn't work. I didn't give up, though, and after doing some additional research, I figured out how to do it!

First, download and run Scancode Mapper. Use it to map "Scroll" to "MediaPlayPause", and commit the changes. Note that it has actually mapped the Scroll Lock key to G; I suppose this would classify as a bug, but I haven't looked at the code. In any case, exit Scancode Mapper and fire up the Registry Editor. Head over to "HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ Keyboard Layout", and edit the "Scancode Map" value. Feel free to read the documentation for this registry value, as it uses a very simple format. The problem is that Scroll (46) is being mapped to G (22) instead of Play/Pause (e0 22). So, simply replace the "00" after the "22" with an "e0", and you're good to go. The binary editor inserts anything you type by default, so be sure you've replaced and not added. I shouldn't have to mention that you edit the Registry at your own risk; it's a dangerous business, so be careful! (For reference, here's my data, which defines only the one mapping: 00 00 00 00 00 00 00 00 02 00 00 00 22 e0 46 00 00 00 00 00)

Anyway, once you've rebooted, your Scroll Lock key is now a Play/Pause key. Have fun!

Update: Minor correction, as described in the comments.

Update: Changed category to Keyboard.

10/14/2003 4:13:58 PM (Pacific Daylight Time, UTC-07:00) | Comments [2] | Keyboard#
Wednesday, October 08, 2003

Instinctively,

  if (strGnusto != "")

is going to be less efficient than

  if (strGnusto.Length != 0)

when checking for an empty string, though I think the former is probably easier to read.

I decided that I'd do some rudimentary timing comparisons using JScript and C#. (Thanks to Jeff Key for Snippet Compiler!) The comparison using Length does seem to be more efficient than the comparison to "" -- about 1/5th the time in the (again, rudimentary) timing that I did.

No surprise, really, but I was hoping that the performance difference would be a bit less dramatic. As it is, I should probably start using the later syntax. The performance isn't going to matter in most cases, but consistency is best.

10/8/2003 10:42:05 AM (Pacific Daylight Time, UTC-07:00) | Comments [0] | Code#
Tuesday, October 07, 2003

If you haven't seen the television series Babylon 5, I envy you. Not because it's no good; on the contrary, I consider Babylon 5 to be The Lord of the Rings of science fiction for television, and that's saying a lot. I envy you because, though I just finished watching episode two of season three, I've seen it before, whereas you have the opportunity to see it for the first time. Babylon 5 really is that good, if you give it the chance. If you're willing to follow my advice, and you're ready to watch some Babylon 5, I've got some guidance for you.

First, get a hold of the pilot episode, The Gathering, on DVD. Now watch it. Be forgiving; the series gets much, much better than this. (Be sure *not* to watch In the Beginning, which is on the same two-sided DVD; it may seem like the right thing to do, but it's full of spoilers for the first four seasons, so you'll want to exercise self-control and not watch it until you're done with the fourth season!)

Once you've watched The Gathering, head over to The Lurker's Guide to Babylon 5 and read the appropriate guide page. There's lots of great stuff there, all written when the pilot first aired, with few, if any, spoilers for the rest of the series. The guide pages are key to getting the full Babylon 5 experience.

Next, get a hold of season one, watch the first episode, and check out the guide page. Continue watching episodes and reading guide pages until you're done with the first season. Don't watch more than one episode per day; Babylon 5 needs to be savored, and there's plenty to think about. Don't watch any of the special features of the DVD -- not even the introduction -- as they'll almost certainly contain spoilers, and you'll want to be just as floored as I was as the series arc progresses.

When you're done with season one, continue on to season two. Then season three. Then season four (which isn't quite released on DVD yet). Now feel free to watch In the Beginning. Great stuff! Finally, watch season five, which probably isn't as good as the first four, but was still a fun end to the series. Now that you've seen all there is to see, feel free to check out the special features of the DVD sets. By this time, they might have released a few of the other Babylon 5 movies, or even the short-lived Babylon 5 spinoff series, Crusade.

If you're like I was, you'll still want more Babylon 5, so you'll want to read some of the great Babylon 5 books. The best books fill in many of the stories in between the stories. The Psi Corps series (1 2 3), the Legions of Fire series (1 2 3), the Passing of the Technomages series (1 2 3 0); all great stuff. I'm currently reading To Dream in the City of Sorrows, another great book that fills in some of the details after season one.

Perhaps I sound like a bit of a fanatic, but I've really enjoyed Babylon 5. I hope your experience is as good as mine!

10/7/2003 10:37:57 PM (Pacific Daylight Time, UTC-07:00) | Comments [1] | Video#
Friday, October 03, 2003

I don't have many readers (I wouldn't be surprised if I know all of my readers personally), but I do get the occasional Google hit from people looking for dasBlog themes. If you'd like to use or modify my theme, feel free.

CustomDasBlogTheme.zip (3 KB)

Update: I just discovered a few hard-coded URLs in the template; sorry about that. It's fixed now.

10/3/2003 3:45:32 PM (Pacific Daylight Time, UTC-07:00) | Comments [1] | Blogs#

I've added a few blogs to my blogroll, but I'd like to highlight Eric Lippert's blog, which has become my favorite. He's got lots of interesting stuff to say, about scripting in particular, so check it out!

10/3/2003 3:38:19 PM (Pacific Daylight Time, UTC-07:00) | Comments [0] | Blogs#

FoxTrot update for .NET:

class App
{
  static void Main()
  {
    for (int count = 1; count <= 500; count++)
      System.Console.WriteLine(
"I will not throw paper airplanes in class.");
  }
}

http://www.ucomics.com/foxtrot/2003/10/03/

10/3/2003 8:25:02 AM (Pacific Daylight Time, UTC-07:00) | Comments [0] | Misc#
Search
Archive
Links
Categories
Administration
Blogroll