I'm actually wondering why they do not compare the lengths first, anyone know?
To me that would seem like the first obvious optimization, do not run the character compare at all if the lengths are different.
If the strings are not equal, they still need to say which string is "smaller" (eg. comes first alphabetically).
Well, that explains it! :)
This is lexical comparison (<, >, =) not just equality.
In addition to what has been said about lexicographic ordering, if the strings are large, say several kB (as they may well be), the entire operation would be dominated by memory latency. In this case it is much cheaper to read each string once, instead of going an extra pass just to find the length.
These are not null-terminated strings; it's not necessary to read the whole string to find its length.
Ah, sorry, my bad. There is so much talk about null-terminated strings here, and I had only skimmed the article. Whoops :P