2010-10-29
Plaining Generation
It is always funny to see code that migrates from a super-set source language to a sub-set of it. In other words, it is really entertaining to see how a C language code slowly migrates into C++. It is even more entertaining when FSM states are written in C while their handlers are written in C++. And the best of it all, which takes the cream of the crop, is when documentations have missed impacts. Who peeps into the bottom of an ice-cream cone when there are two layers of topping above that to lick?
When terse Architecting documents apparently forget subtleties for the sake of brevity, the code sings evil raphsodies from the grimoire of what was enciphered by the masters. And when you are at it you will have two choices: Work indefenitely or quit.
It takes courage, determination and a prejudiced inclination to feel come-what-may to modify such a code. And it takes one more step closer to the edge to check-in the code and tag it. And when it all bunrs down, it give birth to another bug, opened in a tracker, with a short palnned-fix date and a neatly crafted e-mail to the managers mentioning the complexity of further soiling the code. Never forget to mention that testers will have a field day (and night) testing your code. It was once told to me by an elderly man that we pay for the sins of our ancestors.
I realised that there is no point in whining and weeping and slapping breasts to make a point. They know that they know nothing, but we do not know we know nothing. A great master once told me that water flows over the rocks and so the former is stronger than the latter. I corrected him. I said "smarter". He was enlightened. And I quit.
Link Monkey: A Windows Paradigm
I have finally compiled SpiderMonkey and NSPR4 on Windows. It took me ages to realise that the libraries should be compiled using /MT and /MTd options on MSVC++ 2008. Somewhere in a certain file in js/src directory, I found that it defaulted to use /MD or /MDd option which links the code to the dirty sick MSVCR90.dll or MSVCR90d.dll file and the annoying message that MSVCR90.dll was not found and that reinstalling will "take care" of it.
Finally, I can now continue testing on Windows...
Only now, it hangs in JS_CompileFileHandle(...) function, damn it! And the funny shit part is that I don't have the liberty of using Debuggers. Right now, the 'msdbg' says there are no debug symbols in it, which is way more annoying than compiling it.
Let me see that too.
Maintenance Programs
He views your code through a toilet paper tube. He can only see a tiny piece of your program at a time. You want to make sure he can never get at the big picture from doing that. You want to make it as hard as possible for him to find the code he is looking for. But even more important, you want to make it as awkward as possible for him to safely ignore anything.
Programmers are lulled into complacency by conventions. By every once in a while, by subtly violating convention, you force him to read every line of your code with a magnifying glass.
You might get the idea that every language feature makes code unmaintainable — not so, only if properly misused.
Refactoring is a most emotionally-satisfying activity. It is second only to sex. Your own inchoate intention suddenly shines through with blinding clarity.
2010-10-23
Vowel Parsing
This is about a time somewhere ca. 2006 when I was learning database. I came upon some blog elsewhere which was basically a tutorial about using Hibernate (java based ORM layer). The discussion was about overriding default behaviour with a small POJO which can be used to translate table names to class names. It was a very interesting thing and I caught upon it pretty quick.
The idea was to remove vowels and then remove consecutive repeating characters from table names so that it becomes difficult to people reading the DB directly. The code for example did something like this to a table named "class_schedule_t". First it removes the vowels from it, so the name now looks like this "clss_schdl_t" and then removes consecutive repeating characters from the name making the final name look like "cls_schdl_t".
I was so attracted to this philosophy that I caught on this habit to make variables smaller too in my day to day programming. I even went as far as signing mails with my name shortened to "-nd"!
aRivuRuththala
vAnAgi maNNAgi vaLiAgi oLiAgi
UnAgi uyirAgi uNmaiyumAy inmaiyumAy
kOnAgi yAn enadhu enRu avaravaraik kUththATTu
vAnAgi n^inRAyai en cholli vAzththuvanE.
2010-10-20
Time: A Philosophy
When they arrived, Brahma was listening to a musical performance by the Gandharvas, so they waited patiently until the performance was finished. Then, Kakudmi bowed humbly, made his request and presented his shortlist of candidates. Brahma laughed loudly, and explained that time runs differently on different planes of existence, and that during the short time they had waited in Brahma-loka to see him, 27 catur-yugas (a cycle of four yugas, totalling 108 yugas, or Ages of Man) had passed on earth (see time dilation theory). Brahma said to Kakudmi, "O King, all those whom you may have decided within the core of your heart to accept as your son-in-law have died in the course of time. Twenty-seven catur-yugas have already passed. Those upon whom you may have already decided are now gone, and so are their sons, grandsons and other descendants. You cannot even hear about their names. You must therefore bestow this virgin gem (i.e. Revati) upon some other husband, for you are now alone, and your friends, your ministers, servants, wives, kinsmen, armies, and treasures, have long since been swept away by the hand of time."King Kakudmi was overcome with astonishment and alarm at hearing this news. However, Brahma comforted him, and added that Vishnu, the Preserver, was currently incarnate on earth in the forms of Krishna and Balarama, and he recommended Balarama as a worthy husband for Revati.Kakudmi and Revati then returned to earth, which they regarded as having left only just a short while ago. They were shocked by the changes that had taken place. Not only had the landscape and environment changed, but over the intervening 27 catur-yugas, in the cycles of human spiritual and cultural evolution, mankind was at a lower level of development than in their own time. The Bhagavata Purana describes that they found the race of men had become "dwindled in stature, reduced in vigour, and enfeebled in intellect."
2010-10-19
Link-Monkey: So far, No Good
After almost a lot of code went in, I tried my hand at compiling the stuff on Microsoft Visual C++ 2008. Somehow, two things started bothering my sweet-dreams.
SpiderMonkey had too many flaws for my start-up work. They were making a lot of changes to the API simply to compete with V8. I feared that I would have to launch my work on an out-dated back-end. Then the thought of having a huge MinGW environment to fake Unix on Windows seemed very impractical for running auto-tools alone. And after all those pain of compiling NSPR and SpiderMonkey, my own exe's would fail compilation by throwing the most annoying MSVC error about how it failed to find MSVCR90.dll file. And after spending weeks exploring the compiler command-line options, I figured out something and got it running only to see that js_fgets() function is not properly linked. What are the odds?
Then came V8. Python, Scons and MSVC++ is all that you need to start off for a small loss: It is not as cross platform as SpiderMonkey.
Well, I have started porting my work to V8 and let us see what RnD has this to offer.