Archive for November, 2003

David Bau

My good friend and colleague David Bau, of
XML Beans and
Dave’s Quick Search Bar
(indispensable!) fame, has a weblog!

And he’s been busy already.

Welcome to the blogsphere, David.

Syntax highlighting

Dan makes an
interesting observation about syntax highlighting

I noticed this the other day when I printed out the code for the compiler
module I’m working on. In the editor, with colored highlighting enabled, it
makes sense what’s going on, and everything’s reasonably obvious. On paper,
though, in black and white with no highlighting the lack of comments was much
more obvious, and the code itself didn’t make a whole lot of sense.

I have certainly made the same observation.  Once in a while, I revert
to emacs to edit Java files and the absence of highlighting immediately puts an
extra burden on my eyes and my brain (and yes, I know about syntax highlighting
in emacs, I actually wrote a few elisp modes myself, but I stopped trying to
install such packages about five years ago when my sanity was on the brink of
leaving me).

However, I don’t follow Dan when he says:

I have noticed one interesting thing about using it [syntax highlighting],
though–I comment my code less.

I fail to see the logical connection between syntax highlighting ("read"
mode) and comments ("write" mode).  Syntax highlighting is certainly not a
substitute for commenting your code.

Syntax highlighting is about… well, syntax:  keywords, expressions,
well-formedness, etc…

Comments are about semantics.  You don’t need to explain what a "for"
loop does, but it’s definitely a good practice to put a comment on top of such a
loop to explain the business logic inside.  Syntax highlighting certainly
doesn’t cover this aspect, so don’t be lazy with your comments.

Partial classes

Ted is all excited about the upcoming partial classes (the ability to have a
class implementation spread over several source files) in the CLR.  He


As part of the C# 2.0 release, Microsoft/ISO are introducing an interesting
new feature as part of the language; it’s not as sexy as something like
generics, perhaps, but I think it stands to serve as a far more powerful and
important feature in the long run: partial classes.

More specifically, he is worried about accidental overriding:

I can accidentally introduce, through overriding, errors into the code
because I don’t follow invariants assumed by the code-generator.

I fail to see how partial classes help mitigate this problem since nothing
prevents both you and the code generator to create methods with the same name
and signature in different files.

There is benefit to partial classes, though, but Ted seems to miss it. 
The problem with the way code generation is typically performed nowadays in Java
is with inheritance: 

  1. You extend a generated class or
  2. A generated class extends yours.

The problem with solution 1) is that it makes it impossible for your class to
extend another class, since Java and C# only support single inheritance of
implementation.  Partial classes can come in handy in such a case.

This feature is interesting but it also opens the door for the resurrection
of long-forgotten linker problems, since a compilation phase is no longer
guaranteed to produce a valid class…  It will be interesting to see how
Microsoft handles this problem.

HTML still vastly underutilized

My friend and colleague Rod wonders if anybody uses tinyurl.  I
about tinyurl some time ago
and my immediate reaction to Rod’s question was "I use it all the time". 
Then I thought a little bit more and it occurred to me that I used to use it all
the time, but I have dramatically reduced the amount of tinyurl’s I send in my emails.


Simply because I use "real links" in emails now.

I don’t know about you, but while 99% of the emails I receive are in HTML,
very few use even the most basic features of HTML (bold, italics, color) and
much less HREF’s.  When someone wants me to take a look at a certain link, the email
typically looks like this:

From:  Friend of Cedric
To: Cedric
Subject:  Cool tool!

Hey Ced, check out this tool, it really helps speed up EJB development:

A few months ago, I noticed this and wondered how come nobody bothers to use
real links in their emails?  After all, it’s not like senders are not
familiar with HTML and they certainly know how to insert an href in a text, regardless
of the tool they use.  So why don’t we see more emails such as:

From:  Friend of Cedric
To: Cedric
Subject:  Cool tool!

Hey Ced, check out this tool, it really
helps speed up EJB development.

It is trivial to insert a link with Mozilla (Ctrl-L) and Outlook (Ctrl-K,
same as FrontPage), so why don’t people use this feature more?  Once you
start using links in your emails, the need for tinyurl is greatly
reduced.  I still use tinyurl for my Yahoo Messenger status, though.

How about yourself?  Do you use real links in your emails?  When
you compose an email, do you bother adding some formatting such as color or
bulleted lists to make your message easier to read?

about email you receive?


JSR 175 available for public review

JSR 175 (annotations for Java) is now available for public review until December 5th.

Also, TheServerSide is running a thread of discussion about it.

Installation from hell (volume 2)

Next came the choice of a Web server.  That was a tough one.  I am
very familiar with Apache but its track record with XP is not stellar, to say
the least.  And the Gallery documentation makes it very clear that Apache 2
and PHP do not form a happy couple.  As much as I hated the thought, I
resigned myself and went with IIS.  Editing text files was fun fifteen
years ago but I am willing to forego some safety in order to regain my
intellectual sanity.

It takes a little while to adjust from the Apache mindset to IIS’s opinion of
what a Web server is, but it’s not very hard to configure overall.  Adding
PHP support to it was a breeze (I went for CGI again for simplicity, but ISAPI
is safer)

My initial attempts went well:  my pictures were there, I could log in
and change stuff.  Then I tried to upload my first photo, and it didn’t

I enabled the debug mode and Gallery quickly rewarded me with a "Cannot fork
"cmd /c … <imagemagick executable>".

First of all, I’ll pass on the incredibly geeky message about "not being able
to fork", which is a shame even for a debug mode.  It’s pretty obvious that
the authors of Gallery have been fed UNIX juice when they were kids.  Okay,
the message isn’t helpful in the least, but at least I understand what’s going
on.  I just don’t know why.  PHP being the language that it is,
there is no stack trace in the error message so I can’t debug the code myself
(not that I would want to, although I ended up giving it a quick try).

The path to the ImageMagick executable is correct and Google is denying me
any kind of help.  As do the Gallery forums. I make sure that the
IUSR_machine user has the right permission, so I am at a loss understanding what
is going on.  Then I have the idea to run the faulty script by hand from
the command line and… surprise!  It works.

It’s only when run by IIS that the command fails.  In order to confirm
my suspicion, I write a quick PHP script that simply invokes the "dir" command
through cmd.exe, and it fails as well.  I think I know where this is going
now…  Somehow, the IIS user doesn’t have the permission to run cmd.exe.

Considering it would be a big security hole if IIS were configured to allow
this by default, I give credit to the install process for going with the safer
setting.  But now I need to fix it.

Finding the corresponding menu in IIS is pretty easy but to my utmost
surprise, the error persists.

My next thought is that maybe the permission is being denied at the OS level. 
The thing is, I can’t find any security setting for file and users on XP, so I
call Google to the rescue.  I finally stumble upon the screenshot of a File
property window that has a "Security" tab.  I right-click on one of my
files, bring up the Properties window but alas, no Security tab.  Uh?

More Googling and I finally learn that if I am not seeing this Security tab,
it’s either because 1) the file system is not NTFS (it is) or 2) advanced file
sharing is disabled (Explorer / File options / Advanced).  And it is!

I enable advanced file sharing and this time, the Security tab is here. 
I allow the IIS user to run cmd.exe and reload the Gallery test page… 
victory!  IIS can now run executables.


IIS can run executables?!?

This icy realization puts a quick damper on my triumphant mood.  Okay,
do I really want that?

Well, I am not quite sure yet.  Right now, I am just happy to be done
with this installation and having learned a ton of things in the process. 
However, I would really like to make sure that only Gallery is allowed to run
the cmd.exe executable.

My initial idea right now is to copy cmd.exe to another secret location and
to patch Gallery so that it refers to that secret location instead.  This
way, the "real" cmd.exe remains non-executable by IIS.

Still working on that part…  Feel free to make suggestions!


Installation from hell (volume 1)

I have a love-hate relationship with
, a software to publish your photos online.

I love it because it is simple and powerful.  You can create trees of
albums, upload pictures from anywhere (even directly from your Windows XP
desktop), have your guests add comments, etc…

I hate it because it is an unbelievable nightmare to install on anything
other than Linux and Apache.

Actually, I take that back.  It is a nightmare to install on Apache as

My previous installation on my home machine should have been a warning: 
I was encountering random corruption of the pictures and I was never able to
explain it.  I tested with PHP 3, PHP4, Apache 1, Apache 2, IIS, CGI and
ISAPI.  And all combinations thereof.  I finally managed to find a
winning combination (PHP4 + Apache 1 + CGI mode) which still failed sporadically
on IE only (always worked fine on Mozilla).

I recently revamped my home machine and installed a brand new XP on a new
120gb hard drive.  Trust me when I say I was not looking forward to
reinstalling Gallery.  I braced myself, but it went just as bad as I
expected.  Actually, it went worse, because a new version of Gallery has
come up since I last installed it and the newer version came with a host of new
problems I hadn’t encountered before.

First of all, being a PHP application, Gallery has a lot of dependencies on
external packages, starting with PHP itself, of course, and also ImageMagick
and/or NetPBM (one of them required) and a bunch of other optional packages that
I strongly recommend not to install in your first pass.

NetPBM on Windows is, simply put, impossible to find reliably on the net. 
Links are broken all over the place, starting with Gallery’s own Web site. 
Second, when you finally manage to find them, you will find nothing less than
three or four different binary distributions, all of them with their own strings
attached (some were compiled with djgpp, others with cygwin, etc…).

So I went with ImageMagick, which is a better-behaved citizen (even more so
since Gallery only depends on three executables in the ImageMagick

Coming up in volume 2:  choosing a Web server…

AOP Presentation at BorCon 2003

I will be talking about Aspect-Oriented Programming at the Borland Conference tomorrow (Tuesday, November 4th). Stop by and say hi!

iTunes for Windows

Overall, I find that programs running in the Windows environment these days
respect the look and feel guidelines pretty closely, making the experience
really pleasant.  However, there is a whole class of software that has
resisted this trend and persists in not only offering skins to its user, but
also coming by default with a look that will baffle the most seasoned Windows
users.  I am referring of course to MP3 players.

Whether it be MusicMatch Jukebox, WinAmp (probably the worst offender) or
even Microsoft’s very own Windows Media Player, all these programs sport a UI
that is meant to look sexy and "real-world like" but only manages to be annoying
and often littered with graphic bugs causing me to close and reopen windows on a
regular basis, when it’s not the entire application itself.

So imagine my surprise when I tried iTunes and discovered that it is a very
well-behaved Windows application with one single window and with menus and fonts
that blend nicely with the rest of my desktop…  Okay, they couldn’t
totally drop the Apple way and the scrollbars have the Aqua cerulean look, but I
can live with that.

Apple is doing a better job at honoring the Windows look and feel than
Microsoft itself.  Oh, the irony.

There are two more things I like about iTunes so far:

  • How easy it is to create play-lists and switch from one to the other.
  • How songs fade into each other.  This is something that has always
    bugged me in pretty much all the MP3 players I have tried on Windows: 
    they never pre-buffer the next song, which means that when a song reaches
    its end, there is a blank in the stream while the software is busy loading
    the 5-10 megs of the next song.  Really dumb.  Not only does
    iTunes do prefetching, but it also fades a song when it ends then slowly
    goes crescendo on the next one.  And this is configurable (actually, I
    take back what I said:  if you disable crossfade altogether, then there
    is a gap between each song.  Too bad, because sometimes you don’t want
    the songs to fade into each other but just carry on without any volume
    alteration such as in
    concept albums

iTunes is also pretty revolutionary on the sharing side.  As soon as you
launch it, it will broadcast its presence on your LAN and it will display all
the other instances it finds on the network.  If their owner has decided to
share their library, you will have access to it right away, otherwise you will
only see their name (Macs seem to come with the firewall on by default, so Mac
users will have to open a particular port to enable this feature).  Note
also that you cannot copy the songs of your friends, only listen to them (and
only when they are online), so Apple is being very obedient of the copyright
laws.  It is however very easy to buy a certain song if you like it (I
haven’t tried that yet).

What I would like to see in future versions of iTunes:

  • The album and song title of the song currently playing when I hover over
    the tray icon.
  • When I minimize the iTunes window, I want it to disappear from the task
    bar and be only present in the tray.
  • More flexibility in the naming of the MP3 files that get created, such
    as "Track number – Song name".  Right now, the format is not
    configurable, which makes iTunes not an option for me for ripping songs.
  • A lot of the buttons don’t have tooltips.

Hopefully in the next version…