Thursday, May 15, 2008

I had a bug!

Trying to attach a physically simulated cloth to the clothes that Soshiant is wearing had me puzzled for a few days with some bugs. Well, the bug was the kind that after finding out what it was, you just wished you thought a bit deeper into the layers of code and it was in fact very easy to find out, except you wouldn't see it from the upper layer. Hmm... well, aren't all software bugs like this? Something happens, we call it a bug since we don't get what we expect and the reason it is really happening is because we do not really understand what is going on underneath. We think we know everything and call it a bug, but it is really us that has the bug and the system is working absolutely perfect. It is doing what it has to do, we expect it to do something else, because we do not know!

In order to find out about these issues with software, you would usually need to uncover the code which is being used by your code to really see what it is doing, and then modify your usage and maybe your expectations. If you see a bug in the lower layer, then you might as well be able to peel that and see what is underneath that layer or API which you are using. This is why programmers only trained in high level languages and advanced IDEs usually have problems finding the problems since they can not do this peeling and looking inside. The tools and high level constructs of the programming language abstract everything away from the developer.

What we see here is the danger of abstraction in fact. We need to use abstraction in order to be able to manage the intellectual needs of software development but any abstraction brings with it expectations. Expectations that might not always be correct or at least be dependent on many complex configurations which are not always obvious at that level of abstraction, hence we expect incorrectly and call it a bug. A car is an abstraction of a reality in which I know some details, it has to move and it needs gas.When my car stops moving because of something breaking in the engine, I look at this fact as a problem and somehow blame the car (source of problem being in an abstract part which I can not see through), but when the car stops due to not having gas (source being in the same abstraction level as I can see), I usually do not blame the car but probably myself since I am very well aware about the reason, but in reality these two are not any different.

It seems like if we are able to comprehend all the details and go deeper and deeper in the logical relationships of the code, then we can find the reason for all the bugs. Will any bugs remain? What about hardware bugs?How far can we go? Low level code, assembly instructions, machine code, hardware behavior due to physical properties, molecules, atoms .... are there any real bugs in the world? Can we relate this topic to determinism and indeterminism? If the world is deterministic then can we say there are no real bugs ever? In the story "Beyond" from the Animatrix series, there was a bug in the world, but it really had a reason in another lower level layer.

What about generalizing this concept from computer software to real life, are there any problems in the world? Or do we call some things a problem because we expect something else to happen and it doesn't happen because it should not happen and our assumption was false due to the context of the problem. If you find the reason to a software bug, you fix it and don't call it a bug anymore, can we do this with life? Can we find the reason for things we call problems or troubles and somehow be able to fix them and not call them problems anymore? Do we get really frustrated when we don't get what we expect? What "WE EXPECT!". Maybe we expect wrong. The Cynic philosophy is a bit related to this view and it all falls in the domain of epistemology. In mathematical terms, our operations should not have closure, since we need to be able to understand from a different set (layer) or in fact enter the meta-layer, or deductive closure in logic.

The above discussion can have some psychological conclusions also. People get sad when faced with problems, but knowing about the causes of the problems might be able to eliminate this sadness, either by changing something so that the problem does not happen or by changing our expectations. Can we conclude that knowledge will provide the foundation for a happier man? This is opposite to the belief that more knowledge brings more suffering which I am very much against.

No comments: