Monday, April 29, 2013

The forest fire in the Americas has been kindled

And was an experience unmatched. It started out early in the morning at nine and ended late in the evening around seven forty five when I finally started the long drive back with much exhilaration as I could feel that the spark had been lit and it was just a matter of time before the call would come back, a hint of disappointment as the level kindled was not > 1, but it appears that the level can be spiked before the next monsoons. Ah, the smell of moist earth would feel great when making stuff for the electronic book buffs.

Wednesday, April 24, 2013

Stop the '-gate' nomenclature

Coalgate, porn gate and now chitgate. What is it with so many gates?

After some search and our friend wiki I found that the gate reference started with president Nixon of USA because of a building called Watergate and of course Nixon's involvement. Dear Indian media, I did not understand the reference atleast not till now, and I am an average Indian. Put me in a sorted array of intellectuals and I would be somewhere near the average. Imagine how many people would be to my left. Also imagine that these many people might not be able to connect with gates other than of course, our Bill.

Throw out the -gate word. Find something more appropriate. Search for a good word, a suffix that can go along with all corrupt scams by choosing one of unheard proportion and attaching a related word. Or something smarter, people to the right of the array of intellectuals need to work on this, so that people on left can understand.

oh, by the way, I find it appropriate to mention the word colgate here and I hope they can use these -gate suffixes to their advantage in some cool ad.

Tuesday, April 23, 2013

Hi! This is java. Just passing by

Passing by What?

Is it by value or it by reference?

Let's see how we can go about understanding this. Java uses references to point to objects. So, when I call a method which has an argument of an Object A, what we are sending is a copy of the reference we created into the method. Oh! that means we are sending the argument by value. Really? whether it is the reference outside the method or inside, both point to the same object so, both are actually references to the same object and any change in the attributes of the target object would reflect back.

Simply put, if java was passing an object by value, then we would not be seeing changes. But hey! java does not even pass objects, it passes references. These references are obviously passed by value. Why, you ask? Well , let's make a reference to an object and call a method with this reference as an argument and inside the method we point to another object. There would be no changes in the original reference, although the one inside the method would now point to a new object.

So, java has references to objects which are passed by value, but the references themselves both point to the same object.

So, to conclude why people think java is pass by value is because we pass references a copy of which is passed to the method, so Aha! it is pass by value. But then, I ask arent both references referring to the same object in which case we are sending a link to the object by reference.

My take : it is all perspective. with respect to a reference, it is pass by value, with respect to the actual object, it is pass by reference.

Java passes references by value.

Also, while we are at this, it is worthwhile to notice that primitive objects are always passed by value.

Bonus Example: send an array as an argument and edit stuff, you will see a change in original array.  


Thursday, April 18, 2013

KMP algorithm

Getting my feet wet with some string pattern searching algorithms, I think the KMP makes headlines everywhere so I started off by downloading their publication from here

Reading the paper makes it crystal clear, although the volume(28 pages) might appear daunting, the first 5 pages finish up the explanation required for understanding how to go about KMP-ing.