18 January 2011

On God and Religion

The belief of God has to be a personal thing - you follow one or don't believe it. For those who believe that there exists a God - you never saw Him, you never heard Him and you never follow what you believe He said you to follow. You will continue to preach irrespective whether or not God appears before you. God has to prove that he is God even if he appears before them. Quite materialistic. They just believe what they believe but not believe enough. If they learn to simply recognize Him, they will simply recognize God in them, you, me and anyone who stand before them.

Another view is the view of believers world. Believers believe that their portion of elephant is real elephant and they didn't explore other areas of elephant. The religion they portray is their perception. They are atheist with respect to other religions. The man has transformed this world a mess, even if God appears he would think to destroy this world rather than brining in order. The entropy is so huge now and tomorrow it will little more than today.

The state of non-believers is more pathetic. They never saw God and they tend to believe there isn't a God. They have a stigma that they are rational and they are so much glued to it like the believers. They may be rational but not rational enough. The rational thinking doesn't help to reduce the entropy rather adds to its growth. My three old nephew is so intelligent to believe that there exists a country called Canada and he believes that one day he will travel (just for sight seeing) to see places and in order to do that he has to study well and conduct well. It is the same belief that astronauts have on an alternate earthlike planet. If a belief gives you a good feeling, put you on the ethical orbit, makes you to find an inner piece, make you progressive and make you to handle uncertainty, you got to believe that it exists even if your cognition says the other way. The thing can be God or love or something else. Belief is superior than the fact. 

The belief shouldn't be a blind one and rational shouldn't too rational. The believers should learn rational thinking from rational thinkers and the atheists should learn the importance of belief.

The very argument whether or not God exists is insane and inappropriate.

16 January 2011

Emergent Behavior & its Role in Big Picture

A football team wins FIFA world cup, a society that is progressive, a complex software system that fails in field utterly, a strategic group fail to deliver a good strategy, a promising youth later turns out be a pathetic failure at later stage of his life due to his tiny compromises, a kid by continuous practice turns out to be a distinguished performer in arts by being passionate everyday. 

Let us see a software perspective.

Few years back, having a personal computer with 2GB of RAM is very rare and today it is common thing and so is parallel processing (particularly after multi-cores becoming a common thing). The sheer performance of the hardware has increased at least few folds. However, Microsoft Windows froze few years back and it continues to freeze even now. BTW, the freezing is little to do with MS Windows (but it plays a role). Most of the damage is done by the application developers.

Few years back, the developers used to think that we have 512 MB RAM and the part of it is ours (may be half of it). Today, we tend to think that 2 GB RAM is available in the system (as we give minimum requirements in our user guide or release note) and half of it ours. Our thinking doesn't change over a period of time. When we develop applications, we think that there will be few applications that will coexists with ours.

Let us assume that for a 2 GB RAM and 2 GB of swap, we think that at least four applications can run with each  consuming 1 GB of RAM. The math works perfectly well on paper and for the first few days until the processes grows up to 2GB (put together). Beyond 2 GB, the operating system has to swap some portion of RAM to disk. Once few pages are swapped, a method call or access to heap may lead to page miss and the operating system has to fetch the page from swap - an interesting complexity gets added. Due to this complexity, the time to execute an intended operation takes little longer which again may increase the time and memory footprint (as delayed execution delays reclaim of memory which will become eligible for reclaim if the program runs as per plan). This complexity grows exponentially until few process crashes or the system crawls and you decide to give a rebirth by rebooting the system.

But mathematically, we think that there is no problem with the parts (each process) but the entire issue is with the whole (the operating system and the processes put together). This is called emergent behavior. The whole exhibits a behavior that cannot be explicitly attributed to the parts and each part thinks that none of its behavior is responsible for the whole behavior. There is inherent complexity due to movement of parts, the environment and the processing of events that are external to the parts (and no way related to any of the parts).

This emergent behavior affects the operating systems, make climate change a failure or reason for human stupidity. Emergent Behavior proves that the software can be made with the same process that is used to make this universe and the same process can be used to attain spiritual enlightenment.

Think about how an image is formed. The image are formed using pixels. Does removing a pixel lead to disfigured image? No. The disfigure is almost negligible. So, the whole has a power than its parts due to the emergent behavior. People who talk about "the bigger picture" should focus more on studying "emergent behavior". Generalizing things from individual events can be done well by understanding this emergent behavior (and it actually helps not to generalize the exceptions).

15 January 2011

Importance of Expressiveness in Programming Languages

It is a while i had a post here and in fact this is my first post in 2011. I happy to have my first post of the year on the topic that is of huge interest to me these days.

Why aren't we still programming in assembly languages? The threads, inter-process communication mechanisms can be done in assembly language but not easily though. With assembly language, there is only level of abstraction - ability to see the requirements as sequence of bits that are comprehensible by the machine. When you want make your program to run in another target platform, you may need to change both the abstraction and implementation. The assembly language is not as expressive as procedural language. In order to increment a number, you have locate the address, move it to accumulator, add it by one and store back to the same memory location. There is no clear division of responsibility. You have more number of steps to do in assembly but that is very primitive in procedural language.

Why aren't we writing program with procedural language alone? Procedural language is less expressive than object oriented program. The amount of code that a developer should write to accomplish a logic is more in the case of procedural language. While the level of abstraction is moved a level up from the bare machine, still the abstraction is not efficient to solve a problem in application domain. As far as the application is concerned (and in imperative languages), a task is accomplished with side effects. You call a method and it changes the state of few objects. The data and operation have to cohesive. So, in application development it is highly essential that we glue the data together with operations because these operations are specialized over the data.

There are other types of programming languages like functional programming inspired by lambda calculus and one can write their own language for a particular domain. There is one basic commonality in all types of programming languages - they try to be more expressive to make the life of developers easier. For example, today many developers are thinking about writing concurrent programs not only due to multi-cores being prevalent but also due to modern languages that made multi-threading highly expressive. It is easier to write multi-threaded in Java than in C or assembly.

As we move on, we will see many more expressive language, expressive than Java world and it is part of evolution of programming languages.

The article was written after reading Grady Booch's "OOAD with Application" and first chapter of "Programming Paradigms". Hoping to bring few posts on the subject this year. Watch out this space.

31 December 2010

Wish You a Very Happy New Year - 2011

Unstuck wishes you, your family and friends a very happy new year


Cheers,
Lakshmi


30 December 2010

A Question on Java Exception?

In Java, there are two types of exceptions - checked and unchecked.
Java compiler ensures that "checked" exceptions are handled and flags compilation error when checked exceptions are not handled. But it does not flag errors when "unchecked" exceptions are not handled. The subclasses of "RuntimeException" and the subclasses "Error" are "unchecked".

Why does Java have this as a thumb rule?

28 December 2010

Software Design Puzzle #6 - Design A Dictionary

Think about a dictionary now and kind of things that you will do with a dictionary. Normally a dictionary will have simple operations of add, delete, edit and search words. Being a software dictionary, won't it be good that it suggests you list of words based on the words you type.

For example, when you type "sim", it should display first "N" closest match with the prefix supplied. I don't need to emphasize that the first word should be the exact match (if any) and then followed by list of words that matches closely.

Assume that you have many data store in which the words are stored (database, XML file, txt file, CSV file etc). It is enough to perform the search/auto-suggestion on the data in local database. If the user is willing, the user can also hear the word through audio and for doing that you have to contact a remote web service that gives a audio file for a specific word. You can also assume that there exists a audio file for every word in the database.

Can you design the application, come up with set of classes, assign responsibilities to the classes and a brief architectural diagram too.

Put your design patterns knowledge in action :-)

27 December 2010

Lesson Learnt from "Clean the Mess"

I had a wonderful experience today (Sunday, 26-Dec-2010). I took my nephew to a nearby super market. Being a Sunday evening, there were lot of people and even lot more in the billing counters. We were standing at 5th position waiting for our turn at one of the counters. There were many chocolates racks near the billing counters and those chocolates were kept there purposefully to make people standing in the counter to buy when they are waiting for their turn. While standing, i noticed two perk chocolates fallen off the shelf.

My nephew, while taking his chocolate disturbed couple of chocolates from the overloaded chocolates stacks. I had told him to place the fallen chocolates in its shelf. He did it many times as he was busy in choosing chocolates. All the times, he made sure that he kept the fallen ones on to the shelves. But his attention was not on the perk chocolates that had fallen off before we stood there. As an usual adult guy, i didn't try to bring his attention towards the two chocolates that fallen before. The simple philosophy was "i didn't create the mess (we didn't dislodge those two perk chocolates), why i should clear it".

After five minutes, i had a lesson from my young nephew. Finally, his eyes fell on the two chocolates. He picked up those two chocolates along with the new fallen ones. He cleared the whole mess. Though it was mess, i saw the mess differently than how he saw. For him, the mess is the mess and he has to clear it. For me, the part of the mess was due to me and the other part was someone else's. So, i dont need to clear others' mess.

Many times, we go to a training  to learn etiquette. But being sensitive and watching little ones will teach us what the trainings can't teach.

It was powerful learning and great life's experience. I aspire to take this learning forward till I die.

25 December 2010

What is Experience

Yesterday, Sandeep and I had a long discussion on "what is experience". Here is what we came up with.

We start our career with equal potential. Experience is how we mobilize our potential. It is how we convert our potential (the energy we posses by virtue of being human, engineer etc) to action (how we mobilize the potential to get results) decides the depth of our experience. The conversion factor differs and so is over experience/learning. Experience obeys law of conservation of energy. The energy neither be created nor destroyed but transformed from one form to another form.

In general, potential diminishes as experience grows and kinetic increases with experience (for most of us). We become more action oriented with experience.

We came up with the following diagram during our chat.



15 December 2010

Software Design Puzzle #5 - Ice Cream, Ice Cream, Ice Cream

Uncle John is very tired working for a software company. It is his childhood dream to be a entrepreneur and so he resigned his job and started a ice cream business. His business idea is very simple. Like coffees, teas, milkshakes, he wants to do ice cream vending machines and sell ice creams along with ice vending machine. Being a Java developer, he wants to develop a highly flexible ice cream vending machines (and eventually patent it). He wants to give few varieties of ice creams - cone, cup and stick and so many flavors.

The question here is, how will you design the ice cream vending machine (time being forget the fact how various ice creams base/flavors are mixed and ice cream is made which by itself is a separate design problem to solve).

How will you design the vending machine?

10 December 2010

Puzzle - Which is at the Middle

There is a linked list (you can assume that it is unidirectional or bi-directional). The list is not ordered in any specific format (unsorted).
  • What are the methods (or ways) by which you find the middle element of the list? (For example, if the element has 11 elements, 6th element is the middle. If you have 10 elements, 5th or 6th (whichever you like) is the middle element of the list).
  • What is algorithmic complexity of each method?

08 December 2010

Software Design Puzzle #4 - Apple Farm

This time, it is producers and consumers. Here is the story

There is a apple farm and the season is at its peak. The farm has many trees and each tree has numerous apples. The owner decides to harvest the apple and invites bids from various folks who are interested to buy apples. Some of them want the apples to be sent to their places and some of them are ready to reach the farm to procure the apples. So, the farmer plans for the harvest. He employs few hundreds of people - some to pick apples from the tree and some to package/transport apples. And by the way, the farmer sends apple as package of 500 apples.

Can you bring out classes and their relationships to fulfill the above requirements?