?

Log in

The Broken Hut
Working my way up to a full-size building
Recent Entries 
7th-Jun-2007 01:58 pm - Fixing broken programs the easy way

All software of sufficient complexity to do something useful (and even some that don’t do anything interesting at all) will contain bugs. This is a fact of life.

It’s the job of the programmer to find and remove these bugs. There are many ways of going about this but the most interesting, I think, is using a tool called a debugger.

If you’re a doctor, probably the best diagnostic tool you could imagine is to take a patient and cut them open and watch their innards move around, undisturbed, as they go about their daily lives. Imagine you could puncture a huge hole in someone’s chest to examine their heart and lungs while they sit there in the consulting room, chatting away amiably.

Unfortunately for the medical profession, people tend to cry out in great torment, flop on the floor and bleed everywhere if you do all that. (Though something very similar does come up in Use of Weapons by Iain M Banks, where it’s used as a party gimmick!) But programmers can get away with it.

A debugger is a tool that lets us run programs with their innards on display to the world. If something bad happens we can rewind to see what conditions caused it. We can see the last actions of the program before it did something stupid. Why did the user’s high score suddenly change to -2147483648? Why does it crash every time I click Save?

The debugger will even let you ‘run’ the program in discrete steps, like advancing a frame at a time. Or you can pause the program whenever you need — on every autosave, or every new wave of aliens, or just as the whim takes you.

If you see a problem you can tinker with the program as it runs. It would be like your doctor reaching in to ‘fix’ up your plaque-hardened arteries while you are in suspended animation, then releasing you to see how you feel. Pretty neat.

Debuggers are not much use outside the programming field. In fact, they’re one of these specialised tools that people can’t even imagine until they’ve seen one. But they’re also extremely cool, which is what counts.

16th-Dec-2006 05:13 pm - Bugs: Numbers too big, can’t cope!

Today I’m going to talk about how your computer cup can runneth over. So let us look at integer overflow.

You’ll have seen this all over the place but probably didn’t know the reason it happened. If you download large files you sometimes see it, where the file claims to have a negative size. It can also happen in the opposite direction, where numbers get so negative they suddenly become positive again. This wrapping round is called overflow (or underflow when negative numbers become positive).

Tough on integer overflow, tough on the causes of integer overflowCollapse )
This page was loaded Aug 28th 2015, 12:39 pm GMT.