<$BlogRSDUrl$>

Friday, January 30, 2004

Sorry for not posting more 

I've been in coder monkey mode for the last couple of days. But good news- the bit blit routine works! Getting all the corner cases correct is most definately NP-annoying. Now if I can just get the assembler version working...

While I'm muttering, I wonder- how many people are actually reading this Blog regularly at this point? Hit the comment link below and say hello.

Tuesday, January 27, 2004

New reasons why C++ sucks 

I've just discovered that if my browser (Mozilla) crashes after I post a message, but before I publish it, when I restart my browser and come back, I can't publish my unpublished articles until I write a new one.

My browser only crashes because it is written in C++, and is therefor prone to memory leaks and wild pointers and corrupted memory. And, after running so long, or hitting the wrong web page, or opening too many copies of itself, or on days that end in Y, it has a bad habit of crashing without warning. So I decided to write an article about how C++ sucks. That way I'll at least be able to publish my articles.

First of all, all the arguments about how you can add garbage collection to C++ don't work in practice. Yes, you can add the Boehm-Demers-Weiser Garbage Collector, unless of course you're linking in a library that already overrides ::new(). Like, say, QT. Garbage collection should be designed in. Take a gander at that page, especially the advantages and disadvantages of Garbage Collecting C and C++ programs, and this paper. Oh, and while you're at it, this paper and this paper and this FAQ and this book. And so on. But hey- why let facts get in the way of a good theory?

C++ is not parsable. This isn't even something as mundane as a shift/reduce conflict- although my experience has been that if you have a shift/reduce conflict in a LALR(1) parser, you have a potiential for a bug (this is a fault I will lay at the feet of Ocaml- it has way too many shift/reduce conflicts in the language grammar). The classic shift/reduce conflict is C's dangling else. Which does cause real program bugs. And which, of course, C++ imported wholesale, but that was because it's a (more or less) superset of C. No, when I mean C++ isn't parsable, I mean something deeper. Consider the following sequence of tokens:
a < b , c > d;

Is this a) a weird expression using C's comma operator, and grouped like (a < b), (c > d), or a variable declaration using templates, and grouped like (a < b, c >) d? Even typing information doesn't help you- the same identifier can be both a variable name and a type name/template name simultaneously. This language is unparsable.

If they had simply used some different tokens than < and > for templates, these issues could have been avoided (not the other issues I have with templates, like code bloat and misuse, but at least the language would be parsable). This highlights the Ur-flaw as it were of C++. Effectively, it was designed by committee. A committee that would approve major language features, like templates, without them ever having been implemented- because even the most cursory implementations would have demonstrated the parsing problems and caused a change in tokens. Rather like the C99 committee (and there's a rant for another day).

In a way, I'm glad C++ has operator overloading. Because now I can state definitively that it's a bad idea, whereas before I was just unsure. It creates bugs, gets misused more often than not (even not counting iostreams) and is often not used by the very people who are most supposed to benefit from it (numeric programmers). Consider the following code:

int i = 3;
cout << i << 2;

What does this print? Does this print '6' or '32'? Now, for bonus points: what did the writer of this code intend to print out? And simply saying the programmer should refrain from making this mistake is missing the point. I'd love to stop making mistakes. I just haven't figured out how to yet. People new to programming make simple mistakes like the above for simple reasons. Seasoned professionals make simple mistakes like the above for complex and subtle reasons. And I've yet to be a on a programming team of more than three people without at least one yahoo who thinks he's being clever. This is not even counting the times I was a yahoo too.

I would actually count iostreams as a serious misuse of operator overloading- in that it weakens and obfuscates what an operator means- even to the most experienced C++ expert imaginable. In this slashdot interview, Bjarne Stroustrup himself demonstrates this confusion when he says, and I quote:
For example, It's clearer to say that a class must have a << operator than to say that it must be derived from "Printable" (that then has a << operator).

To the inventor of the language it is no longer clear what the "real" meaning of the << operator is- output, or left shift. There are classes I can easily think of that might want to implement both meanings of the operator- a bignum class, for example. But even ignoring iostreams, in the C++ code I've seen I see operator overloading abused more often than used legitimately. How many classes overload ++ so the authors can use for loops instead of while loops? Even when the concept of "successor" is entirely meaningless? There is no way C++ could gaurentee that the code that implements the operator actually fullfills some expectation of how that operator behaves. Operator overloading is the 21st century equivelent of old FORTRAN programmers redefining the number 2.

And lastly, the people who are most commonly cited as needing operator overloading- numeric programmers- tend to avoid it. Especially if they've had any experience with C++. The problem is temporary creation. If what you're dealing with is sufficiently small, like complex numbers (the classic example), then temporary creation isn't a problem. But if what you're dealing with is 1024x1024 dense matricies, temporary creation is very much a concern. And no, inlining does not solve the problem- optimial matrix multiply routines, for example, are difficult to inline (read this paper on the importance of blocking and copying to matrix multiply- and the remember that this makes matrix multiply a recursive operation).

Well, that's enough flaming on C++ for now. You will no doubt get more next time I have to work with the bastard. Or the next time my browser crashes near the end of a long post.

Quote of the day 

I do have to make fun of Attny General John Ashcroft for this quote, it's a moral imperitive:

"Weapons of mass destruction including evil chemistry and evil biology are all matters of great concern, not only to the United States but also to the world community. They were the subject of U.N. resolutions," Ashcroft said.


I have to agree with Ashcroft- there is certainly signs that both chemistry and biology were taking place in Iraq before the war. And we know that both chemistry and biology are evil, because they scientifically support evolution and not creationism, and therefor lead to godless secular humanism. Praise the Lord that we have George W. Bush in the Whitehouse, who is committed to stamping out chemistry and biology everywhere- even on Mars, which was recently discovered to have chemistry, and maybe even biology!




Iraqis want to see Saddam's allies stand trial with him 

Kudos to Michael Moore for pointing me to this gem. It seems that many Iraqis want to see Saddam's allies- specifically, us, or more specifically, the Bush administration, put on trial for war crimes right next to Saddam.

I guess the "Liberation- from the people who brought you the original Oppression!" advertising campaign wasn't as effective as we had hoped it would be.

Monday, January 26, 2004

Fear and Loathing at HP 

Personally, I think a new level of hell is being prepared for Carly for when she finally shows up, for what she did to the HP calculator division. But that's me. I see some of my predictions about the future of HP are comming true.

My basic feeling of what is going at HP is comprised of two points. The first is that HP is not the company Carly wanted to run. At a guess, the company she really wanted to run was Dell. Dell makes sense from an MBA's standpoint- do it faster and cheaper. HP's technical culture simply doesn't make sense in MBAville. I've experienced companies managed by management that really wanted to run some other company, and it was a diaster. Management made decisions that either only made sense in the context of the other company, not in this company, or that they felt would work to change the company to be more like what the company they really wanted to run. Notice how in neither case are the decisions noted for making sense for this company and this situation. The Compaq merger was a classic example of this- it was a way to bring in a more Dell like management structure. As was killing the calculator division (despite the fact that it was a profit center)- Dell doesn't make calculators.

The second point, which is really a variant of the first, is that the MBAs have taken over HP at all levels. Carly election to CEO was just the final acknowledgement that it's been all downhill since Bill and Bob left. See, HP used to be famous and/or infamous for being an engineer run company. Because that's what Hewlett and Packard the men were- old school engineers. Now the MBA's are in charge, the company will be incapable of making a rational engineering decision for the forseeable future. See, the rational engineering decisions will always be proposed by those who best understand the engineering issues- the engineers. And were a manager to actually follow the recommendations of his engineers, that would create the image that the engineers and not the managers were in charge again- among the poor guy's fellow managers, if not among the engineers. In companies where there is no question that the managers and not the engineers are firmly in charge, and managers will not face repurcussions for acquiescing to engineering requests, sane decisions can still be made. Not so in HP. They've got to put those unruly engineers in their place!

Unfortunately, once corporate insanities like this get wedged into a corporate culture, I have no clue how they can get unwedged. The manager makes dumb decisions (like kill calculators, merging with Compaq, and betting the future of the company on the Itanium), and then later needs to either admit that they screwed up (yeah, right- that'd be worse than agreeing with the engineers in the first place!) or defend to the death that it was the right decision, despite the overwhealming evidence to the contrary. Which means the insanity gets metasized. The logic of paranoia is that it's never safe to relax.

So, as much as I hate to say it, we're seeing the death throes of HP. It's sad- it was a good company, back in the day.

The Truth Deficit 

Today's required reading is this screed from Cal Pundit. At the very least, take a look at the graph. The report from the Congressional Budget Office has a baseline that shows us getting back to balanced budgets in 2011, and maybe a $200B surplus by 2013. But, if you add in all the goodies that Bush has already asked for, he has managed to turn that surplus into perhaps as much as a $800B deficit. That's a $1 trillion dollar turn around.

Here's the problem I have. According to the CIA World Fact Book, the US has a gross GDP of $10.45T. With a debt of $7 trillion dollars. In other words, the federal debt is already 67% of our GDP. But the Bush Administration is seriously proposing to add $500B to $800B a year in new debt between now and 2013. That's another $5-8 trillion in debt, making our total debt $12-15T. And, at current rates, our GDP will only grow to about $15.5T.

The last time the US Gov't was this heavily in debt, we had just finished defeating global fascism. What do we have to show for the debt this time? Even worse, who holds the debt has changed. In 1945, the debt of the US Govt was largely held by US citizens, with a personal stake in the American goverment (aka patriotism). Today's debt is primarily held by foreign investors, looking for good returns on the money they've made from the US trade deficit.

"Recipie for diaster" doesn't begin to cover it. We can go too often to the well- the supply of credit for the US Gov't to consume is not endless. And a bankrupt goverment can not do much of anything for anyone- stimulate the economy, provide for the well being of it's citizens, or even provide for the common defense. The best it can do is inflate the currency like mad in the hopes of getting out of it's trap- a cure almost as bad as the disease. Which is why this election budget matters are second only to fundamental issues of preserving our democracy. And why everytime on of these articles comes out, it instantly becomes the required reading of the day.

Billmon and the Blogs 

I'm reading this screed from Billmon about how the social elite have discovered blogging. I found the one advertising exec talking about swooping in and buying up blogs while they're still cheap to be incredibly humorous. If she's reading, Bogonomicon is up for sale- opening bid is a measly five million dollars. Call me, baby- we'll do lunch.

The freeloader problem is interesting, and, in the context he presented it, unsolvable. His fundamental flaw is assuming that the only reward for doing something is monetary. If you don't pay for it, it doesn't get done, or isn't worth anything. I call this the libertarian fallacy, as "mainstream" outlets which call themselves libertarian- for example, the Cato institute- tend very strongly to make this mistake. This is also a very common mistake made when considering open source software. If we don't pay our programmers, how will software ever get written? The trick is, once you realize that not all rewards are monetary, a number of otherwise unexplainable phenomema become readily explicable.

And the "mainstream media" is not as indispensible as it thinks. Yes, their is this romantic image of reporters meeting trenchcoat wearing deepthroats in shadowy garages, dodging hails of bullets as the bad guys try to scare them off the story, and yelling "stop the presses!" as they break the pulitizer prize winning story of the century. But how much of that goes on in reality? And standing against that you have Robert Novak- who is just one of many "journalists" who make their living dutifully parroting whatever spin is comming out of the halls of power.

OK, Billmon can't afford to go to Iraq himself, and neither can I. So if the news media doesn't exist, who is going to report from Iraq? Umm, how about the Iraqis themselves? Every Dean event is followed by a spate of blogging entries as eye witnesses report. In blog space, everyone is a reporter, therefor any event with human beings in attendence has potiential blog-space reporters there. And if a tree falls in the woods and no one is there to witness it, is it news?

And objectivity isn't an argument either- primarily because I don't beleive objectivity exists with humans. Heinlein said one of the most artistic ways to lie was to tell the truth, just not all of it. The old gray lady herself, therefor, is telling you right on their masthead that they're lying- "All the news that fits in print". Not all the news, just all the news fits. Which, since it isn't all the news, it becomes a question of what aren't they telling you- and there (if nowhere else) does bias sneak in. What qualifies as "news"? And, if you've somehow gotten the notion that Bogo is fair and balanced, let me correct you right now. Bogo is unfair and horribly biased, almost as badly as the TV network which uses the "fair and balanced" slogan. Caveat lector- beware of the physciatrist with the odd eating habbits.

Which is the biggest value a blog can bring- the chance to tell your side of the story. The city council meets to discuss the highyway bypass. In attendence is the half a dozen city council members, fifty concerned citizens, and one reporter. The next day, only one person's viewpoint is printed- the reporters. And 56 people are left screaming at the newspaper "that isn't what happened at all!" It's not money that will drive those 56 people to write up their experiences of the meeting, it's the chance to set the record straight. And maybe make a difference in the city plans.

When thinking about starting this blog, in what I envisioned it might someday mean, the thought "and then we make money off it" never crossed my mind. Indded, I would argue any attempt to turn any blog into a "profit center" would destroy the blog- Bogonomicon, or Kos, or Instapundit. I did dream that one day I might have a vast readership- maybe even more than a dozen people :-). And therein lies the value of Bogo to me- it's the ability for me to affect the debate, and maybe put some ideas into people's heads. Bend reality a little closer to my heart's desire.

Which is why the death of mainstream media doesn't frighten me. And I think it's going to happen sooner or later anyways- as everyone who isn't a reporter stands to benefit. Five hundred years ago the invention of the printing press doomed the goverments based upon hereditary nobility. I imagine the dukes and earls asked each how on earth goverments would manage to function without control being firmly in the hands of the nobility. The answer, of course, was "just fine, thank you very much".

Dean & Roses 

Smirk of the day- this take on the Dean Iowa speech.

Sunday, January 25, 2004

The physics theory I like... 

...is that the mysterious "dark energy" that is expanding the universe against the force of gravity is, of course, the expanding pressure of the storage requirements of google groups.

The fact that google groups, and therefor the web, is expanding faster than light does not violate relativity, however, as no information is being transmitted.

This page is powered by Blogger. Isn't yours?