Saturday, September 26, 2009

Forgetful Loops

Consider a software algorithm that builds a tree in a computer program. Typically when you build a tree you would have a recursive loop in which tree nodes are created and connected. The loop will have an entry and an exit point.



You might also recycle the same tree builder algorithm to build a parallel tree, an almost identical tree with only its target context being different. For example tree1 is supposed to be an observer of explorer style representation, whereas tree2 observes a column based representation. So the nodes of each tree might have a different type, their properties are determined and their behavior are dictated by the context they live in.



Let us now assume that we are living in a universe UR.

One way of comprehending our universe is thinking of it as a gigantic Hilbert Space. A vector-space that represents the state-spaces of quantum mechanical systems is also a Hilbert Space.

Think about every atomic particle that makes you, they have a certain position and momentum at any given time, i.e. they can be represented as vectors. And when I say 'at any given time' I mean the time of our vector space. Together with other quantum mechanical systems, such as the coffee mug, the earth, the sun, the milky way galaxy and so on, we are all part of one big vector space.

Another way of visualizing our universe is thinking it as a space-time sheet or fabric, on which every vector stays on the same fabric, moving in random directions and changing their magnitude all the time.

Returning back to our tree building problem, there is no reason why you would not build parallel trees by running the tree-builder algorithm sequentially, so you build the tree1 first followed by the tree2 and so forth.

After all our program runs in the realm of our universe, in the same space-time fabric. So the loops building these trees would occupy different localities on our universe's space-time since they are built at different times, nevertheless they lie on the same sheet of space-time.

Suppose now that there is a glitch in your program so that while executing the first loop to build tree1, the program suddenly switches its context, enters into the second loop and starts building tree2.



You may be surprised to find that when the program finishes building the second tree, and returns control to the loop of tree1, instead of the iteration continues where it left, it might leave the loop prematurely with tree1 left incomplete.

Suppose also that the glitch causing your program to suddenly leave the first loop at the first place is not avoidable. This also implies that your trees are NOT built sequentially contrary to your intention (design).

The only way to fix this software problem is to SAVE the loop's iterator prior to leaving the first loop, and RESTORE it back when the control is returned prior to the loop iterator is incremented.

The loop needs memory of where it left prior to making the jerky switch, otherwise it fails to restore itself.

This is a remarkably common pattern in mathematics, theoretical physics and literature no matter how speculative its representation might turn out to be.  Think about wormholes, multiverses, Alice's Adventures in Wonderland, The Magician's Nephew, and The Lion the Witch and the Wardrobe.

The loop is like consciousness. Suddenly leaving the realm of loop1 is like entering into a shortcut, a wormhole and finding yourself in the realm of loop2, a different consciousness in a different universe.

However there is one crucial difference. In literature we are biased to think that the heroes maintain their consciousness. They remember other realms when they return. This gives the audience a comforting cozy feeling.

I tend to think though there seems no need to remember your previous conscious presence in one realm or the other. All you need is a functioning anchor when you return. You might pretty much succeed as a forgetful loop provided that your anchor works.

Wednesday, September 16, 2009

The Consolations of Philosophy

I finished reading The Consolations of Philosophy, by Alain De Botton, a contemporary philosopher.

De Botton takes us to a journey in the garden of philosophy and gives us consolations for unpopularity (Socrates), not having enough money (Epicurus), frustration (Seneca), inadequacy (Montaigne), a broken heart (Schopenhauer), and difficulties (Nietzsche) buy looking at tragic life stories of these great philosophers. Ironically each one of these men witnessed the drama of integrity of their philosophy tested upon them.

I would like to quote my favourite passages from this fantastic book:
"Yet there is a danger that Socrates' death will disuse us for the wrong reasons. It may foster a sentimental belief in a secure connection between being hated by the majority and being right…We may be neither geniuses nor saints. We may simply be privileging the stance of defiance over good reasons for it, childishly trusting that we are never so right as when others tell us we are wrong.This was not Socrates' intention. It would be as naïve to hold that unpopularity is synonymous with truth as to believe that it is synonymous with error. The validity of an idea or action is determined not by whether it is widely believed or widely reviled but by whether it obeys the rules of logic. It is not because an argument is denounced by a majority that it is wrong nor, for those drawn to heroic defiance, that it is right.The philosopher offered us a way out of two powerful delusions: that we should always or never listen to the dictates of public opinion.To follow his (Socrates') example, we will best be rewarded if we strive instead to listen always the dictates of reason."

Thursday, September 10, 2009

Apple Keynote and The Rise of Self

Today I watched the 2009 Apple Keynote. People cheered and applauded thin and frail Steve Jobs for minutes who had undergone a liver transplant surgery last year. I have great respect for the guy, and I adore Mac computers (I own one).

The IPod touch, IPhone and IShuffle look sexier, more powerful, cheaper and sleeker than ever.  It is impossible to suppress your urge to have one of those toys.

Steve Jobs also mentioned a new feature called Home Sharing. It is now possible to share movies and music on up to five computers in your family computer network.

I can't help thinking though isn't it somehow sad to imagine a family of five, who hardly wait to finish their dinner to run into their room and start playing with their toys in their secluded own little virtual world? Can we call these people a family any more? Is a virtual family a family?

Where is the wisdom of learning something intimate from your father in a cold night over a cup of tea, rather than gazing at Wikipedia? Where is the charm of listening to stories just before midnight about mysterious family members who did something strange and who passed away long ago. How about funny stories about how your dad and mum met, and deliciously funny visualisation of them as teenagers? Do we have to bury these things with technology? Is this what we call progress?

Sunday, September 6, 2009

Human Skin

Natural Selection does not produce perfection. If your genes are good enough your offsprings will make it to the next generation. This is obvious in the populations around us. Individuals may have genes for genetic diseases, or they may not have genes to survive adverse conditions. No population or organism is perfectly adapted.

Dr. Nina G. Jablonski, who heads the anthropology department at Pennsylvania State University said:
"There was a tremendous takeoff in human evolution about two million years ago when primates who could no longer be called apes appeared in the savannahs of East Africa. These early humans ran long distances in open areas. In order to survive in the equatorial sun, they needed to cool their brains. Early humans evolved an increased number of sweat glands for that purpose, which in turn permitted their brain size to expand. As soon as we developed larger brains, our planning capacity increased, and this allowed people to disperse out of Africa. There’s fossil evidence of humans appearing in Central Asia around this time.."
"Skin color is what regulates our body’s reaction to the sun and its rays. Dark skin evolved to protect the body from excessive sun rays. Light skin evolved when people migrated away from the Equator and needed to make vitamin D in their skin. To do that, they had to lose pigment. Repeatedly over history, many people moved dark to light and light to dark. That shows that color is not a permanent trait."
This illustrates neither darker nor lighter skin coloured populations are perfectly adapted to climate variations in different parts of the world. In winter an African American living in Northern USA must expose her skin to sun rays for much longer periods in order to have adequate vitamin D absorption. Similarly lighter skin coloured individuals who live in sunny climates are less protected against harmful UV radiation due to their skin's increased light absorption capability.

References:
evolution.berkeley.edu
nina.jablonski.nytimes.interview.2007
nina.jablonski.ted.video

Friday, September 4, 2009

Security and Evolution

In software development there seems to be an inherent 'arms race' around security. External predator software to breach software's security holes is in constant 'arms race' with the software's capacity to repel them. This kind of tense relationship recalls eternal struggle between prays and predators in nature. The pray develop a defense mechanism and survive better and longer say with a camouflage, then the predator develops a counter-measure and the arms race continues indefinitely (people will always attack browsers, browser vendors will always have to deal with them).

Wednesday, September 2, 2009

Junk Code

The human genome contains three billion base pairs, the DNA letters in which the code of life is written. Yet only a tiny proportion of these letters -no more than 2 per cent- are actually used to write our 21,500 or so genes. The remainder, which makes none of the proteins that drive the chemical reactions of life, has long been something of a mystery. Its apparent lack of function has led it to be dubbed 'junk DNA'.

Much of our junk DNA has origins that have been relatively simple to establish. A very large part of it belonged originally to viruses, which have incorporated their own genetic codes into our genome in order to reproduce.

The legacy of our viral ancestors can also be seen in so-called retrotransposons. These repetitive chunks of DNA, which were originally deposited by viruses, have the ability to copy themselves into the human genome again and again, using an enzyme called transcriptase.

In some ways, the continued presence of this junk DNA is not surprising: DNA is 'selfish', and will replicate itself regardless of utility to its host organism. But for it to withstand natural selection, some of it must surely be functional.

Software made by humans is like synthetic DNA. Remarkably junk code also exists in software systems made by us. In fact in evolutionary design methodologies such as Scrum it seems more likely that imperfect code being copied to incoming generations of software.

Scrum sprints typically follow a short 4-6 week iteration pattern. In Scrum the focus is on delivery, therefore junk code may get more chance of being copied compared to quality focused methodologies.

I don't think however junk code makes evolutionary methodologies less successful. The advantages of being agile has more survival value than less adaptive quality driven methodologies.

Consider this real life example:

Sprint1 in Project P ends, the architect A approaches the developer D.

A- Hey.. Something drew my attention, you guys hard-coded the magic-token in your module. Whereas there is a common function in our library which you should have used to retrieve the magic-token. How come this happened?

D- Oh. We've just cut and pasted the code from project Q. They also used the hard coded magic-token.

A- Ahh. I see. Damn. They should have used the library too. I wonder how we may clean up this mess.

D- I can fix this easily now in project P.

A- No, wait.. Fix it in the next sprint. I'll talk to other teams see if I can get them fix their code too.

As you probably guessed the hard-coded magic-token in this example is junk code. Like Junk DNA it possesses a powerful intrinsic ability to get itself copied into other projects/sprints i.e. other generations of code (perhaps because people find it more reassuring to use magic-tokens than using functions returning them). It seems despite A's intention to clean up the code once and for all, in practice it may be logistically not viable and quite expensive to clean up dozens of other projects' code across all versions from this viral but relatively harmless junk code. So it is likely that the fix will only be made in project P (provided that it is remembered in sprint2), and the viral code will continue to survive.

Evolutionary design in software systems is remarkably similar to evolution by natural selection. More importantly in software projects aiming at perfect design would almost certainly limit software's adaptive power and consequently diminish its competitive value.

References:
50 Genetic Ideas, Mark Henderson
Parasitism, Wikipedia
Agile Software Development, Wikipedia
Agile/Scrum Development, Wikipedia