Oct 14, 2010

Stop fighting

JavaScript is a amazing language, and it continues to amaze me. But I learned it in the hard way because I was trying to translate it into classic OO concept, and I failed. Douglas Crockford is my JavaScript idol, here is what he says how he finally understands JavaScript.

Eventually I figured out what was going on. After a lot of struggle, I eventually figured out that it was a functional language, and at that moment I stopped fighting it. I remember when that moment occurred, I was bicycling. I had just read the ECMAScript standard, which is a really difficult thing to understand. But I read through it, and then I had this epiphany when I was miles away from a computer. Oh, it's got functions in it, there are lambdas — I can do this now. It completely changed the way I thought about the language. In the end, the story ended successfully. We finished on time and on budget, Turner shipped it, and everything went great.

The lessen that I learned is to stop fighting against new idea with my old knowledge. New idea may be odd, but it will be appreciated if you follow along, and it expresses similar semantics in the way you never thought of. I love the philosophy of Chinese philosopher Zhangzi, here are two pieces of excerpt that I feel helpful to understand new idea.

The Ruler of the Southern Ocean was Shu, the Ruler of the Northern Ocean was Hu, and the Ruler of the Centre was Chaos. Shu and Hu were continually meeting in the land of Chaos, who treated them very well. They consulted together how they might repay his kindness, and said, 'Men all have seven orifices for the purpose of seeing, hearing, eating, and breathing, while this (poor) Ruler alone has not one. Let us try and make them for him.' Accordingly they dug one orifice in him every day; and at the end of seven days Chaos died.

Paoding was cutting up an ox for the ruler Wen Hui. Whenever he applied his hand, leaned forward with his shoulder, planted his foot, and employed the pressure of his knee, in the audible ripping off of the skin, and slicing operation of the knife, the sounds were all in regular cadence. Movements and sounds proceeded as in the dance of 'the Mulberry Forest' and the blended notes of the King Shou.' The ruler said, 'Ah! Admirable! That your art should have become so perfect!' (Having finished his operation), the cook laid down his knife, and replied to the remark, 'What your servant loves is the method of the Dao, something in advance of any art. When I first began to cut up an ox, I saw nothing but the (entire) carcase. After three years I ceased to see it as a whole. Now I deal with it in a spirit-like manner, and do not look at it with my eyes. The use of my senses is discarded, and my spirit acts as it wills. Observing the natural lines, (my knife) slips through the great crevices and slides through the great cavities, taking advantage of the facilities thus presented. My art avoids the membranous ligatures, and much more the great bones. A good cook changes his knife every year; (it may have been injured) in cutting - an ordinary cook changes his every month - (it may have been) broken. Now my knife has been in use for nineteen years; it has cut up several thousand oxen, and yet its edge is as sharp as if it had newly come from the whetstone. There are the interstices of the joints, and the edge of the knife has no (appreciable) thickness; when that which is so thin enters where the interstice is, how easily it moves along! The blade has more than room enough. Nevertheless, whenever I come to a complicated joint, and see that there will be some difficulty, I proceed anxiously and with caution, not allowing my eyes to wander from the place, and moving my hand slowly. Then by a very slight movement of the knife, the part is quickly separated, and drops like (a clod of) earth to the ground. Then standing up with the knife in my hand, I look all round, and in a leisurely manner, with an air of satisfaction, wipe it clean, and put it in its sheath.' The ruler Wen Hui said, 'Excellent! I have heard the words of my cook, and learned from them the nourishment of (our) life.'

No comments:

Post a Comment