*** MOVED ***

NOTE: I have merged the contents of this blog with my web-site. I will not be updating this blog any more.

2006-06-30

Separating Debugging Information

Debugging information in an executable usually takes up a lot of space so developers usually "strip" an executable before shipping it. This however makes it difficult to diagnose problems in your programme reported by the users, especially when a problem is only reproducible in the reporting user's environment.

Microsoft's development tools support creating a separate "Program Database" (PDB) file for an executable containing debugging information for the executable. Its diagnostic tools support reading a PDB file for an executable , if one is available, to generate a more usable diagnostic report for a fault. You ship stripped executables to your users and when they report a fault, you ask them to install the corresponding PDB files to help you get a better diagnostic report. I think that this is a nice idea and I used to wonder if the GNU toolchain would ever support something like this.

Danny Smith pointed out to me that something similar is already supported by recent versions of GDB and binutils. You can use the --only-keep-debug option of objcopy for this purpose. For example:


gcc -g hello.c
objcopy --only-keep-debug a.out a.dbg
strip --strip-debug a.out


a.dbg now has the debugging symbols and a.out has been stripped of debugging symbols. When you want to debug a.out you can use:


gdb -s a.dbg -e a.out


Simple.

2006-06-29

Tales of Human Resources

In an organisation that I once worked for, the Human Resources department was particularly prone to engaging in activities and issuing diktats that were rather Dilbert-esque. Here I recount a couple of egregious examples of this behaviour that unnecessarily damaged the careers of several employees for absolutely no fault of their own.

At that time, the employees in that organisation were awarded grades every year reflecting their perceived performance based on appraisals by their peers, their seniors and anyone working under them. The grades ranged from A (exceptional) to D (unsatisfactory) and affected how much of a hike in salary (if any) you get when the next round of salary hikes takes place. They also affected the chances of your promotion.

Someone in the HR department read somewhere that the distribution of these grades in a large organisation usually follows the bell curve of a normal distribution with a few employees being graded exceptionally good or marked unsatisfactory and most employees being graded good or merely satisfactory. This person then made the leap of logic in deciding that the distribution of these grades must necessarily look like a bell curve and that too for each team in the organisation!

Needless to say, this had a very bad effect on some teams and our team was affected especially badly. Our team was assembled by hand-picking the best people from a lot of teams across the organisation to work on a particular project that the company perceived to have a lot of potential at the time. It was natural for almost everyone in the team to perform well and the managers mostly awarded Bs and As. The HR department, of course, would have none of this. The distribution must be "normal" across the team and all the pleas of the managers fell on deaf ears. The result was that some of our team members were awarded a D even though they had done good work throughout the year! This had a predictable effect on employee morale. A lot of people from the team left the company very soon.

The same organisation also had an unwritten rule of letting go of the bottom 5% of the employees of the organisation every year judged by their performance. The merits of this kind of a rule is, of course, debatable but once again a diktat from HR made it even more damaging. They decreed that every team should let go of the bottom 5% (rounded up to the nearest whole number), irrespective of whether there was actually anything unsatisfactory about the affected employees. Once again managers pleaded in vain with HR and were helpless as useful team members of a project were unnecessarily laid off. The crazy thing is that hiring continued to go in full swing during this period. Some managers thought they could take advantage of this and hire back the laid-off workers but HR nipped their plans by reminding them of the policy that an employee could not join the company after leaving it for a period of at least six months.

These incidents were not only devastating for the morale of the employees directly affected, but they were also depressing for the rest of us. Ironically, one of the purported aims of the HR department was to devise ways of boosting employee morale. Their actions however had the exact opposite effect.

2006-06-25

Rolling in Money

"Is Indian IT getting too expensive?" is an article in The Times of India that is a perfect example of the reckless and utterly irresponsible journalism that is increasingly becoming the norm for this newspaper. While the general thrust of the article is more or less correct, either the reporters in question or the "analysts" they consulted seem to have simply made up all these numbers. Believe me, it is not at all the norm to pay a guy with 10 to 15 years of experience an annual salary of 1.5 to 2 crores Rupees (about 330,000 to 440,000 USD)! The numbers are off by about an order of magnitude. I also think a salary of 70,000 USD for a middle-level manager in the US as stated in the article is a bit on the lower side, though I cannot be sure. As a couple of us were joking upon reading this article, these guys should have published the names of the companies which supposedly pay such salaries so that all of us can apply for a job with such suckers. On the other hand, such a company will not last long because it will quickly drain out its cash reserves doling out such largesse.

Unfortunately, these are precisely the kind of stories that unnecessarily widen the divide between software engineers and other sections of the society. They also unnecessarily make software engineers a lucrative target for robbers and other criminals. They create frustration among gullible engineers who think they are never paid enough for their job, even if they are already being paid far more than they deserve. They cause engineers returning to India from the US and elsewhere to demand really outlandish salaries for a job.

Pathetic.

2006-06-23

Mathematical Digressions

In my previous post, I said that the sum of the geometric series:

1 + x + x2 + ... + xn-1

is (xn - 1)/(x - 1). One of my beliefs (as also shown by that post) is that you should never take a formula at its face value. Here I quickly attempt to show why this particular formula should be correct using a very commonly used proof. Let us assume that S denotes the desired sum. That is:

S = 1 + x + x2 + ... + xn-1

If we multiply both sides of this equation by x, we get:

x×S = x + x2 + x3 + ... + xn

If we subtract each side of the first equation from the corresponding side of the second equation we get:

(x - 1)×S = x + x2 + x3 + ... + xn - 1 - x - x2 - ... - xn-1

This simplifies to:

(x - 1)×S = xn - 1

which gives:

S = (xn - 1)/(x - 1)

as we had claimed.

By the way, while attending a conference call last night where it was particularly hard to concentrate on what was being discussed, I began to doodle and stumbled upon a simple result which might have been interesting about a millennium ago and is probably just an idle curiosity now. I am also sure it is contained somewhere in our high school text books for mathematics, but I cannot recall seeing it before. (Despite what might be indicated by these blog posts, I do not have much of an interest in mathematics itself and have never pursued it for its own sake.)

Anyways, looking at the factorisation of (x2 - y2) into (x - y)×(x + y) and (x3 - y3) into (x - y)×(x2 + x×y + y2), I wondered if (x - y) is always a factor of (xn - yn). By playing around a little bit with the terms, I could write:

xn - yn = (x - y)×(xn-1 + xn-2×y + ... + x×yn-2 + yn-1)

confirming my hypothesis. If you set y=1, this reduces to:

xn - 1 = (x - 1)×(xn-1 + xn-2 + ... + x + 1)

which can be rewritten as:

(xn - 1)/(x - 1) = xn-1 + xn-2 + ... + x + 1

which is the same formula that we derived just a while back for calculating the sum of a geometric series!

Calculating EMIs

Most of the software engineers I know here in Bangalore have either already bought a house or are planning to buy one. The biggest incentives are perhaps the easy availability of home loans at interest rates far lower than that available to the previous generation and the tax-breaks one gets here in India on the principal and the interest paid on home loans. Our generation is also not averse to taking on a debt unlike the previous generation. In addition, many of us feel that it is better to take the plunge now and enjoy the comforts of your own house than to diligently save all the required money for years and then buy a house, only to find out that the dream was realised a bit too late in your life.

2006-06-22

Libraries

I really miss having access to a well-stocked and conveniently accessible library of books here in Bangalore. I really like reading books and it is not possible for me to buy all the books I fancy reading. It is not just a question of being able to afford these books; I do not have enough space in my home to stock all such books and they are a pain when moving houses.

2006-06-20

Sports

The football world cup is messing with my sleep patterns but I do not mind it at all. It is one of the most wonderful games to watch (and play), especially at this level of competition. What is especially amazing this time round is the fact that little countries like Trinidad and Tobago, Cote d'Ivoire, Ghana, etc. are playing so well against the "big guys" of the game. (With a population of around a billion each, neither China nor India seem to be able to put together a team of just 11 men who could compete at this level.)

Unlike most of my countrymen, I do not enjoy watching cricket at all - I cannot fathom how people can spend an entire day watching a game like this (for the "shorter" one-day matches) and (even worse) how they can spend five days watching the longer test matches where most of the time the result is a frustrating draw! Do people really have so much free time on their hands? Cricket is also a frustrating game to play - if you are neither a good batsman nor a good bowler (as I was), all you can do is wait in the field for the ball to come over to your nook of the universe to brighten up your otherwise utterly dull existence. Football, Volleyball, Basketball, etc. on the other hand are such wonderfully participatory games.

By the way, even though I quite like playing Pool and Bowling myself, I cannot watch these games being played at the professional level since the players have become so perfect! Seeing one strike after another in Bowling or seeing all the target balls being pocketed perfectly and the cue ball being positioned perfectly for the next shot every time in Pool ceases to remain interesting for me after a while. Watching the Chinese or the Koreans play Table Tennis is a similar experience for me - they are so perfect. That way Tennis and Football are a long way from being perfected though the professional players are fairly good and are therefore still very exciting to watch. I hope they never perfectly play the game of Tennis (e.g. hitting an ace on every serve) or Football.

2006-06-16

Spam

Gmail is pretty good at detecting and filtering out spam, but these days a lot of spam is making its way past Gmail's filters. Spammers have started sending emails where images show the text of the email, leaving no hope for Gmail's filters to process the text to determine if its spam or not (unless of course they use an OCR software, in which case the spammers might resort to using captcha-like text in the images, ad nauseum). I have also started receiving a lot of spam in languages like Chinese and Spanish (perhaps Portuguese, I can't tell), again something that Gmail's filters apparently can't process.

A big irritant on Gmail is its single biggest misfeature (in my opinion) - mails delivered to, say, "r.mathew" are delivered to me ("rmathew"), filling my inbox with random (sometimes personal) mails. They try to justify it as a feature, but since they let people register usernames with a period for a while, this can either get very amusing or very irritating for a lot of people depending on their disposition. Why can't they just stop implementing this "feature"?

Anyway, I have now become used to quickly scanning the subjects and senders of the mails in my inbox to select and "Report Spam" the ones that are obviously spam and then proceeding to read the mails in my inbox.

2006-06-15

Driving In India

This video shows an example of how people drive in Indian cities. This is unfortunately not an exaggeration - for example, the junction of Taverekere Main Road and Hosur Road near my office building has a traffic pattern very similar to the one shown by this video. I come to work every day driving through such traffic. No wonder foreigners find it very difficult to drive in Indian cities and Indians find it very difficult to control their urges in foreign cities.

2006-06-12

GCJ for MinGW

I have updated my article "Building GCJ for Windows" and the associated scripts to work with the current SVN mainline sources of GCC (to be released as GCC 4.2). They might also work with GCC 4.1 sources, but I have not checked it myself. The article also has some tips for building GCC natively on Windows using the MSYS toolkit, especially to make the built and installed GCC relocatable (see below).

A major portion of the effort went in to ensure that the resultant toolchain was actually relocatable (that is, the installation can be archived and then extracted elsewhere, possibly on a different machine, and everything can still be expected to be working). The proper locations of the Windows headers and runtime libraries and the flags to pass to the GCC configuration scripts were something that took a lot of trial and error (and a lot of help from Mark Mitchell and Danny Smith) to get right, since I was trying to do something less common (building cross and crossed-native compilers) for a platform that gets the attention of very few GCC hackers as such, if at all.

I had stopped working on GCJ for Windows quite a while back and the reason I had to update my article and scripts was that there seemed to be a lot of people trying to build GCJ for Windows themselves using the latest released or in-trunk sources (and my instructions and scripts) and they were running into all sorts of issues. Unfortunately, GCJ on Windows has become worse than it used to be which is understandable since there is no one who is actively working on it to improve it. It is also a shame since even though it is a closed platform with an ugly design it appears to have the most number of users enthusiastically willing to try out GCJ.

We must do something about this situation.

QEMU
For a fan of Linux trying to make GCJ for Windows work, a very useful property of GCC is that it can be built on Linux as a cross compiler or as a crossed-native compiler targetting Windows. For a person with a relatively old machine and limited free time to hack on GCJ, this is also important since the build on Linux is way faster and far more reliable than that on Windows itself using MSYS. Equally important is the ability to test out the binaries created in this process without having to reboot the machine into Windows or having access over the network to another machine running Windows. Wine doesn't quite help since I need an environment that is as faithful to the real thing as possible.

QEMU running Windows on Linux comes to my rescue here. When run with the -kernel-kqemu option using the QEMU Accelerator ("kqemu"), the guest OS runs at very close to native speeds without adversely affecting the performance of the host OS. It has a built-in TFTP server that allows you to easily transfer files from the host machine into the guest system (there are also other ways of achieving this using QEMU, but this is the simplest). It's almost magical and is immensely useful. It's no wonder that virtualisation is becoming so popular these days and every developer who has tried it out sings its praises. If you are an "enterprise software" developer, you should already know what I am talking about. If you haven't tried it out yet, you really should. Virtualisation offers you the freedom and the flexibility to play around that is very useful and quite addictive.

2006-06-07

"W", "A" and "D"

Tarandeep gave a short presentation on JavaServer Faces the other day and I couldn't help but wonder how similar it was to the "W" web-application development framework that we had developed about seven years ago when I used to work for "T".

"W" was an MVC-based framework written in Java that encouraged you to build your web-applications as a composition of reusable components rather than as monolithic one-time efforts. Since "T" used to build a lot of web-applications for its clients, we found ourselves doing some things over and over again, with only slight changes in look-and-feel and functionality for different applications. To save ourselves time and effort (which meant you could do the same stuff for lesser money - a big advantage over your competitors in the cut-throat software services industry), we developed the "W" framework and used it in our work.

"A" was a similar framework developed around the same time to provide a set of services that were needed by almost all the Java web-applications we were developing (user management, security, licensing, accounting, logging, caching, etc.). This framework provided the infrastructure that an Application Service Provider (ASP) could utilise to quickly build and deploy web-applications, provide detailed reports on their usage by its customers and create invoices based on the pricing scheme applicable to a customer. Its name however was an unfortunate misnomer since most of the framework was useful for almost all Java web application developers, not just ASPs. ASPs also quickly went out of fashion and many people didn't want to touch anything related to ASPs with a barge pole.

"D" was yet another Java application framework we had developed for implementing simple distributed workflows. Once again, it was born out of a necessity to reliably and quickly implement workflows that were a part of many web-applications we developed for our clients. It supported a simple and straightforward XML-based format for defining workflows, several out-of-box actions, a graphical workflow designer application, etc.

The sad thing is that none of this really went anywhere. We tried to turn "A" and "D" into products ("W" was deemed "too fundamental"), but being a company primarily focussed on software services and struggling to survive in the post-dot-com-boom era and the havoc caused by the events of 11 September 2001, we just couldn't devote enough resources to polish these and effectively market them. We also tried to donate "A" to the Apache Jakarta project (yes, the approach was extremely naive of us) with disastrous results. "A" was used by one ASP. These frameworks were used in a few applications for the company intranet and in a few applications developed for its clients, but as far as I can tell, they are no longer in use. In fact, I couldn't even locate the blurb on these frameworks and the associated white-papers on the website for "T". I think they are dead for all practical purposes.

R.I.P.

I am not saying that any of this was insanely great and necessarily deserved to succeed. In fact some of the aspects of the design of these frameworks reflected the naivete of its inexperienced designers (yours truly being one of the prime culprits) that can only be cured by years of experience with solving hard problems in real applications. I am also not saying that no one else had thought of these things at that time or had built frameworks or products around these ideas. What I am saying is that there were aspects of these frameworks that could have helped a lot of people save time and effort on building Java-based web-applications, much before the tools that are now available made their appearance, if only we had created a better awareness of these frameworks and promoted them differently.

There were several good things that did come out of these frameworks though. I learnt a lot about proper object-oriented design and architecture by working on them. I found out just how completely different creating a software product is compared to providing turnkey solutions for your clients. While promoting "A", I got a chance to experience the wonderful city of Amsterdam for over a week. Most of the people in the team that created "A" have become some of the best friends I've ever had - one of them, Anusha, is now my wife. There is a silver lining to every dark cloud in life.

Update (2007-08-06): Replaced the actual names of the products and the company with their initials on a request from "T" - Google was ranking this page too highly for their comfort.

2006-06-06

Graphic Novels

I am quite intrigued by graphic novels and look forward to reading some of them, especially those by Alan Moore. I was therefore very happy when I spotted some graphic novels in Landmark, Blossoms and Crossword here in Bangalore. The happiness was rather short-lived as I discovered that they were quite expensive. There is no way I am going to shell out 800 rupees for such a thing when I don't even know if I am going to like it and especially since many of them are in a rather battered condition probably caused by many people browsing through them but then deciding to not buy them.

2006-06-03

GCJ and ECJ

RMS has finallly agreed to using ECJ to generate bytecode for GCJ!

That sound you hear is the huge collective sigh of relief heaved by Free Java hackers everywhere.

2006-06-02

I Blog in Your General Direction

Yumpee considers blogging an act of vanity and inanity. Of course, he doesn't actually refrain from reading such blogs himself and would sometimes tell you a couple of things based on one of your posts accompanied by his trademark smirk.

Steve Yegge has a very nice writeup on why one should blog and I will not repeat here what he says there - it is a must-read for all people who think blogging is a completely wasteful activity. I would just add that I personally use my blogs and website as a sort of a Pensieve (what Dumbledore uses to store some of his memories in the Harry Potter series of books), except that I like to record my thoughts too instead of just memories. Sometimes I look at what I wrote a few years ago to see what I was intrigued by or interested in back then and occasionally I can't help but be embarrassed or amused by what I see. It still does not stop me from blogging though, mostly for the reasons that Steve points out in his article.

I have found out that blogs tell me a lot more about a person beyond what I can learn from everyday interactions with him or her. For example, Vikgup, Arpana, Anupama and Mridula have blogs that showed me aspects of their personality and areas of their interest that I had absolutely no inkling about from my conversations with them. If you do not blog yet, go forth and blog (and send me the URL for your blog).

By the way, despite my (admittedly mild) pleas to the contrary, Mark has added this blog to Planet Classpath as well. If you see posts in Planet Classpath via this blog about stuff not related to GCJ or GNU Classpath or Free Software or even technology, you now know who to blame for it.