Archive for August, 2007

Broken Programs

I’m a programmer by profession, so I sometimes wonder: why are most programs so bad? All sizeable programs are full of bugs. Mostly these bugs don’t matter so much, but why are they there? If computer hardware had as many glitches as computer software, computers would never manage to boot up at all.

My current suspicion is that one of the root problems is underspecified interfaces. All programs are stitched together out of a number of different modules. Those modules all communicate via interfaces. The interfaces are generally documented reasonably well, but they are underspecified. Rarely does the interface say “you must be able to allocate 10M of memory” or “your network must be working” or “you must not open a dialog box now” or “the user must have logged in.”

To put it another way, every module of a program makes a set of assumptions about the environment in which it will work. Those assumptions are normally implicit. Violating those assumptions will cause unexpected behaviour. That behaviour will sometimes be a bug.

Other engineering disciplines spell out their assumptions in detail, apart from physical assumptions like “object will be constructed on planet earth.” For example, structural engineering drawings for a house specify exactly what bolts and nails should be put where, and the calculations show exactly how the load will be borne. A safety factor is included, to protect against unexpected weakness in the materials, or shoddy work by the builders.

Why are there so many implicit interfaces in computer programming? Because programs are very complex. We simple don’t know how to design and implement very complex systems.

How can we make this better? I don’t think the answer is to implement better interface specifications. I think it is more likely to be to make programs much much simpler. The growing use of tiny applications is a positive step–except, of course, that they must run in a very complex environment. One of the significant advantages of Unix when it was developed in the early 70s was that it implemented sets of small programs, and provided a very simple way for them to communicate: the pipe. Unfortunately, while the pipe is very simple and convenient, it is not enough to construct a modern application.

I think that when working on a complex program, ones primary goal has to be to continually simplify. Individual modules should not make any assumptions. Communication between modules should be explicit. Modules should be idempotent whenever possible, and when they must store data it should be explicitly stated in the interface. Development tools should enforce these conventions.

I know that none of this is original or new. And we have learned things over the years: todays systems are much more complex than the systems of thirty years ago. But they still have just as many bugs, and it seems like the bugs are harder to fix. We have a long way to go.

(I’ll be travelling for the next couple of days, and may not post.)

Comments

Escaping Malthus

How have we escaped the Malthusian trap, and is our escape only temporary? Malthus argued that human population was naturally at the limit of what resources could support. To put it another way, the very poor were always on the edge of starvation. Any increase in resources would only bring temporary respite: the population would increase, and once again the poor would be starving.

While a good part of the world is still in a Malthusian regime, it is clear that the western countries are not. Why not? Malthus’s argument is fairly general and fairly strong.

The escape would seem to be due to technology. Not just technology, but the ability to harness energy not directly produced by humans and animals. It’s sometimes difficult to grasp, but just 250 years ago there was very little non-human, non-animal energy available. People used water-wheels and windmills to grind wheat, and they used wind power to move boats, and they used gunpowder to fire weapons. But food was grown and distributed entirely by human and animal labor.

The invention and commercialization of the steam engine, and the subsequent industrial revolution, provided a new source of power. According to Malthus’s argument, the population would have been expected to grow enough to consume all the newly available resources. But that didn’t happen. It didn’t happen because the new machinery generated so much power that the human population could not grow fast enough to use it up. For the first time in human history, resources grew faster than population.

It’s worth considering where those resources came from. Initially they came from burning wood. But pretty soon, people burned coal. Later came natural gas and oil. That is, the industrial revolution was based on consuming solar energy which was collected by plants and then stored in the earth over millions of years. The process of creating new coal and oil is ongoing, but the existing resources were consumed at a completely unreplenishable rate. The key to escaping Malthus’s argument turns out to be the consumption of resources which were previously unavailable, and to consume them at an extraordinary rate.

We’re still doing that today, of course. This raises the spectre that Malthusian life has only been evaded temporarily. When we run out of oil and coal, our resource usage may crash, which will be followed by a population crash, and human life will return to a Malthusian regime.

Can we escape that? One interesting fact we’ve discovered is that when people have sufficient resources, they have fewer children. This seems to be true in a number of different cultures. This is something which Malthus did not anticipate, as it implies that given sufficient resources, there is a natural limit to human population.

Do we have sufficient resources? Today, we clearly do not. The wealthy countries are consuming stored solar energy much faster than it is being created, and the poorest countries are essentially Malthusian regimes. Can we find new sources of energy? There are many possibilities. The only ones which could possibly work in the long term are the ones which are unbounded at human scales: geothermal energy, solar energy, and fusion power. Wind and tidal power use the rotational energy of the earth, which effectively can not be diminished, but they don’t seem to provide enough energy for us, so they can’t be a complete solution. Ethanol is a form of solar energy. None of the possibilities are sufficient today; the question is whether we can make them sufficient before our current energy regime expires.

Our current society is similar to a gambler who borrows money to start playing roulette and keeps putting his winnings back on the table. It is possible for the gambler to finally win enough money to come out ahead. It is also possible that the gambler will wind up losing everything.

Comments (4)

Immigration

Why do we have immigration restrictions in the U.S.? Does it make sense to advocate for free trade and free flow of capital without also permitting free flow of labor?

It’s interesting to ponder how much immigration would increase if there were no restrictions. Many people enter the country one way or another despite the restrictions. Would that jump enormously if immigration were legal? I don’t see why. There aren’t that many jobs for unskilled people who can’t speak English. Life in the U.S. if you are poor and don’t have a job is not so great, and is worse than in many other countries. On the other hand, there is the advantage of getting your children into the free public school system, where they will learn English and presumably be able to get a job themselves. How much would things really change?

We’re not likely to ever find out. There seems to be a real paranoia about immigration in some parts of the country. While immigrants certainly compete for jobs with unskilled workers, for other people they make the country wealthier. I think that people cite economic worries, but they are more concerned about social issues. Immigrants are by definition not like us, and immigrants in large numbers change the nature of society. It would be foolish to consider that to always be a good thing.

A different immigration issue is that of the skilled workers who come in on H1B visas. They clearly make the country wealthier, but people try to keep them out using the argument that they lower the salaries of workers already in the country. That doesn’t fit my personal experience. High tech jobs are hard to fill. H1B workers aren’t taking those jobs away from other people, they are filling jobs which would otherwise go unfilled. I’m sure there are exceptions, but that seems to me to be the general rule.

There is this advantage to immigration restrictions: they help preserve existing cultures from homogenization. Losing cultures is like losing languages: we lose ways of thought. It’s better for all of us if people around the world think about problems in different ways, assuming they can still find ways to talk to each other about their approaches. In these days of instant communication and world-wide media we will tend to lose that, but we may make it up by the small subcultures we are breaking into.

I see that I’m being inconsistent here with my thoughts a few days ago about the common narrative provided by the media. In that case I was thinking within the country, and here I am thinking about the whole world. Still, there is a clear inconsistency; something for me to think about.

Comments (1)

Medical Expenses

So why is health care so expensive in this country? This is a subject I don’t really know anything about, which gives me even more opportunity than usual to speculate freely and leap to broad conclusions.

Obviously a big chunk of it is profits taken by pharmaceutical companies, profits which would have much more justification if they spent a higher percentage of their income on actual research and development rather than on marketing. But that must be less than half of the overall cost.

Some of the health care spending is simply taken by the insurance companies, and by the extensive paperwork processing they require. I don’t think this is more than ten or fifteen percent, though.

What about the rest? Doctors are very well paid. Medical procedures generate extraordinary amounts of waste–I am regularly astonished by the amount of waste which is produced when I merely donate blood. Hospitals don’t actually collect money when they treat uninsured patients, so they have to charge more for everybody else. Medical machinery is very expensive–this is a version of the problem with pharmaceutical companies.

Can we reduce medical expenses? There are some obvious points of attack. We can tighten up drug patents considerably to cut pharmaceutical pricing. We can restrict drug marketing to cut their expenses; there will still be plenty of opportunity for wealth. We can fix the insurance problem. We can pay doctors less. We can unify health records and store them electronically, reducing duplicate tests and reducing paperwork costs.

Does it make sense to reduce expenses? Letting people become rich will encourage the best people to enter the health care field. Of course, this would be more convincing if the U.S. had the best health care in the world, which in general it does not, but it is certainly possible that wealthy people in the U.S. do have the best health care.

I don’t know the answers here. But it seems to me that more people need to be looking into this. Lots of people talk about reducing costs by moving to a single payer system, which certainly makes sense to me. But there is a lot more scope for cost reduction. Health care costs can not continue to grow without end, and therefore they will stop. We need to spend more time thinking about how to stop cost increases in ways that make sense.

Comments (11)

W. Richard Stevens

I was thinking about W. Richard Stevens the other day, when a colleague bought one of his books. I think the books he wrote are still unquestionably the best books on Unix programming and on TCP/IP. I first got in touch with him when I sent him a long list of errata for Advanced Unix Programming. I used to have the habit of noting down errors when I read technical books, and sending them to the authors. He was the only person who ever replied. We would up exchanging dozens of e-mail messages over the years. I was a proof reader for several of his later books, and wrote a back cover quote for TCP/IP Illustrated Volume 3. He was always very interested in his subjects and very supportive.

I only met him in person once, at the LISA convention in Boston. We spoke for about an hour. He said he thought the reason his books were so good was that he didn’t know anything about the subject when he started, but had to learn it as he want along. In retrospect I think it was really because of his ability to use diagrams effectively, and to write very clearly and concisely about technical matters. Both skills are rare in technical writers. He also did a good job of writing small example programs to show how things worked–these were the same programs he wrote to find out how things worked himself. I don’t do much really technical writing myself, but I aspire to his level.

That LISA convention was in December, 1998. He died less than a year later, at the age of 48. It was a very sad shock for me and for many other people. When we die, all that really remains are the memories that people have of us. I didn’t know Rich well, but I knew him well enough to remember him.

Comments

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »