Archive

Archive for August, 2012

The source of all hatred

23.08.2012 Leave a comment

Recently I’ve read an interesting article in a well-known magazine about the evolution of cooperation. The bottom line of it was that cooperation evolves together with competition. It makes a lot of sense and can be seen in many species, including humans.

Competition is good, because it promotes individual good features. This way the good features spread among a species. This way the whole species can adapt to a changing environment.

On the other hand cooperation is also good. Those who help each other make it easier for their group to survive, while those who are selfish have it harder, so obviously the ones with more altruism have more chance to survive, thus the altruistic features spread better. Obviously individuals in any given group share more physical traits with each other than with individuals from other groups, so helping individuals from the same group or family helps the same or similar genes to survive. In some species it does not matter too much, e.g. tigers live solitary lives. Other species are on the other side of the spectrum and seemingly rely on almost total devotion, such as ants.

All species evolve together with a balance between competition and cooperation. It’s hard to say arbitrarily what the balance is for each species exactly, but it is certainly different between various species and depends on their traits and environments – apparently competition is more important for tigers and cooperation is more important for ants. One could determine clues on why this is, but it’s not important here.

So what struck me in humans is that cooperation leads to promoting and supporting their own groups. For example people of the same race, religion or hobbies, etc. tend to stick together in order to cooperate. But at the same time they may be competing with other groups. This is rooted deep in human nature and goes back way before tribal groups, back to apes. Chimpanzees share similar behavior, while they cooperate within their groups, they sometimes fight between groups. So while cooperation makes us like people similar to us, competition makes us hate others who are different from us.

When you look at it from this angle, it explains the existence of many of the bad human features, such as racism, hatred, etc. They are rooted in humans and were one of the primary tools of human evolution. On one hand the good features such as altruism helped humans survive as a species in their environment, on the other hand the bad features which were helping promote individual genes, were the result of competition.

Humans are getting less aggressive these days and due to globalization and cheap travel they and their cultures mix. Eventually there will only be one group.

Next time you see hatred, don’t ask where it’s coming from, think of this post.

Categories: Universe

Evolution

19.08.2012 Leave a comment

Most people consider evolution just a proven biological theory which explains biodiversity and how humans came to be.

But I think of it in a different way.

I don’t know if you’ve heard of meme theory. In my definition a meme is any cohesive set of information which together makes a whole. Examples of types of memes include stories, books, gossips, religions, computer programs, food recipes, designs (mechanical, architectural), movies, songs, etc. A notable example is of course information encoded in chromosomes about an individual organism.

Memes are copied very easily. For example stories are told and repeated, books get revised, movies get remakes, designs get fixed and improved, creatures reproduce, etc.

When memes are copied, they are also often modified for whatever reason. Sometimes on purpose, sometimes because of errors. When you look at a history of a meme, it will look like a graph. Multiple copies may be modified in different ways. In time the meme changes.

This is evolution.

So in my definition, evolution is change which happens to any kind of memes or information over time. This change is inevitable. Even if there is no practical need to change memes, they often change due to errors resulting from the imperfectness of the medium (such as human memory, errors when copying genes, etc.)

To many programmers this is no news, since “genetic algorithms” are very useful in searching enormous parameter spaces for local maxima.

Evolution is everywhere and governs the change of everything.

Categories: Universe

Rewrite from scratch?

7.08.2012 Leave a comment

One day we’ve decided to import a piece of code of a significant size from another project. It made perfect sense and allowed us to avoid spending months to write what others have already written. This happens quite often in many projects, because code reuse saves time and money.

After making it work, days later we’ve discovered saddening truth. Lots of resource leaks! The source project was sloppy with resources, because it did not matter much in that particular project and perhaps they don’t have the right tools to even know about the resource leaks’ existence.

A few hours spent with a leak checker revealed that even though the code was written in C++, it was written in a C-like fashion, with objects allocated directly with new and stored in raw pointers without ever being released. Some containers were semi-hand crafted, though they used STL containers underneath, but holding raw pointers.

Lots of programmers given such code would scream: “Rewrite from scratch!”. But is it really such a good idea? I don’t think so. I don’t doubt that there are projects which absolutely need a rewrite, but in many cases refactoring comes to the rescue. In the end refactoring is a less costly alternative. If there are tests for the original code (hopefully!), the approach is to slowly fix the code. In this particular case the first thing is to gradually introduce the right resource allocation and management mechanisms which are not prone to leaking.

The size of the task of importing foreign code is hard to estimate. One of the reasons is that taking code from one project and putting it in another, new environment will make the code behave differently enough to reveal obscure bugs. On the other hand if that code remains maintained and shared between projects then its quality will improve. So everybody can benefit from reusing, and if needed refactoring and fixing existing code.

Categories: Computing