News flash: Heavier drivers use more gasoline

Posted by

In a tradition started by Raymond Chen (I assume), in posts like “News Flash: Big houses also cost more to cool” or “News flash: Going for a walk on a nice day makes you feel better,” here’s my entry:

News flash: Heavier drivers use more gasoline

How to implement a no-fly-zone over your city

Posted by

This is classic. Apparently the mayor of Chicago wants a “no-fly-zone” over his city for non-commecial aircraft, apparently in order to stop things like that accident in New York from happening “on purpose” as it were.

But ignoring the fact that this is just a crazy rant, let’s think how you’re going to enforce a “no-fly-zone” like this. Let’s imagine the conversation between air traffic control, and the terrorists:

Air Traffic Control: You are not authorized to fly in this airspace, please turn back.
Terrorists: Sorry? What? We can’t hear you.
Air Traffic Control: Repeat, you are not authorized to fly in this airspace, please turn back.
Terrorists: Oh, sure. Hang on a minute, I just spilled my coffee...
Air Traffic Control: Please turn back immediately!
Terrorists: You want us to keep going?
Air Traffic Control: No, turn back!!

Too late! A plane can travel over a city in a straight line in maybe 30 seconds. That means that air traffic control would have 30 seconds to scramble the fighter jets or the surface-to-air missiles or whatever counter-measure they decide to put in place. And once you shoot the plane down, what do you get? A screaming fireball over your city.

Sure a no-fly-zone over a city will stop law-abiding people flying over it, but terrorists are not law-abiding.

ClearType is a temporary solution!

Posted by

It seems that I just can’t let a ClearType-related post go by without adding my own 2¢. Like this one from Michael Kaplan, “It is Clear[Type] how the quality is being managed.

The thing is, I had a bit of a revelation a few weeks ago about this whole ClearType business, and how it’s such a bad idea to force it on everybody like some people are trying to do. Here’s the thing: ClearType is a temporary solution!

In a few years (I can’t predict how many, of course, but at some point in the future anyway) we’ll have 900DPI screens. Of this, I am 100% sure. At that point, ClearType will be pointless – the difference in readability of text at 900DPI with ClearType on vs. ClearType off will be unnoticible.

For illustration, here’s the letter ‘a’ in Verdana at 10pt and at both 96DPI and 900DPI (I zoomed the 96DPI version so it’s about the same physical size, just to compare):

The letter ‘a’ at 96 DPI The letter ‘a’ at 900 DPI

As you can see, at 900DPI, there’s no question that you’re looking at a letter ‘a’.

And when displays reach this milestone, we’ll still be stuck with ClearType simply because it’s getting harder and harder to turn it off - not just in the OS, but in individual applications as well. With frameworks like WPF making it so easy to build applications that scale to higher DPI displays, yet at the same time make it so hard to turn ClearType off, it’s really sending a mixed-message.

Not only that, but you’re kind of limiting the creativity of the hardware manufacturers. Right now, they have to manufacture LCD displays in a R-G-B or B-G-R order. What if a triangular arrangement were better? What about displays that can be rotated 90°?

It makes no sense!

"International" StrCmpLogicalW

Posted by

I've made a version of the native StrCmpLogicalW in C# that sorts the non-digit parts in a culturally-sensitive way (or, if you like, in a non-culturally-sensitive way). You can download the code here

The algorithm is quite simple, and there's plenty of room for improvement. Basically, it just splits the string into non-digit and digit parts, then compares the non-digit parts using a normal StringComparer and the digit parts by first converting to an integer then doing a simple integer conversion.

There are a couple of areas where it could (should) be improved. First of all, it splits the entire string, even though only the first few bytes might be what decides the difference (the solution here would be to split/compare at the same time – but that would have complicated things a little bit too much).

Another problem is that it assumes the digit-part will fit into a 32-bit integer. It would be easy enough to change that to a 64-bit integer, but a truly scalable solution would be to do some "fancy" string compares, with the knowledge that you're dealing in numbers only.

Finally, one of the questions Michael Kaplan posited in his recent post "What would it mean to internationalize StrCmpLogicalW? was "how would you deal with non-ASCII digits?" At the moment, my code only cares about the digits 0-9 but it wouldn't be impossible to extend so that it correctly handles all digits defined in Unicode (well, all 0-9-based numbering systems. I'd hate to have to implement Ethiopic numbering into it :)

Are software firewalls a waste of CPU cycles?

Posted by

I was reading Channel 9 the other day, and I noticed this comment about software firewalls:

I use a router (Firewall) Software firewalls are a stupid waste of clock cycles imho.

I don’t actually have a Channel 9 account (because I’m lazy) but I still wanted to reply to this comment. There is one very important feature that software firewalls have that hardware (actually, external) firewalls do not. That is they can block connections on a per-process basis. So you might have no problem with Internet Explorer (maybe you do!) or Firefox connecting to a remote server on port 80, but maybe you have a problem with “random-piece-of-spyware.exe” connecting – an external firewall cannot tell the difference, but a software one can.

Of course, you still need a hardware firewall (what was that thing about “defence in depth”?) but I believe you should also have a software one as well. A good software firewall won’t waste all that many CPU cycles. They do all their work when the connection is opened anyway, and what with DNS lookups and TCP handshakes, the extra couple of cycles needed to lookup a table is pretty miniscule.