2010-11-01

Link-Monkey: Windows finally...

Link-Monkey started working on windows finally...

It took a several drops of blood, sweat and tears to accomplish that. Firstly, I was doing things all wrong. Secondly, I should have done parallel development by testing each small piece of code on both platforms before pushing it in.

A small comparison on how Platform object would contain on both platforms:

Terminal Data
-------------
    Username/ID = Administrator
     VM Version = 0.0.1 - 20101101

    System Name = Windows
        Version = Microsoft Windows XP Professional Service Pack 3

 System Release = 5.1-2600
   Architecture = x86
      Host-FQDN = hcube

            CPU = Intel(R) Core(TM)2 Duo CPU     P8600  @ 2.40GHz
          Cores = 2
   Memory Total = 2086612992
    Memory Free = 1184010240
     Swap Total = 584269824
      Swap Free = 4013883392

  Process Count = 71
        Up Time = 10560921


Terminal Data
-------------
    Username/ID = gorilla
     VM Version = 0.0.1 - 20101101

    System Name = Linux
        Version = #41-Ubuntu SMP Thu Aug 19 01:12:52 UTC 2010 [Ubuntu 10.04 LTS]

 System Release = 2.6.32-24-generic
   Architecture = i686
      Host-FQDN = hcube

            CPU = Intel(R) Core(TM)2 Duo CPU     P8600  @ 2.40GHz

          Cores = 2
   Memory Total = 2051399680
    Memory Free = 193531904
     Swap Total = 267378688
      Swap Free = 267341824

  Process Count = 266
        Up Time = 3939570

Source code to this was checked-in on sf.net and can be seen via git browser.

Based on this output, it seems a default build of Ubuntu will have a little over 250 processes and has just about 184 MiB free memory, while after running Symantec and even Louts Notes with Open Office running on Windows the memory available is still over 1 GiB and only about 71 processes. Despite all this very high memory usage, Linux is still more responsive than Windows. Food for thought!

By the way, source code of this platform.js is:

#! /usr/bin/monkey

stdout.writeLine("Terminal Data");
stdout.writeLine("-------------");

if (Modules.require("Platform")) {
    stdout.printf("%-15s = %s\n", "Username/ID", Platform.userID);
    stdout.printf("%-15s = %s - %s\n\n", "VM Version", Platform.vmRelease, Platform.vmBuild);
    stdout.printf("%-15s = %s\n", "System Name", Platform.systemName);
    stdout.printf("%-15s = %s\n\n", "Version", Platform.version);
    stdout.printf("%-15s = %s\n", "System Release", Platform.release);
    stdout.printf("%-15s = %s\n", "Architecture", Platform.architecture);
    stdout.printf("%-15s = %s\n\n", "Host", Platform.nodeName);

    if (Platform.hasExtendedData) {
        
        stdout.printf("%-15s = %s\n", "CPU", Platform.cpu);
        stdout.printf("%-15s = %s\n", "Cores", Platform.cores);
        stdout.printf("%-15s = %s\n", "Memory Total", Platform.memoryTotal);
        stdout.printf("%-15s = %s\n", "Memory Free", Platform.memoryFree);
        stdout.printf("%-15s = %s\n", "Swap Total", Platform.swapTotal);
        stdout.printf("%-15s = %s\n\n", "Swap Free", Platform.swapFree);
        stdout.printf("%-15s = %s\n", "Process Count", Platform.processCount);
        stdout.printf("%-15s = %s\n", "Up Time", Platform.upTime);
    }
}

2010-10-29

Plaining Generation

Over the last two years I have had the most profound task of maintaining a piece of code that runs a massive Finite State Machine. Call control is FSM at its core and it is this FSM that dirves call services. You name any feature like call forwarding, voice mail, etc., you will always see a massive FSM that drives it.

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

Ha, ha!

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

To foil the maintenance programmer, you have to understand how he thinks. He has your giant program. He has no time to read it all, much less understand it. He wants to rapidly find the place to make his change, make it and get out and have no unexpected side effects from the change.

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

For many years humans have searched and dreamt about only thing all along: The ability to surpass time. I think, the inability to to surpass time has somehow contributed greatly to flesh out the concept called God. Every culture, every civilisation and every bit of text at some point in time discussed about it. For many years until the the turn of 19th century, cultures imagined immortality as a means to surpass the limited time humans live.

But one thing sure was abnormal. In Mahabharatha,
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."
The quest still continues despite the enfeebled 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.

2010-05-23

bX-7olwc

Sounds a little crazy, but while searching blogs with people who listen to "Electronica", I found that error code. Didn't know what exactly to do, so I posted it. If someone finds something similar, maybe it would be of some use.


How I ended up like this? As I said, I was searching. After a couple of pages (clicking next) I found this.

2010-05-09

Link Monkey - The Begining

After many days of writing, rewriting and fine-tuning I have finally made the basic skeleton for Link Monkey. Link Monkey is an EcmaScript based network protocol simulator. You may wonder why did I write one when we have plethora out there over the net. Pretty simple: Its will soon be an all-in-one swiss knife.

Two reasons borught me write something of my own. Almost a year ago, when me and my small team of four members (including me) were working on a certain call feature, we had to write a set of test cases for it. 17 to be precise. It was to be written in a language which one of the members of that product's R&D team had developed. It looked like a mixture of Pascal and BASIC but without most of their built-in capabilites. Believe me, it was a 21st century language which did not support arrays and subroutines! And expressing complex logic required a lot of blood, sweat and tear to be shed. We managed to miss multiple deadlines because most of its features were undocumented and looked like we were writing a 2 MiB large configuration file to fine tune its behaviour. Despite all this, it is a proprietary software with 100s of telecommunication protocols and it needs to be renewed every 90 days or so.

One other reason was that when I tried a couple of open source software, they were even more restricted to the kind of protocols they handled. One could not express a simple logic as to change phone numbers based on certain conditions as call flows were often expressed as XML files.

Link Monkey is an attempt to improve upon their shortcommings in many ways. Firstly, it can be used as a general purpose language if need be, which means you can have files, data streams, etc. And secondly, you can express any kind of normal programming based logic on it since its JavaScript underneath.

Source code is release under LGPL. Installers for Windows and Linux will soon be available. Stay tuned.