A Look Inside the Recursive Hell of Fibonacci Series

Recursion is cute, no? After all, this is what every programmer learns in his early days while attempting (and failing at) the Towers of Hanoi problem. But this cuteness comes at a cost: overhead of making a lot of function calls.

Consider this simple Java program that produces the first 100 members of the Fibonacci series:

When I run it on my SSD-enhanced, Intel i5-powered laptop, the computation time starts hitting several seconds even as the 44th member is being printed. Interesting . . . I’m now intrigued about exactly how many function calls are being made. So let’s tweak this program a little and add a static variable to keep the count:

This run reveals something startling:


As you can see, the function exhibits insane growth as soon as it nears N=40. At N=44, this “cute” recursive function is making more than 2 billion function calls!

That’s scary. Now let’s convert it into an iterative computation:

And the resulting growth graph:


Look like a quadratic growth curve. As you can see, for N=40, we now have to make only 821 calls as opposed to 2 billion+ form before. Quite an improvement!

Moral of the story: Go easy on recursion, people!

Jordison-era Slipknot Kicks SERIOUS ass


Yes, they do. My introduction to Slipknot was in the form of .5 – The Grey Chapter, and while I seemed to enjoy the raw intensity, very soon the charm waned off. Ironically, soon enough the only song I liked from that album was the intro – XIX. So when I’d hear things that Vol. 3 – The Subliminal VersesAll Hope is Gone, etc., are great albums, I pitied the speaker for still being chained by his teenage angst.

And here was why: I thought the man behind the drums in The Grey Chapter was Jordison! Yes, yes, I know — how can I be such a jackass?!

Ahem, so . . . the point is, when I got to hear that Mr. Jordison had actually moved and it was some other gentleman pounding the snares, my interest piqued. Gingerly, I tried All Hope is Gone, and BAM!, a whole new world opened up.

Jordison and Taylor formed a duo that was unsurpassed — hypnotizing vocals, thoughtful lyrics, and rapid-melodic drum beats combine to produce a metal type that;s super heavy and yet easy on the ears. What strikes me most is the continuity — riffs and song sections interweave effortlessly and progress into an ending gracefully. This is so unlike The Grey Chapter (listen to The Devil in I to know what I mean).

I guess that was the magic of Jordison!

Flipkart is Shutting Down

Its website, apparently.

But the news that the largest e-commerce player in the India market is considering moving to an app-only format, has become, well, bigger than Flipkart itself. Confusion reigns, as some say only the mobile website is shutting down, while others say the desktop one will die as well.

In any case, what prompted me to write this post was some of the comments I came across on TOI about this development:



Long live Indians! :D

Thoughts on Reference-Based Copying

One of the biggest annoyances I remember when learning scripting languages was wrapping my head around copy by reference. I came from a typical “C/C++ rules everything” background, and I was amazed how quickly I was able to pick up Python because it was oh so similar to C++. Except that copy and deepcopy made no sense to me. Yesterday I was learning object-oriented programming in PHP, and the __clone() method came up.

One might argue why the language designers have gone to such elaborate fence-building when it comes to copying objects? Why not simply copy by value and let that be the end of it. One explanation, of course, is memory usage. But I think it’s also part of language design philosophy.

The so-called modern languages were created to make programming faster and more intuitive. And so we have loose typing, which most people agree is a sanity-saver (including me). This is why when you write “$” * 4 in Python you get $$$$ and not an error; after all, if you forget about computer architecture for a while, isn’t that what you were trying to accomplish?

I think the same thing is going on in reference-based copying. When we write a = b, we tend to think in our minds that a and b are now identical. This means that if one part of a is changed, b is changed as well. Of course you might argue that it’s essentially mathematical notation and there it has no connotations of “identical-ness”; but hey, let’s not split hairs here. :-)

Coding without Syntax Highlighting?

How good is the idea of coding without syntax highlighting? Like, when everything is pitch black on white background (or reverse, if you’re intent on losing your eyesight early). Despite what I thought earlier, it’s one horrible idea. Syntax highlighting is not just eye-candy; the color scheme you follow is a powerful filtering system that helps you quickly locate what you’re looking for: “An error occurred while parsing a string? Hmm, then I need to quickly scan the red portions in the login script”.

And this, in turn, reduces the pressure on your eyes and nervous system A LOT. The conclusion, which I accept with humility, is that I can be an ass sometimes.

My First Attempt at Limericks

Today I felt like sitting down and writing a few limericks. These might not be great, but I feel an odd joy in the thought that these are original. Here goes!


I’m often confused about what to read
with what my brilliant mind to feed
those mystery stories with clever hooks
or the tales of unfortunate crooks
but like always, I can’t decide, and am undone by greed.


When it rains outside my home
on the faraway marble dome
through the window comes a light
dancing, twirling, with footsteps light
and my thoughts follow the clouds that roam.


Am I saint or a heathen sinner
a loser or a glorious winner
these thoughts occupy my mind
against my wish, oh what a grind
I lose sense of time, and every day, forget my dinner.


There was a girl who always said
she will never embrace the marriage bed
one day the pressure became too much
from somewhere she got a gun or such
and when they found her, her eyes were full of lead.


Don’t ask me to say something profound
I’ll only keep talking round and round
until your patience will run out
and you’ll begin to stomp and shout
while I’ll still be admiring the insects on the ground.

It’s all about Sex

I started reading J.M. Coetzee’s Disgrace, anticipating the rush of pleasure that comes from reading a fine book. It’s a great read, but I’m kind of getting fed up with sex featuring as the bedrock of every great work. Now, don’t get me wrong — sex is interesting; very interesting, in fact. But I’m kind of getting tired of reading about frustrated desires, lost desires, suppressed desires, and whatnot.

Maybe it’s time I turned to the Russians? I remember no sex in Crime and Punishment, and Master and Margarita also looks like a promising read. Anyway, here’s to bad luck, which follows us more faithfully that a tail follows a dog!

Cleverness in Software

Sometimes you come across life-changing statements that enter your mind quietly and make you chuckle. I came across one in the open source book Eloquent JavaScript. Here it is:

A useful principle is not to add cleverness unless you are absolutely sure you’re going to need it. It can be tempting to write general “frameworks” for every little bit of functionality you come across. Resist that urge. You won’t get any real work done, and you’ll end up writing a lot of code that no one will ever use.

Wonderful English from around the World

Found this funny collection buried in my mailbox. Too good not to be shared!

In a Bangkok temple:
It is forbidden to enter a woman;

Even a foreigner, if dressed as a man.

Cocktail lounge, Norway:
Ladies are requested not to have children in the bar.

Doctor’s office, Rome:
Specialist in women and other diseases.

Dry cleaners, Bangkok:
Drop your trousers here for the best results.

In a Nairobi restaurant:
Customers who find our waitresses rude; ought to see the manager.

On the main road to Mombassa, leaving Nairobi:
Take notice: when this sign is under water; this road is impassable.

On a poster at Kencom:
Are you an adult that cannot read? If so we can help.

In a city restaurant:
Open seven days a week and weekends.

In a cemetery:
Persons are prohibited from picking flowers from any but their own graves .

Tokyo hotel’s rules and regulations:
Guests are requested not to smoke or do other disgusting behaviours in bed.

On the menu of a Swiss restaurant:
Our wines leave you nothing to hope for.

In a Tokyo bar:
Special cocktails for the ladies with nuts.

Hotel, Yugoslavia:
The flattening of underwear with pleasure is the job of the chambermaid.

Hotel, Japan:
You are invited to take advantage of the chambermaid.

In the lobby of a Moscow hotel across from a Russian orthodox monastery:
You are welcome to visit the cemetery where famous Russian and soviet composers, artists and writers are buried daily except Thursday.

A sign posted in Germany’s black forest:
It is strictly forbidden on our black forest camping site that people of different sex, for instance, men and women, live together in one tent unless they are married with each other for this purpose.

Hotel, Zurich:
Because of the impropriety of entertaining guests of the opposite sex in the bedroom, it is suggested that the lobby be used for this purpose.

Advertisement for donkey rides, Thailand:
Would you like to ride on your own ass?

Airline ticket office, Copenhagen:
We take your bags and send them in all directions.

A laundry in Rome:
Ladies, leave your clothes here and spend the afternoon.

Don’t Get Mad, Get Git

I’m overjoyed that my full day’s effort of struggling with Git has finally paid off. I now have a proud addition to my development and professional profile, and unlike most developers I meet, I can boast of being able to create and merge branches in Git.

It wasn’t easy, trust me. Git is quite complicated to understand at first, and I can’t even begin to describe how many times I had to draw diagrams and reread paragraphs for my understanding.

Finally, I can develop projects in multiple directions, not worrying about what happens to changes I make.

Life is awesome. Heck, I am awesome! :D