Leaving…on a jet plane

This will be my last entry for at least a few days, and quite possibly as much as three weeks. The reason is that in about half an hour I’ll be leaving for the airport, and thence to Australia for about…you guessed it, three weeks. The rough itinerary is

  • Sydney
  • Blue Mountains
  • Hobart
  • Cradle Mountain NP
  • Grampian Mountains
  • Melbourne

I’m not taking a laptop, so I won’t be checking email; the only way I’ll be on the net at all will be if I stop in at an Internet cafe in one of the cities, and that won’t be for long. I am taking a digital camera with enough memory for about 500 pictures, and a digital sound recorder, so when I get back you can expect to see and hear tidbits from the trip. Maybe there’ll even be pictures of a real live platypus, from Taronga Zoo in Sydney and/or Healesville Sanctuary near Melbourne. If I’m really lucky maybe we’ll spot one in the wild, most likely during the Tasmanian part of the trip, but I’m not counting on it.

No matter what, this promises to be a really exciting trip. My last serious vacation was four years ago, and who knows when the next one will be, so I certainly intend to make the most of it. Everyone take care of yourselves, and I’ll see you all when I get back.

Phew!

Well, looks like things are falling into place. I got a new cap on my front tooth, we delivered on this month’s milestone at work, I got my haircut, and now I’ve implemented posting of top-level entries directly from the browser into the SQL database (instead of FTP and regular files) here so I can post from an Internet cafe if I feel like it. It’s Miller time. Well, more like home-made iced tea time for me, but you get the idea.

Australia in two days. :-)

Fixing CSS

I got into a discussion with Aaron Swartz the other day, based on his statement that “CSS is the best design I’ve seen to make web pages that look good”. I argued that such a statement was meaningless given such a small sample of designs for the same thing, and that CSS has many warts. Here are a few, along with how I would go about fixing them.

First, the box model is just more complex than it needs to be. We don’t really need padding and borders and margins as separate concepts, because they all do basically the same thing. A much cleaner model would be to pick one term, define an order – inside out or outside in – and allow specification of arbitrarily many “layers” all at once. You could also do away with the separate xxx-left and yyy-top attributes in favor of expanding the current width/type/color tuple to include sides. With appropriate defaults, the following old- and new-style definitions would have the same effect:

	padding:       3px;
	border:        1px dashed green;
	margin-left:   5px;
	border:        3px, 1px dashed green, 5px left;

This approach would make the relationship between an element and its visual presentation much clearer than it is now, without needing such arbitrary definitions as “rendered content” vs. “containing block” and such, and with no sacrifice of flexibility or precision.

The only case where the above doesn’t really work is tables. In general, CSS needs to get over its anti-table bias, and also get past the political infighting that has led to supporting two completely separate models (“separated” vs. “collapsing” and they can’t even agree on verb tense) for table formatting. More specifically, the problem with tables is that the spaces between cells belongs more to the table itself than to the cells (or rows or columns) and conflicts can arise between how the cell/row/column specifies what should go in such a space. IMO the best way to resolve that would be to have style rules carry an explicit priority value, so you can just look at the priorites instead of having to scurry back to the spec to see which takes precedence over what. Certain priority ranges could be reserved for user vs. publisher style sheets, which would also get rid of all that arbitrary !important junk.

Second, the whole notion of floats can just go away because the CSS approach barely works even for things like a simple three-column layout (and not at all for four). In addition to eliminating section 9.5 itself, that also lets us get rid of section 9.7 (“Relationships between ‘display’, ‘position’, and ‘float’”) and 9.8 (“Comparison of normal flow, floats, and absolute positioning”). Heck, practically all of sections 9 and 10 could and should be reduced to a couple of paragraphs with no loss of flexibility or precision. If there are simple, clear rules for how boxes relate to other boxes (which includes nesting), and for what formatting can be applied within a box, there’s no need at all for 90% of that verbiage.

Tables really are the appropriate metaphor for a lot of formatting, which is why so many people still use them despite all the pressure to use CSS. The only problem with tables is that HTML doesn’t account for different media and CSS does, but there are cleaner ways to “bridge that gap” than floats and their friends as they currently exist. For example, consider the following as a hypothetical layout for this site:

	#topnav {
		nesting-step:   1;
		position:       top 150px;
		border:         10px bottom;
	}
	#leftnav {
		nesting-step:   2;
		position:       left 150px;
		border:         3px, 1px dashed green;
	}
	#rightnav {
		nesting-step:   2;
		position:       right 200px;
		border:         3px, 1px dashed green;
	}
	#main {
		border:         10px left/right;
	}

It’s so simple that it hardly needs any explanation except to say that “nesting-step” defines the (ascending numerical) order in which special-purpose areas are “carved out of” the parent box (in this case the entire document). Therefore, 150 pixels are carved from the top first, then 150 and 200 pixels from the left and right from the remainder, then the borders are applied within the boxes thus defined.

Another common need is for columns within a box. Here’s a simple way to do that:

	#main {
		columns:            100px 60% 40%;
		column-separator:   1px solid black, 3px;
	}

In other words, we’ve defined three columns. The leftmost is 100 pixels wide and the other two divide the remaining space 60/40. Columns are separated by a one-pixel vertical black line plus three blank pixels on either side. Voila! In two lines instead of fifty (and without JavaScript or server-side scripting or other non-CSS crutches) a completely “fluid” three-column layout has been defined and the browser can do the obvious right thing balancing text between the columns, etc.

There are some very basic suggestions for how to clean up CSS. Sure, they could use some further tweaking to do everything that people really need CSS to do. The problem is that CSS is too hard for browser vendors to implement consistently, and too often yields results that no sane person could want or expect. That kind of flexibility – the flexibility to create pages that look like dog vomit on some or all browsers – is not a positive thing. CSS is a terrible design.. It’s a big bucket into which everyone on the standards committee threw their share of junk, resulting in a barely-comprehensible mess of internal contradictions and redundant functionality and grey areas. A simplified CSS would make it easier to produce excellent-looking web pages, and allow browsers to render those pages faster, and there would be no negatives to offset those positives. Maybe my ideas aren’t the best ones, maybe there are others that are even better, but if CSS is the best design you’ve seen then you need to get out of the W3C pig wallow more.

Smart Pointers Are Stupid

I’m doing some work in C++, and I had a code review today. The following discussion occurred:

Reviewer 1
Why do you always create objects using “new” instead of just on the stack?
Me
I don’t like to abuse the stack. I’ve worked in too many environments where stack overflows were a major source of pain.
Reviewer 2
You could use an auto_ptr.

At this point the conversation moved on, which was a great relief because I had no idea what an auto_ptr is. The last time I used C++ was when many things that are now part of the idiom didn’t exist at all, or didn’t exist for kernel programmers, or couldn’t be trusted; STL, namespaces, and even templates all fit into this category.

So I looked it up. All I can say is: yech. I’ve never liked operator overloading in any form, and “smart pointers” in particular, and IMO auto_ptr is an example of why they’re a bad idea – not of how they can be used safely. Consider this, from a pro auto_ptr article:

I have seen many programmers try to use auto_ptrs in other ways just as they would use any other object. The problem with this is that auto_ptrs are most assuredly not like any other object.

For auto_ptr, copies are NOT equivalent.
It turns out that this has important effects when you try to use auto_ptrs with generic code that does make copies and isn’t necessarily aware that copies aren’t equivalent (after all, usually copies are!).

It is never safe to put auto_ptrs into standard containers.

Again, yech. Those are some serious differences between an auto_ptr and a regular pointer (which it is supposed to replace transparently). The author even admits that many programmers have had problems because they weren’t aware of the differences, but doesn’t draw the obvious conclusion that replacing one faulty abstraction (regular pointers and memory leaks) with another (auto pointers and “spooky” bugs resulting from their unexpected behavior) is dumb.

In conclusion, I can’t help but quote from the article’s acknowledgments. The very fact that a book with such a title even exists could be considered evidence that C++ rots your brain.

This article is drawn from material in the new book Exceptional C++: 47 engineering puzzles, programming problems, and exception-safety solutions

Needle-free Blood Testing

This looks really cool, and Kiwis invented it.

InstantChess

In other news, I’ve been having real fun over on InstantChess. Their interface is quite nice as long as all you’re doing is playing and chatting with players selected for you automatically, but there are lots of bugs and interface glitches and absolutely no documentation. Here are some examples:

  • Two players agree to “increase time to N minutes” and the time is increased by N minutes.
  • Many things that look like links aren’t, or they lead to do-nothing screens. Many essential functions must be accessed by clicking on something that is not in any way visually distinguishable from information-only text.
  • Everything seems to require far more clicks and screens than are truly necessary.
  • Some of the informational text in dialogs directly contradicts what clicking on a button actually does.
  • Some settings don’t do anything at all when you change them, even though there’s an obvious expectation of what they’d do.
  • If you play an opponent at one time limit and then want a rematch, the rematch might or might use the same time limit depending on who offered a rematch to whom.

On Monday I got hit by one of the more serious bugs (improper disconnect handling that cost me a game) for about the fifth time and I’d had it. I posted to the local message board, identifying some of the more egregious problems and suggesting more attention to interface/documentation issues. What was the response? Almost every admin on the site has by this point sent me at least one flame, saying the problems are all in my head, I must be an idiot, the site’s new (too new to have these fixed means too new to be deployed live IMO) and so on. Two or three tried to be helpful, but the majority have behaved in a way that shouldn’t even be tolerated in a regular member let alone a representative of the site. How these people ever got into positions requiring social skills I’ll never know. The worst offender is the chief admin, one mysterious “DEADLYPAWN” who never seems to pass up an opportunity to belittle the people who pay for his site. He threw one of the most amazing temper tantrums I’ve ever seen online, practically foaming at the mouth and trying to force the chief forum moderator (nominally his subordinate, and one of the helpful ones) to remove me from the site. Fortunately, a calmer head prevailed and no lawsuit will be necessary, but I was still left positively amazed at what a world-class psychopath this guy is.

Interesting side point: these guys will never be profitable. They claim to have 1100 paying members, at $30/year a pop. That’s $33K/year. They also have advertising, but in today’s market nobody pays more than a pittance for that. I know something about the highly competitive online-games landscape, and about the costs involved in this kind of business. There is basically no way in the world this business is profitable for them, and they must know that. If they’re still able to pay their employees there’s only one of three possible reasons:

  • Some other line of business.
  • Really gullible investors being fleeced like sheep.
  • Criminal activity.

The last item wouldn’t normally be something I’d consider, but these guys are incredibly, notoriously secretive, and the names that rumors associate with the enterprise are in many cases names that have also been linked to Russian organized crime. Between that and his thuggish behavior – and the pictures of admins sitting in luxury cars – it wouldn’t surprise me at all if DEADLYPAWN’s primary vocations are smuggling and prostitution.

If anyone else happens to hear any rumors about the shady figures behing InstantChess, let me know. They’ve piqued my curiosity.

General News

OK, generic update for those who care about my personal life. The rest of you can leave now. ;-)

The Leonid meteor shower might not have lived up to everyone’s expectations, but I thought it was pretty cool. In about 25-30 minutes of watching I saw four really good ones and a few more glimpses. Neat stuff.

On Monday I chipped one of my lower front teeth. I wasn’t doing anything special, I just noticed something gritty in my mouth and when I checked I found that it was part(s) of my tooth. Yesterday I went in to the dentist, and we agreed to go with a porcelain laminate. This involves several steps:

  1. “Prepare” the tooth by grinding it down to a rather funky shape.
  2. Take a mold and color match.
  3. Wait for the lab to make the laminate from the mold.
  4. Glue the laminate in place and hope for the best.

The problem is that the lab takes time to make the laminate – maybe a week. Besides the fact that this leaves me walking around with exposed dentin for a week (which means no Vanilla Coke), there’s this little think about Thanksgiving and then my trip to Australia. We’re really getting close to the wire here. If things don’t go exactly as planned, I’ll either be at the dentist’s on Thanksgiving Day or we’ll have to do something temporary until I get back from my trip. Neither I nor my dentist finds either option very appealing.

Word of the Day

The latest buzzword in the business world seems to be “agile”. Everyone’s claiming to be agile all of a sudden…yeah, right. My suggestion: every time you hear a business type use this word, replace it in your mind with “shifty” or “indecisive” and you’ll be much closer to the truth.

Worst Synopsis Ever

After reading AccordionGuy’s log entry about “Harry Potter: just another pampered jock?” I was tempted to look up references to pro-aristocracy anti-egalitarian themes in Lord of the Rings. I quickly found a synopsis called “Your Homework Done For Free” at the Tolkien Sarcasm Page (which I’ve mentioned here before). It’s so totally wrong on so many points that it’s just hilarious. Imagine some poor kid turning in a book report based on this.

Internet Censorship

Paul Baranowski of Peekabooty has written a response to Bennett Haselton’s list of possible weaknesses in Internet censorship-circumvention software. In the response, Paul makes this claim:

While processor power doubles every 18 months, Nielson’s Law [sic] states that available bandwidth grows at 50% per annum. This means that over the same 18 months that processing power has doubled, bandwidth has more than tripled.

Interesting. Let’s see what Nielsen [note spelling] himself has to say about comparisons to Moore’s law, in his original article:

comparing the two Laws shows that bandwidth grows slower than computer power. Moore’s Law says that computers double in capabilities every 18 months: this corresponds to about 60% annual growth. As shown in the table, bandwidth will remain the gating factor in the experienced quality of using the Internet medium.

Annualized


Growth Rate

Compound
Growth Over
Ten Years
Nielsen’s Law Internet bandwidth 50% 57x
Moore’s Law Computer power 60% 100x

Actually, over the time that processing power has doubled, bandwidth has increased by a factor of only about 1.8 – and even that seems not to have happened since Nielsen’s article was written in 1998, while Moore’s Law has held up quite well.

On that one issue, I’d have to give the point to Bennett. The Chinese ability to filter traffic with increasing sophistication is likely to grow over time, and let’s not forget that in China the government gets to control how much bandwidth is available if they find they’re falling behind.