Monday, September 26, 2011

Optimization is Fun, but ...


The first rule is to avoid premature optimization at all costs. I have literally been at companies that I've seen destroyed by premature optimizations. I can't name names, but just know that doing premature optimization can massively destroy your design and create such a complicated system that when you actually come to your performance and profiling phase, you don't know where to start. The most important thing is to build the right system. Don't take short cuts based on what you believe will affect its performance; build a system that is maintainable, that satisfies getting your functionality out the door, that satisfies getting your system built quickly, whatever your important things are, but don't do premature optimization.
Grabbed this from a coder's blog. A sentiment that I find echoed in so many places. I can think of many situations where people have indulged themselves in premature optimization. I'm using the word indulged because performance optimization is a very interesting intellectual activity and programmers typically love  to say that they're working on optimization. But I am very skeptical of all the imaginary use-cases and performance optimizations that people are forever carrying on before even implementing features and products.

This doesn't mean that we should purposely implement our applications in a shoddy way - we must follow best practices of whatever platform we are working in, we must create a design and architecture that makes sense - but what we shouldn't do is to bend over backwards to optimize something that barely even exists.

I want to round this off with an unrelated but nice quote about Test Driven Development that I found yesterday. It is from a book by Kent Beck; he says - Tests are a Programmer's Stone, transmuting fear into boredom. I hope I remember this the next time I am feeling bored writing tests.

Monday, July 4, 2011

pulse

it is easy to grab a hold of the pulse of the american media and really take your pick in which representation you are more comfortable with consuming every day and what level of balance you desire.

india is a (somewhat) different story. it is easy to pick up two very disparate sources of news (hindu vs indian express). but the spectrum of voices everywhere in between that leads to a better mix of left and right, happiness and sadness, fix-it and let-it-be, is not easy to find.

here is an evolving list of things i can read to widen my perspective. suggestions are very welcome.

thehoot.org
thebetterindia.com
indiatogether.com
caravanmagazine.in

Saturday, March 5, 2011

All in a day's work


There is definitely something therapeutic about Origami. I spent all of yesterday making Origami boxes. I made atleast 9 of them. Square ones, rectangular ones, one with a lid, couple with one divider, one with five divider. Several false-starts and calculations later, I got the perfect box for my earings - check out the one in the center.

One of the most amazing things about Origami seems to be the math around it. The next thing I want to try is modular Origami.

Posted by Picasa

Wednesday, January 26, 2011

बोल कि लब आज़ाद हैं तेरे

On Republic Day, this day, Ilina Sen reminds us to speak up when constitutional freedoms are violated in our country and to hold our democracy responsible for the crimes it commits against its own citizens. She exhorts to no longer stand by the wayside and watch when people are "killed, tortured, humiliated, disappeared, threatened, arbitrarily detained and arrested, falsely charged and under surveillance because of their legitimate work in upholding democratic rights and fundamental freedoms." Her letter can be found in its entirety at http://www.binayaksen.net/2011/01/ilina-sen-writes-to-all-supporters-of-dr-binayak-sen/.

बोल कि लब आज़ाद हैं तेरे
बोल ज़बां अब तक तेरी है
तेरी सुतवां ज़िस्म है तेरा
बोल कि जां अब तक तेरी है

देख कि आहंगर कि दुकां में
तुन्द हैं शोले सुर्ख है आहन
खुलने लगे कुफ़लों के दहाने
फैला हर ज़ंजीर का दामन

बोल कि थोड़ा वक्त बहुत है
जिस्म ओ ज़बां की मौत से पहले
बोल कि सच ज़िंदा है अब तक
बोल जो कुछ कहना वो कह ले

Thursday, July 29, 2010

Alchemy

At 15 years of age, it mattered that someone was "cool". Ravi Uncle was the coolest teacher I ever knew. I had known him since I was born, he was a very close friend of my family, but from the moment I entered his classroom I knew that this interaction was going to transform me. From the very first lecture, I knew I was going to look forward to every Tuesday and every Thursday for the next two years. And since then, I have gone to engineering school and done my Masters, and I have never looked forward to someone or looked up to someone the way I looked up to him.

The first thing he taught us was Atomic Theory. He said that the atom has wave nature and particle nature, but it is not a wave, nor is it a particle. He said, "If I brought a mule and put it on this table, and you inspected it and you poked it here and there, one of you might say - this animal has such and such characteristic so it is a horse, and another might disagree and claim that the animal has this other property and therefore it is a donkey. But really, what I already knew was that this animal was neither a horse nor a donkey, but a mule." And so, he explained to us the Wave-Particle duality that all matter has, and electrons and light, which we tend to think of as particles and waves respectively, are neither particles nor waves.

Next we were talking about the Heisenberg Uncertainty principle. This is not an easy principle to understand, particularly since we had just entered XI. The way that I remember it, Ravi Uncle sat us down on this round table and said, "Now imagine that we have these cool ships that somehow allow us to travel into the atom. Our mission is to discover the position and the velocity of the electron. Once we know these two, we should always be able to know precisely not only where it is but also where it will be. And so we get into our ships and zoom into a quantum-scale world and we're looking for electrons. But how do we see something? Well, we throw a photon of light at it, and when a photon collides with an electron we should be able to see it. If we throw a photon that has a small wavelength, so we know more precisely where it is at the moment it collides with the electron. But this means it has a high frequency and therefore a large energy, and when the collision actually takes place, an undetermined amount of energy is transferred to the electron and we can no longer tell how much that energy changed the momentum of the electron. So we change our tactics, and use a photon that has low energy, so that we don't impact the momentum of the electron at the time the collision takes place. But again, low energy implies low frequency implies high wavelength. So this time we can measure the momentum, but because the wavelength is high, we have no idea precisely where our photon is. At the moment that the collision takes place we cannot know precisely where our photon was so we cannot know where the electron was either." There it was, clear as day, the Heisenberg Uncertainty Principle.

I was moved by how at the end of the class, my mind was waking up from a dream and I found it magical that my teacher had managed to involve my imagination in the "drab" subject of chemistry.  Yet, from today's vantage point I see that it is the intersection of logic and imagination that makes science, and indeed life, beautiful.

I find it fascinating to realize that over two years he was really building something inside my mind, he was raising me to the level that I would be able to grasp and appreciate what was to come. These two lessons that I have described are not an isolated lecture: they are the foundation of everything that was to come. Hybridization and covalent bonding cannot be understood without realizing that all we have is a probability distribution of where the electron may be and that it is impossible tie an electron down to some kind of an oval pathway. This way he continually raised my thinking to a level at which I would be able to grasp what he would say next, and the progression that appeared so smooth and natural was actually a pathway laid carefully by a most wonderfully skilled teacher.

A few moments ago, I was looking the precise description of the Heisenberg uncertainty principle, and I found something fascinating yet unsurprising at the bottom of the Wikipedia entry.  It seems that the story that Ravi Uncle told us was very similar to how Heisenberg himself had originally argued for it. Ravi Uncle always told us: Read the textbook. He always taught us to learn from the masters.

I will never forget when Ravi Uncle introduced me to Olah. He not only described the mechanism that Olah had deduced, but he also told us why Olah deduced it, how Olah deduced it, and what conditions Olah had to create to be able to deduce it. I learnt that Science is one never-ending puzzle and it is unto to us to find the little answers that lead to other answers and other questions.

Ravi Uncle taught me to read textbooks. Once he had fascinated me with Olah and Organic chemistry, I felt delighted to spend my vacation reading Morrison and Boyd. What was more surprising was when I found myself enjoying reading J.D. Lee. Inorganic Chemistry can be endless torture; the memorization is even more tortuous and “illogical” than Organic. But Ravi Uncle imbued those subjects with life; inorganic compounds became characters whose "nature" would define how they would "react". And just like in a book the character that comes more often is often more important, in Chemistry the compounds that we came across more often were more important. They were the big guys that, just as he said, peppered our exams.

Studying for him was a rewarding experience; he showed us the way to succeed in learning what he was trying to teach. He didn't spoon-feed us, he showed us the way and each time I learnt something I had an "Aha!" moment. He would introduce us to a topic and give us some clues. When we read the book, we found the back-story. Finally, when we put three such different stories (or facts as you prefer) together in a test, we solved a puzzle that he set us up to solve.

Ravi Uncle taught us to know First Principles. He constantly reminded not to memorize, but to understand. He taught us to know our assumptions. He showed us that facts, formulae, simplifications, generalizations, only stand tall under a set of assumptions, and under a different set of assumptions, the foundation is weak and our solutions fail and fall like a pack of cards.

He had a deep and abiding concern for all his students. One class we didn't go upstairs to study. He sat us down in the drawing room and talked to us. He had never made any bones about the task that we had undertaken. But he had so much compassion, that he understood that all our hard work and struggle was pointless given the amount of pressure and turmoil that we going through. He reminded us that if we didn't study coolly calmly and smartly, and simply studied hard; it would be painful and worthless. He decided to spend the hour chatting with a bunch of tense teenagers, instead of trying to teach them when they were too worried to listen. He said, study hard and study smart. He would say, "If you work very hard trying to memorize the log table, how is that going to help you?" And he said, don't let pressure take away the joy from what you're learning.

Before I knew him as my Chemistry teacher, I hated chemistry but by the end of class XII, I thought I wanted to study it for the rest of my life. But then, I realized that what Ravi Uncle taught me wasn't just about Chemistry. He showed me that logic and beauty were two parts of the same coin, and that rationality and imagination did not bifurcate my world, they unified it.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I receive quite a few messages from people who have known Ravi uncle as a teacher and mentor requesting to connect with Ravi uncle's family, his kids. While I would like to reach out to each of you personally, the blogger platform does not allow me to do so.

If you would like to reach out, connect and share your memories with his friends, family and fellow students, please join the Facebook group - Friends of Ravi Gopinath.

All of us there would love to remember him with you ...

Friday, June 11, 2010

Friday, December 4, 2009

जो जीत वोही सिकंदर

we're performing today and tomorrow.
it's a creative, theatre-esque show
we've written our own script
for a movie scene
voices will be ours
for the actors on the screen.
we will perform our script Live!
and we hope you like
but even if you holler
Vote for Us, with your dollar
the money goes to AID
a charity with a crusade
to help with activities
in development and sustainability.

टीम का नाम - फिल्मी भेलपुरी
http://seattle.aidindia.org/sikandar