Tuesday, September 04, 2007
Have you heard of MarsEdit? It's a weblog editing tool. I'm impressed with it's ability to automatically ascertain the blog software used for this site. However, it was not able to piece together about the RapidWeaver version of this site. I'll have to do some research into ways to get the site editable by this tool.
Saturday, May 13, 2006
E3, yo
Long delay on the next post? Electronic Entertainment Expo? Coincidence? Perhaps not. Chew on this to tide you over.
In the meantime, I'm looking around for a different host for the journal here. Apparently Google/Blogger here won't allow me to post C/C++ document files. The second article in the Software Robustness series already has too much source code to run inline. I have to find a site that allows straight FTP posting.
In the meantime, I'm looking around for a different host for the journal here. Apparently Google/Blogger here won't allow me to post C/C++ document files. The second article in the Software Robustness series already has too much source code to run inline. I have to find a site that allows straight FTP posting.
Sunday, April 16, 2006
Source code and the web
I obviously need to dig up a better way of transferring source code into the blog here. Having to lt; and gt; my angle brackets is going to get old quickly. Anyone have a system for pretty-printing source in HTML?
Building robust software, part 1
A few years ago, I got a call from a former employer looking for game industry tips on software quality with applicability in the automotive industry. That original discussion never turned into the imagined series of speaking tours, preaching to the car makers how they should be crafting their software. Instead, I've had years to stew over the lessons I've learned on engineering practice, without an outlet. This is the first of a series of articles about the subject. The goal is to codify some ideas about how to build a robust piece of software.
A word on languages: I'm talking about C/C++ here. Since those are the languages I work in most often, they're where I feel the greatest comfort making comments. They are fairly low-level languages that expose more than hide the complexities of software development. Higher level languages like Java, C#, Python and the like are built to hide some of the difficulty. In my experience, though, if you do not understand the steps they are taking to hide complexity, you can get yourself into just as much trouble as in the low-level languages.
By far the most common source of errors/crashes I've seen in C/C++ programs is the unchecked use of invalid pointers. (Are there any non-programmers reading this? A pointer is just the address of a region of memory.) Pointers are the classic double-edged sword. A fundamental element of programming, they are simultaneously both powerful and dangerous. Pointer problems largely fall into one of three categories.
I can't say what this program will do when it runs. If the address of b is the same as a, it will crash when it derefences the value 1 as if it were a valid pointer. Then again, the addresses could be different, and it will work, obfuscating the bug until 4 AM the night before you're ready to ship. This is an admittedly contrived example, but problems like this happen all the time in software development, often in seemingly innocuous cleanup code.
A dream system will provide an easy way of resolving all those problems. In part 2 of this series, we'll try to develop such a system.
A word on languages: I'm talking about C/C++ here. Since those are the languages I work in most often, they're where I feel the greatest comfort making comments. They are fairly low-level languages that expose more than hide the complexities of software development. Higher level languages like Java, C#, Python and the like are built to hide some of the difficulty. In my experience, though, if you do not understand the steps they are taking to hide complexity, you can get yourself into just as much trouble as in the low-level languages.
By far the most common source of errors/crashes I've seen in C/C++ programs is the unchecked use of invalid pointers. (Are there any non-programmers reading this? A pointer is just the address of a region of memory.) Pointers are the classic double-edged sword. A fundamental element of programming, they are simultaneously both powerful and dangerous. Pointer problems largely fall into one of three categories.
- Not checking return values.This one is so common, they actually teach it in school. You ask for a pointer to a address, and then use it without making sure it points where you think it does. Even a read through an invalid pointer can crash you. Is it non-zero? Does it point somewhere inside your program's address space? Is the thing on the other side of it still what you think it is?
- Uninitialized memory. Suppose you made a structure, I asked for the value of a pointer in your structure, and discover that you never initialized that field? What am I getting back? What is the value of uninitialized memory? Sadly, it can look like anything. Now obviously you should initialize your pointers to known values if anyone (even you) can get at them later. But we also want a way to recognize uninitialized values for what they are. That way when the operating system tells me my program has been shut down because it tried to access (read or write) memory location 0xABABABAB, I know exactly why.
- Keeping a pointer to memory you no longer own. This is the number one source for bad data in the middle of an object that, I swear, was good just a second ago. Problems here are especially common in systems with freelist-style memory allocators that tend to hand out the address most recently returned to them. Consider this example:
#include <stdlib.h>
#include <stdio.h>
typedef struct _A
{
int val;
} A;
typedef struct _B
{
int* val_ptr;
} B;
static void kill_me( A* a );
static B* b = 0; // NULL is just a typedef for 0
int main( )
{
A* a = (A*) malloc( sizeof( A ) );
if( a )
{
kill_me( a );
a->val = 1; // a no longer points to valid memory
}
if( b && b->val_ptr )
{
printf( "B's val: %i\n", *b->val_ptr );
}
free( b );
return( 0 );
}
void kill_me( A* a )
{
free( a );
b = (B*) malloc( sizeof( B ) );
// because A and B are the same size, B's malloc may
// well have the same address as A
// even if there's something after A on the heap
b->val_ptr = 0;
}
I can't say what this program will do when it runs. If the address of b is the same as a, it will crash when it derefences the value 1 as if it were a valid pointer. Then again, the addresses could be different, and it will work, obfuscating the bug until 4 AM the night before you're ready to ship. This is an admittedly contrived example, but problems like this happen all the time in software development, often in seemingly innocuous cleanup code.
A dream system will provide an easy way of resolving all those problems. In part 2 of this series, we'll try to develop such a system.
Tuesday, March 28, 2006
Monday, March 20, 2006
NetNewsWire
The planet's best RSS aggregator, NetNewsWire, just got a ton better. I was leery when Brett announced that his little program that could had been bought by online aggregator NewsGator. I assumed that heralded the end of development. I am happy to be proven wrong. The new beta 2.1 adds a remarkably sophisticated synchronization mode with the web-based NewsGator system. Now, no matter where you read your feeds, each viewer knows what you've read, so you don't waste time cutting through a thicket of repeats when you switch machines. Because I regularly rotate among 3 machines in a day, this is fantastic for me.
I haven't explored all of the boundaries of the synchronization yet. It looks like adding or removing a feed in one place is automatically reflected it to all others. But can the home client download unread messages collected at the always-on webserver, even if they've already gone stale from the feed? That would make a convenient way to keep up with ALL of the news for the day, not just the stuff that's still being fed when I get home.
I haven't explored all of the boundaries of the synchronization yet. It looks like adding or removing a feed in one place is automatically reflected it to all others. But can the home client download unread messages collected at the always-on webserver, even if they've already gone stale from the feed? That would make a convenient way to keep up with ALL of the news for the day, not just the stuff that's still being fed when I get home.
Saturday, March 18, 2006
Cartoon plate tectonics
Here we have noted (and awesome) comic book artist Neal Adams pushing a theory that tectonic subduction is a fallacy, and that landmass reformulation instead occurs by continuous planetary growth. As is the hallmark of all good science, he uses loaded language to dispose you against the opposition view ("Well, it is a preposterous and even stupid idea").
The site features a bundle of little quicktime animations depicting his theory of planetary growth. These argue persuasively that landmasses indeed change, but I'm not as sure they support his hypothesis. It seems to me that if the planets were continually growing, they would be simultaneously flattening and losing density. I don't believe that to be borne out by the facts. I also doubt that a geologic theory which requires an ocean-less Earth can be made to mesh with the current ocean-based biologic origin theories.
Animation can be used to show almost anything, which is why it exists. After all, it would be very hard otherwise to have a whistling, anthropomorphic mouse piloting a steamboat. Adams' animations are interesting to watch, sure, and bring up some good talking points about crustal movement. They don't, however, convince me that he's got a better game than the traditional tectonic plate guys.
The site features a bundle of little quicktime animations depicting his theory of planetary growth. These argue persuasively that landmasses indeed change, but I'm not as sure they support his hypothesis. It seems to me that if the planets were continually growing, they would be simultaneously flattening and losing density. I don't believe that to be borne out by the facts. I also doubt that a geologic theory which requires an ocean-less Earth can be made to mesh with the current ocean-based biologic origin theories.
Animation can be used to show almost anything, which is why it exists. After all, it would be very hard otherwise to have a whistling, anthropomorphic mouse piloting a steamboat. Adams' animations are interesting to watch, sure, and bring up some good talking points about crustal movement. They don't, however, convince me that he's got a better game than the traditional tectonic plate guys.
Tuesday, March 07, 2006
Jury Duty
Today's jury duty was a bit of a fizzle. 3 cases out of 11 ended up calling for jurors, utilizing less than 30% of us. So it ended up being a long day of alternately glaring at the broken coffee vending machine and the sign barring jurors from leaving the waiting room. Come the end of the day, my headache had billowed into thunderstorm proportions. This dependence on caffeine makes me suspect that I would have a tough time attempting to scratch out a frontier existence. When the revolution comes, they may as well shoot me first, for all the good I'll be in a place that no longer imports freshly roasted coffee beans.
One day/one trial, they said, so I'm off the hook now. That's for petit court, mostly criminal cases. Near us was housed an opaqued room where the grand jurors convened. Apparently that stint goes for a solid month. Makes me wonder how they pick the poor slobs for that duty.
One day/one trial, they said, so I'm off the hook now. That's for petit court, mostly criminal cases. Near us was housed an opaqued room where the grand jurors convened. Apparently that stint goes for a solid month. Makes me wonder how they pick the poor slobs for that duty.
Saturday, March 04, 2006
Smoosh fan
I have lately been enamored of Seattle-based band Smoosh (warning, noise link) comprising two rather young girls named Asya and Chloe. Are they sisters? 10 years old? 15? Do they produce their own music? These are mysteries to me, but (probably) not due to a lack of available reference. I'm actually hesitant to find out the answers.
I live in fear of bumping into a quote from the girls saying something like: "I really hope you enjoy Quack, our most lyrically complex work to date", which would totally blow the illusion. I prefer the think of the girls as practicing a form of musical glossolalia. They string together series of syllables, Eno-like; it resembles language without dependence on depth or meaning. I worry that were I to believe that they were taking their lyrical content seriously, I would lose the ability to enjoy their surprisingly sophisticated sound.
If that sounds like something you can enjoy, I urge you to check them out. Just don't peer too closely at the man behind the curtain.
I live in fear of bumping into a quote from the girls saying something like: "I really hope you enjoy Quack, our most lyrically complex work to date", which would totally blow the illusion. I prefer the think of the girls as practicing a form of musical glossolalia. They string together series of syllables, Eno-like; it resembles language without dependence on depth or meaning. I worry that were I to believe that they were taking their lyrical content seriously, I would lose the ability to enjoy their surprisingly sophisticated sound.
If that sounds like something you can enjoy, I urge you to check them out. Just don't peer too closely at the man behind the curtain.