Monday, October 22, 2012

Expert C Programming: Deep C Secrets

I read a friend's copy of "Expert C Programming" many years ago, and ended up buying a copy for later reference. I didn't quite remember why I would purchase a book I had read already. Recently, I cracked open my copy for the first time: it still had the new book smell.

Oh, now I remember.

This is the most enjoyable programming book I have ever read.

The book is about corner cases and implementation-quirks of C, with a smattering of C++ thrown in. The entire book is divided into themes, and each theme is self-contained in a chapter. Each chapter talks about a quirk of the language, something that good C programmers should be aware of.  For example, one chapter talks about the differences between Kernighan&Ritchie C and ANSI C. Each idea is crisply presented, with source code and clear explanation. The chapters are littered with relevant anecdotes, historical background, and tantalizing puzzles.

Programming books can be dry and just about the facts. Recent technologies usually come with books that focus on how to get things done. While this is useful, it does not improve the appreciation of the technology. Expert C Programming was written 20 years after the development of the language. Perhaps time leads to some clarity and a light-hearted view of things.

Programming is more than just a profession: it is a creative process. It helps to have such books in your shelf: so you can them pick up and remind yourself how fun computing can be.

(Image courtesy: Amazon)

Thursday, October 18, 2012

Sad condition of Indian women

Shameful statistics:

45 percent: percentage of Indian girls who are married before the age of 18 (International Center for Research on Women, 2010).
56,000: maternal deaths recorded in 2010 (UN Population Fund).
52 percent: percentage of adolescent girls who think it’s justifiable for a man to beat his wife. For boys, the figure is 57 percent (UNICEF, 2012).
7.1 percent: increase in crimes against women between 2010 and last year (National Crime Records Bureau in India).
12 million: estimate of number of girls aborted in India in the past three decades (The Lancet, 2011).
914: There are now just 914 girls to 1,000 boys in India thanks to female feticide (Indian census, 2011).
8,618: number of Indian women murdered last year for not providing a sufficient dowry (National Crime Records Bureau).
65.46 percent: female literacy rate; male literacy rate is 82.14 percent (2011 census).

Courtesy: "Why India is no place for women", Taipei Times.

Image courtesy:  竜次 on Flickr

Wednesday, October 10, 2012

An Android user looks at iOS: 2: First impression

This is a multi-part series about an objective look at iOS.

Disclaimer: I work at Google, I am an Android programmer and a long-time Linux user.  This is all personal opinion, free of any incentives.  I try to be as objective as possible, but bias leaks into every analysis. Having said that, if you are looking for validation for your fanaticism, this article will be disappointing.

Part 1 covered the purchase
-> Part 2 covers first impressions

First impression
The iPod Touch (4g) arrived today. It shipped in a clear plastic container, and the container was elegantly attached to the cardboard shipping container using an elegant cardboard holder. It was beautifully done. I have seen this earlier with Apple products: the unboxing is pure pleasure. Every tab, every bit of plastic is clearly marked to make it easy to remove the product from the packaging.

The device itself is a curious blend of elegance and confusion. The bezel is rounded, so the power and volume up/down buttons need to stick out of it to make them parallel with the screen. However, since the bezel is rounded and narrow, it is difficult to obtain any opposable grip when pressing down on the buttons. The device slips away when changing volume or pressing power, and it takes a bit of practice to use the power or volume buttons with one hand. Also, the back is as shiny as a mirror. Already in the first few minutes it gathered a few scratches from the table. I can tell the back will be a hazy mess in a short duration. It is a curious choice of materials, while the new device looks amazing, its beauty will fade very rapidly. The device doesn't feel flimsy but does feel delicate. I would expect a handheld, mobile consumer device to be a lot more sturdy. I now understand why every iPhone I see is encased in a rubberized case.

The first impression of the case was of handling a delicate glass artwork: breathtaking beauty combined with shocking fragility.

Signing in, ...again and again
The iPhone requires an Apple login at start-up. While entering the Apple ID, it wanted to spell correct my ID, and also while entering my name, when setting up an email account. Even more baffling was that the suggestions were different. In one case the correction was "Vibrant" and in the second, it was "Coltan".

And the iPhone requires an Apple account password very frequently. I provided this for the startup screen and I was amazed at how often it prompted me for the password. I did not keep count, but I grabbed six separate screenshots, before giving up.  The screen does not indicate why it needs a password, or who needs it. Very baffling. There seemed to be no logic in asking me for passwords. I installed free applications, and it asked me for passwords on some of them and not others. Also confusingly, the keyboard always shows uppercase characters irrespective of the actual input mode.

On the plus side, it was great that the icons were not static: the calendar icon showed today's date. (The clock icon didn't show the current time, why?) And the notification shade was quite similar to Android, which was nice. The dock at the bottom of the screen was similar to the dock in OSX, and the popup when changing volume was also exactly the same as the OSX version, which was also wonderful.

The screen (retina without IPS) was also gorgeous. The fonts in Books were gorgeous. This would make a lovely book reader, and I fully expect the iPad with retina display to be an awesome bedtime bookreader as well.

The device setup was painless, except for the iTunes and sync which will be the next post.

Monday, October 08, 2012

An Android user looks at iOS: Part 1: Shopping

This quarter, I plan to learn about non-Android mobile devices. I work on Android applications, and wanted to broaden my understanding of the mobile ecosystem. I start out with iOS, the wildly popular mobile platform from Apple.

Disclaimer: I work at Google, I am an Android programmer and a long-time Linux user.  This is all personal opinion, free of any incentives.  I try to be as objective as possible, but bias leaks into every analysis. Having said that, if you are looking for validation for your fanaticism, this article will be disappointing.

This guide was written in October 2012. The mobile world moves fast, this will be obsolete in a few months. Also, most of this information is specific to the US.

Step 1: Shopping

Unlike the Android world, there are few iOS devices. My options were:
  1. iPad: Apple's tablet comes in two choices: the old (iPad2) and the new (iPad3). These devices can be purchased with WiFi alone. The iPad2 (released March 2011) costs $400 and the iPad3 (released March 2012) costs $500. They come with 1/2 G of RAM and 1G of RAM. Applications need to be written to support the higher resolution of the iPad.  At $400, the iPad2 is a good choice. It is overpriced for its specifications, but I am sure the tablet applications add a lot of value. I currently own a Nexus 7, and the 7 inch form factor works a lot better for me than the bigger form factor of a Xoom. Since the iPad screen is 9.7 inches diagonal, I suspected it would be too big while I was parenting at home, and to carry everywhere.
  2. iPhone: Apple's iconic smartphone comes in three choices: the iPhone4, iPhone 4S, and iPhone5. The iPhone 4 was released in June 2010, the iPhone4S was released in October 2011, and the iPhone5 was released in September 2012.  I am out of my cell-phone contract, and cannot commit to another two years of contract. That only leaves unlocked iPhones. The unlocked iPhone4 is $450 and the unlocked iPhone4s is $540. This is astronomical for devices that are two years old and a year old respectively.
  3. iPod Touch: This is a touchscreen device which is close to the iPhone in capability but it lacks both a GSM chip (for voice and data networks) and a GPS chip (for global positioning). The iPod Touch 4th generation (iPod touch 4g for short) starts at $200 for 16Gb, and the latest iPod touch 5th generation (iPod touch 5g) starts at $300 for 32Gb of capacity. Both devices are small and light, and the 4g is slightly shorter than the 5g. The iPod Touch 4g was released in September 2010, and the 5g was released in September 2012.  The margins on these devices must be insanely high: the cheapest iPod touch 4g costs $200 which is the same as the Nexus 7. The Nexus 7 has 1G of RAM, a 7 inch screen, and many components that the iPod Touch lacks (GPS, NFC, ...)

Those are all the options you get: three device types and two generations per device.  New Apple devices sell for roughly the same cost everywhere, so to buy cheaper, you must buy used. All iOS devices contain non-replaceable batteries and online forums suggested that used iOS devices might have terrible battery life. Also, some devices have aluminium casing, which results in ungainly scratches if poorly handled.  Rather than risk a poor experience with a used device, I decided to buy a new device directly from Apple.

After much consideration, I settled on an iPod touch 16GB. It allows me to use a device similar to the iPhone without extending my cell-phone contract.  As a bonus, at $200, I would have realistic expectations from it.

There is an Apple store in my neighborhood, but online reviews were disappointing. Online is a lot more convenient anyway, so I headed to I can wait a few days for shipping.

The purchase at the Apple Store was effortless: there was nothing to configure. You are given a stupidly large button to choose the color (white/black) and then another stupidly large button to select the capacity (16Gb/32Gb). The lack of choices is great for most customers: you choose between two or three options at every stage. In the end, portability and the need to avoid extending my contract made the choice very easy. I love the clean interface of the Apple store. There is very little information presented: too little for engineers but everything is geared towards facilitating the purchase. Terminology is kept to a minimum.

Apple doesn't provide any guidance about their inventory. This is a departure from Amazon, which tells you exactly how many devices they have in stock. In addition, Amazon gives you accurate shipping estimates: "If you buy in the next four hours, you can be guaranteed to receive it by Tuesday". By comparison, Apple says that shipping time is 5-7 days once they have inventory, and they won't tell you if they have any inventory. US customers now expect free shipping for most expensive electronics, following Amazon's exceptional service. In the light of that, it is comical how Apple makes a big deal about free shipping.

Shortly after the order, I received an email with the order confirmation and yet another with the tracking number. So far the experience has been pretty good.

(Image courtesy: Protocol Snow)

Wednesday, September 19, 2012

Android debugging using the framework source

When writing Android apps, it is helpful to be able to read the implementation of the framework to clarify a point.  This might be when the documentation is incomplete, or if you want to learn from canonical classes like ListView.

Nexus devices contain this framework code unmodified. This allows you to trace your application flow down to the framework level, either to learn how the platform works or to find a bug. Today, the cheapest Nexus device is $199, so having an additional Nexus device is an excellent tool for Android developers, even if you do most of your development for non-Nexus devices.

It is easy to get the source code from the Android Open Source Project (AOSP). You need the following:
  1. A good Internet connection. The full AOSP tree is well over 8 gigabytes of data. If you have more than one Android developer, you could download the tree for a single developer, and then mirror it locally.
  2. A fast computer. AOSP is a lot of code and Eclipse chews a lot of CPU and RAM with large projects. A computer with two CPUs and about 4GB of RAM should do perfectly, you might get away with lesser RAM.
  3. Disk space. If you choose to build the code, you're look at 30 gigabytes of disk space.
  4. Eclipse, some recent version and Sun's Java 1.6.
  5. Linux or Mac. The instructions work for Ubuntu 10.04/11.10/12.04 and some Mac version.

Here are all the steps:
  1. Set up your computer: This can be done on all developer computers simultaneously. This will install all the development tools. At the end of this, you have all the tools but no AOSP code.
  2. Download all the AOSP source: This uses your internet connection to download all the source. The AOSP source has everything going back to the earliest releases of Android. You get all source history, the framework, the open source applications, the kernel, all open drivers, everything. There are instructions on that page to set up a local mirror. Follow those steps to download the source once and then share it over your local network. This conserves bandwidth, and saves time. You might want to start this download over a weekend, depending on your network connection and other users' needs. I will assume that you are putting the source in /usr/local/aosp.
  3. Build the source. Here, you have two options. You could follow the AOSP instructions. However, if you just want to include the source in an eclipse project, those instructions are overkill. You can get a much smaller project if you follow these alternate instructions. If you have trouble with java versions, read the bottom of this post.
    $ cd /usr/local/aosp
    $ source build/
    $ lunch full-eng
    $ # The following step takes time. -j<num jobs> increases parallelism.
    $ make -k -j2 sdk
  4. Create the Eclipse classpath. By default, we can create a project with all the Android source code. This is beneficial if you want to have access to all the AOSP code for reference. If you want just the framework, you can reduce the size of the project significantly. To do this, first create a file in the directory containing the following:
    $ cd /usr/local/aosp
    $ cat excluded-paths 
    This file allows you to reduce the size of the Eclipse project, which improves Eclipse's performance significantly. Now, we can generate the Eclipse classpath as follows:
    $ cd /usr/local/aosp
    $ ./development/tools/idegen/ 
    Read excludes: 3ms
    Traversed tree: 781ms
    $ ls -l .classpath
    -rw-rw-r-- 1 user group 16938 Sep 18 21:50 .classpath
  5. Create the project in Eclipse. First you need to start Eclipse with increased heap size and virtual memory:
    $ eclipse -vmargs -Xms128m -Xmx512m -XX:MaxPermSize=256m
    Now, create a new Eclipse project (File -> New Java Project -> Next). In the dialog, under the "Libraries" tab, click the "Add Library" button -> Add System Library -> Add JRE system library. This will help resolve the references to core libraries like Integer and String. Adding the system library is not required, but it reduces the number of syntax error Eclipse finds with the framework. Click "Finish" when done.
  6. Done! Try your setup by searching (Ctrl-Shift-T) for FragmentManager. You should be able to see its source code, and navigate through its code. Some handy commands are: Ctrl-Shift-G to look for references of a class, and F3 to look for a method's implementation.

JDK version pain: You might encounter a problem with JDK versions. You need Sun Java 1.6 to compile the AOSP source code, while your Eclipse setup might require a different version (OpenJDK?). One solution is to use sun-java only to compile the AOSP, and switch back to the previous version after the compilation has finished. On Ubuntu, this is done with the commands shown below. Select the number that corresponds to sun-java before the compilation, and run these commands after running to switch back to your previous version of jdk.
$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                         Priority   Status
  0            /usr/lib/jvm/java-6-openjdk-amd64/bin/javac   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/bin/javac   1061      manual mode
* 2            /usr/local/sun-java-1.6/jdk/bin/javac         1         manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/lib/jvm/java-6-openjdk-amd64/bin/javac to provide /usr/bin/javac (javac) in manual mode.
$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
  0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
* 2            /usr/local/sun-java-1.6/jdk/bin/java             1         manual mode

Press enter to keep the current choice[*], or type selection number: 2

Sunday, September 16, 2012

Where are you from?

When Indians meet, one of the first question is, "Where are you from?" Depending on the parties involved, the answer can have varying degrees of detail.
  1. Born in different states: the name of the city, if it is well known: "I'm from Madras". The name of the state if the city is not well known: "I'm from Assam" rather than "I'm from Duliajaan"
  2. Born in the same state: the name of the city: "I'm from Satara".  Perhaps a locality within the city if the city is popular: "I'm from Old Delhi". This is especially true if the locality has racial/religious connotations.
  3. Born in the same city: the region where you are from, but now you specify your mother's and father's place as well: "We live south of the Yamuna, but my mother's family is from Satara".
I hate this question. People trace your origin so they can find a familiar prejudice to apply. If you are from Madras: you are immediately perceived as a Hindu, most likely vegetarian, lover of rice and hater of wheat. Your Hindi is perhaps terrible, you enjoy spicy food and worship your Reader's Digest. This question finds differences without finding any common ground. It doesn't lead to any insight, it doesn't make you understand the person any better.

It is awkward if this question is quickly followed by total silence, as if your place of birth is the only noteworthy information about you.

I have always considered this question quirky. My parents were born in a city that I have never visited, and I have only visited the state once, many years ago. My parents traveled often, so the entire question makes little sense. I have grown up in five cities, and I am an alien to all of them. I'm not really from any city. For many people in my generation, this question is pointless.

I would rather discuss people's interests, their aspirations and their passions. It is our common interests that bring us together, not our differences.

(Image courtesy: Samaritan's Purse)

Saturday, September 15, 2012

Experiences with Human Resources

In any software engineering shop, good engineers are the biggest asset. A Human Resource department is supposed to manage this critical asset. In my experience, even exceptional companies have lousy (or downright inethical) Human Resources teams. Here are some experiences, in no particular order. They are all from top tier software firms from the San Francisco Bay area.
  1. The cheapskates: After a campus interview, the HR recruiter offered to give me a gift card for the company's store. The company was well known, but I did not use their store, so I declined the offer. The recruiter persisted, she said I could give it to a friend. Hesitatingly, I accepted the card. The denomination on the card was One Dollar. The company had printed cards for a single dollar and was handing it to candidates who were being interviewed. This was in 2008, when a cup of coffee cost two or three dollars. I considered giving her a ten-dollar bill so she could give the next sorry contestant something substantial.
  2. The lazy: After successfully making it through the interview process, I was unable to contact the recruiter for a month. In the intervening time, I started interviewing at a different company, was offered a position, accepted, and had signed formal papers. Much later, the recruiter contacted me again, suggesting she could send me the formal offer. By now, it was too late.
  3. The shameless: After contacting me and setting me up with technical interviews, the HR recruiter decided to join another company. While I was still interviewing at her previous company, she started hounding me for positions in the new company she was now working for.
  4. The unethical: After I declined to join a company, a recruiter from the same company contacted me under the pretense of discussing the failed offer. A few minutes into the conversation, she started asking me all sorts of probing questions about my current compensation and internal details of my project. Both of these are confidential, so I declined. At this point the recruiter said that she was a contractor and her company also hires for several other top tier software firms, and offered to set me up with them.
  5. The mugger: At a well known developer conference, this recruiter was waiting in the shadows. She struck up a conversation with engineers as they left the talks, asking them about their work. A few minutes into the conversation, she mentioned how she was a recruiter and was hiring for a well known firm.
  6. The comatose: After receiving a question about compensation when changing roles at a company, this HR business partner decided not to answer for another two months. By this time, the role change had already happened. When asked again, she said she didn't know anything about compensation when changing roles. If HR doesn't know such things, what do they know?
Human resources are the public face of the company to candidates. If they act poorly, a candidate suspects that such behavior is ingrained in the company culture. The image and brand of a company can be tarnished by the sloppy behavior of their recruiters and human resource staff.

Conversely, a considerate and thoughtful human resource personnel improves the image of a company. I interviewed at a company that I would have never considered joining due to personal reasons. However, their HR personnel were exceptionally caring and understanding. Declining their offer was a very difficult decision only because of their wonderful HR team.

Monday, August 27, 2012

Xmodmap: a quick guide

If you use a variety of Linux/Unix machines and are confused between their different keyboard layouts, it might help to learn the xmodmap utility.

Xmodmap allows you to read the keyboard and mouse pointer bindings and to set them. You don't need root permission, and you can modify these without restarting the X session. This is very useful if you use different keyboards, or want to use the CAPS LOCK key for something useful.

The easiest way to use the xmodmap command is to print out its current config. Run
$ xmodmap -pke

This prints out all the keycodes that are assigned. Here is a sample line:
keycode  24 = q Q U094C U0914

This says that 
  1. Keyboard code 24 corresponds to the 'q' key. Pressing the key by itself without any modifiers produces the 'q' key.
  2. If you hold shift while pressing it, it produces the 'Q' key.
  3. If you hold the mode_switch key while pressing it, it produces the Unicode 094C character (in hex)
  4. With the mode_switch and the shift, it produces the Unicode 0914 character (in hex).
The mode_switch key is used on non-US keyboards to produce non-English text. If you don't know what it is, you don't need it.

But you do use the shift key. How do you know which key that is? Run:
$ xmodmap -pm

That command tells you what the modifier keys are. Looking for the 'shift' modifier, you can see that it is mapped to two different keys:
shift       Shift_L (0x32),  Shift_R (0x3e)

They have hex keycodes 0x32 and 0x3e. 0x32 is 32 in hex which is 50 in decimal. If you search for keycode 50 in the output of 'xmodmap -pke', you will see the following line:
keycode  50 = Shift_L ISO_Prev_Group Shift_L ISO_Prev_Group

So that's the left shift key.

All these keys can be remapped. The most common use is to remove a key you do not use, like the CAPS LOCK key. That is the 'lock' modifier. On my keyboard, the lock modifier is:
lock          Caps_Lock(0x42)

It is assigned to the Caps_Lock key. Let's remove this binding. To remove bindings, you can write commands as arguments to xmodmap -e, and you can supply many commands in succession, as follows:
$ xmodmap -e "command1" -e "command2"

To remove the Caps_Lock binding, we will remove the 'lock' modifier from it.
$ xmodmap -e "remove lock = Caps_Lock"

If that didn't produce any output, it was successful. Validate by running "xmodmap -pm" again. Now, the lock line should look like

Now Caps_Lock doesn't produce a shift lock anymore. You can also verify by opening a text window and pressing the caps lock key. It will not do anything.

Now, let us put the key to good use: how about assigning it to control? Run:
$ xmodmap -e "add Control = Caps_Lock"

Great, now your caps lock is an additional control. We can combine these two commands:
$ xmodmap -e "remove lock = Caps_Lock" -e "add Control = Caps_Lock"

Easy remapping, and it works independent of the window manager, the keyboard type, and the version of Linux.

In case you want to find what key code a specific key produces, run the 'xev' program. It tells you in great detail which keystrokes are pressed and released, and also all mouse events.  Here is a sample line:
KeyPress event, serial 36, synthetic NO, window 0x3e00001,
    root 0x15d, subw 0x0, time 1355682, (152,6), root:(783,52),
    state 0x4, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (01) " "
    XmbLookupString gives 1 bytes: (01) " "
    XFilterEvent returns: False

I pressed a key which produces keycode 38. Using this method you can narrow down on an unused key and put it to good use.

Sunday, June 10, 2012

STM32 with Linux: Device support. Part 1

I recently got a STM32F0-Discovery board. This is a development board that contains a versatile ARM microcontroller and a supporting chip to program and debug the microcontroller. This is Part 1 of a short series to get you up and running with these devices.

0. Motivation
Microcontrollers are computers that contain a processor, memory and storage all in one tiny package. Such computers are used inside devices that need a small amount of processing power: in televisions, printers, or electronic music players. These computers are easy to program, they utilize little power, and are rugged enough to last many decades of continuous use. I had previously posted a set of tutorials showing how to program ARM processors using assembly. These tiny microcontrollers can be programmed with a subset of the ARM instruction set, making them easy to learn.

The STMF0 discovery board is a low cost development board intended to demonstrate the advantages of the platform. It looks very compelling: it has many Input/Output lines, it is low cost ($7.50 each), and it uses ARM assembly. Mike Szczys recently wrote a link program that makes this device programmable within Linux. When I received my device this week, I decided to give the Linux interface a try. In case you have one of these devices and an Ubuntu machine: here are the steps you need to follow to get your device working inside Linux.

You will need:
  1. An STM32F0 Development board. At this page, go to Orderable products -> Distributor Availability to find a retailer near you to buy from. 
  2. A Linux computer with root access.

1. Install Development packages.
You need a few packages as root:
sudo apt-get install pkg-config libusb-1.0.0-dev git

2. Installing ST-Link
This is code written by Mike Szczys that allows you to communicate with the discovery board in Linux.

mkdir stm_discovery && cd stm_discovery
git clone
cd stlink
./ && configure
There shouldn't be any errors in the output to configure. If there are errors, they usually point to missing development tools, so fix them before continuing. Otherwise, proceed to the next step:
Checkpoint: You should have two executable files: st-util and st-flash in your directory. They won't do anything yet, for that we'll need device support.

3. Device support.
If you have the STM32 device plugged in, unplug it. If you have a v1 device, you should unplug any USB storage disks like flash disks as well. This is because the v1 device fakes a USB disk, and we will need to change the USB kernel module to get it working. So, unplug usb disks now. Then, run the following commands:
sudo cp 49-stlinkv* /etc/udev/rules.d   # Allow any user to access device.
sudo modprobe -r usb-storage            # Remove the module
sudo cp stlink_v1.modprobe.conf /etc/modprobe.d   # Set device specific policy
sudo modprobe usb-storage               # Add the module again

This sets up the device so any user can play with it.  There is no security issue with allowing users to write to these devices, so the above steps are safe.

Checkpoint: You should have an executable file called st-util, and running it should produce the following output:
2012-06-10T21:23:29 INFO src/stlink-usb.c: -- exit_dfu_mode
2012-06-10T21:23:29 INFO src/stlink-common.c: Loading device parameters....
2012-06-10T21:23:29 INFO src/stlink-common.c: Device connected is: F0 device, id 0x20006440
2012-06-10T21:23:29 INFO src/stlink-common.c: SRAM size: 0x2000 bytes (8 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
Chip ID is 00000440, Core ID is  0bb11477.
KARL - should read back as 0x03, not 60 02 00 00
init watchpoints
Listening at *:4242...

4. Get ARM development tools
At this point, you have support for the device, but you don't have a compiler or debugger for this board. Your computer is most likely an x86 device so you need a cross compiler to compile ARM code for it. The cross compiler is special: it generates code for a device with no operating system.

Code Sourcery is a free toolchain that compiles code for such devices. You can download it for this specific board and install it as a user. You don't need to be root to install it. This is a 100Mb file, so depending on your download speed, this might take some time. You can install it anywhere, the location isn't special. The installer asks you if you want to modify the PATH environment variable. Choose yes.

This isn't the only way to get the ARM development tools. If you want, you can compile gcc and gdb from source. Adam Kunen has a long article that describes how to do this.

Checkpoint: Start a new terminal. (This is important because your PATH needs to be updated.) You should have the programs arm-none-eabi-gcc and arm-none-eabi-gdb in your path. You can test them by invoking them:
$ arm-none-eabi-gdb
GNU gdb (Sourcery CodeBench Lite 2011.09-69)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-eabi".
For bug reporting instructions, please see:
(gdb) quit
$ arm-none-eabi-gcc
arm-none-eabi-gcc: fatal error: no input files
compilation terminated.

Now, you should have full support to program these devices in Linux and to debug them. Part 2 will show a sample program.
(Image courtesy: ST Microelectronics)

Book Review: Once Upon A Secret

Want to read a moving book about one woman's life and how it was shaped by an early mistake? Grab "Once Upon a Secret", by Mimi Alsford.

Marion (Mimi) Beardsley was a 19 year old intern in the John F. Kennedy White House. She was one of many women who fell prey to JFK, who was a insatiable womanizer. This book is written by Mimi Beardsley, now much older and much more mature.  Despite the racy premise, the book carries valuable lessons about the value of equality in a relationship, and the consequences of one-sided relationships.

The book follows Mimi's life from an early age. She sets the stage well: talking about her family and what values they held, leading up to her securing an internship at the White House. She talks about her relationship with the president and what it involved. I found her evaluation of the situation frank and mature. She doesn't paint a rosy picture, and has a deep understanding of her role and her emotions during this time. The book doesn't end at JFK's death, instead it carries on with Mimi's life and the implications of her relationship with JFK. She explains how it impacted her marriage, and how she changed over the years as she struggled with this secret.

The world changed in this time, relationships became open and frank, and both men and women learned to have expectations from a healthy relationship. A lot of topics that were taboo in the 60s became open for discussion. Mimi shows how this changed her life and allowed her to find true love.

Mimi's understanding of healthy couples and how they find happiness is the true gem in the story. This isn't a story about a girl's summer fling. This is a mature, thoughtful and insightful book about finding love and understanding. About having healthy expectations about companionship and finding happiness in a faulty world. It is a rare gem of honest thoughtful writing. Few people understand themselves as well as Mrs. Alsford does, and even fewer can write about themselves in such a frank and precise way.

(Image courtesy:

Saturday, May 19, 2012

Patient consumerism

I just finished "The World of Goo", a five year old game. I'm now playing "Psychonauts", which is at least five years old.

I see a lot of hysteria when new games are released. What's the hurry? If the game is any good, it will still be around in a few months.  If anything, after the first round of consumers has tested the game, it will be released with patches and updates to make it work better. And in a few months, there will be much more content for the game.

Products thrive on consumer hype and early sales. Early adopters serve as testers for the product. They get bragging rights, but their experience is often rough. This strategy works well for people who need the features the new products provide. And that's a small subset of people. The majority of consumers need a rugged, stable product at a reasonable price. Marketing, however, works differently. There is a huge marketing campaign when a product is released: it has to be prominently featured to grow consumer awareness. Average consumers get caught up in the hysteria. You find first-adopters who purchased the product for brag rights rather than actual utility.

Poor products rely on early sales while good products rely on sustained sales. Good products have long-term focus. The Nintendo DS and the Sony PSP both sold roughly 1.2 million units in first-week. But the overall sales were very different: Nintendo DS sold 152 million units, and the PSP sold half that number. Both products were released in 2004. First week sales of the two consoles were not indicative of their relative success. Of the products released in 2006, only 5% were hits, and only 15% were around after five years. A patient consumer has fewer options, and the options are of higher quality.

I can wait when most new products come out. I don't need a cutting-edge game, just like I don't need a cutting-edge vacuum cleaner. My current flight simulator is nearly a decade old, and meets my needs. There is a small subset of products where I do need the very latest. Products that improve my efficiency or quality-of-life fall in this category. I spend many hours carrying my child, and will happily pay for an innovative baby carrier. This set differs from one person to the next. A person with breathing difficulty might want to buy the cutting-edge vacuum cleaner.

When you see a new product, ask yourself if you are buying it because it will significantly improve your life. Avoid getting caught in marketing hysteria. The product will still be on the shelf a month later.  If it is any good, that is.

(Image: courtesy News-o-Drome)

Friday, May 18, 2012

Impressive gaming: World of Goo

In order to fight off murderous tendencies while doing taxes, I play video games. This year, I played one game on my Android phone: The World of Goo.

Wikipedia claims that this is a physics-based puzzle game, but that is as accurate as describing chicken tikka as a dead bird. The World of Goo is a brilliant adventure game, told through many levels that involve tiny balls of Goo. The balls start out sticking together, and new levels add interesting capabilities. There is a single objective in every mission, usually collecting a fixed number of Goo balls towards a pipe. (To be fair, Wikipedia has a scary long page about the game. What they lack in humor, they make for in actual content and facts.)

A few years ago, I was saddened by the lack of inventiveness in new games. It seemed that every game was about the same boring plot: there were certain genres and everyone stuck to tried and tested mechanics. Walking through the aisles of a computer store, you could quickly categorize each game into a few genres: RPG, strategy, platform, with little that set the individual games apart. Compared to this, the early days of gaming were filled with creativity as programmers experimented with computers to create something fun and unique.

That wasn't the only problem. I use Linux and many games do not work on my system. Even when had the luxury to install Windows on one partition, games required registration codes and other fiddling just to get working.

In such unhappy times, I came across the demo for World of Goo. There was a Linux version, and I played one level or two and loved the idea behind the game. The game was refreshingly new, with goo balls sticking to one another and making cute sounds when they reached the destination.

For one reason or another, I put off the purchase and then promptly forgot about it. A few weeks ago, I finally bought the first Indie bundle on Android and downloaded my copy of World of Goo. It was as refreshing and enticing as I remembered it, and so I installed it on my Android phone.

Tax week was a whirlwind of administrative paperwork and an ill baby. In between copying numbers from one dull form to another, I was holding my child as he slept clinging to me. My hands were free, but I wasn't coherent enough to do anything productive. My phone was nearby, and the opportunity was perfect for the World of Goo. After a few hours over many days, I finally finished the last level. And I cried because I had no more goo world to conquer. That's how good the game is.

The game has exceptional level design. Most game developers fall in the trap of coming up with a single idea for a game: developing the engine and then churning out levels one after another. In such games, the fun dries up quickly after the first few levels. The game gets devilishly hard and the levels just get tougher. New levels are more challenging, but no more rewarding. Level two is level one, but with less time and fewer resources. That's not fun, that's a chore. In Goo, you go through different scenarios, changing weather and different kinds of goo balls. The game mechanic changes as you tackle new levels. This reminds me of Soul Bubbles for Nintendo DS, which had the same change of mechanic as the game proceeded. I'm glad the developers resisted the urge to copy-paste levels. I'm glad they spent as much time in innovative levels and level mechanics as they did on the creativity of the engine. The levels are inventive, they keep you eager to see what happens next.

As the game proceeds, the story of the goo balls unravels and takes the player through its strange and  humorous turns. World of Goo does a lot of things well, and is an instructive lesson to the cesspool of current-day gaming.
  1. Creativity counts. Come up with something unique. Computer worlds are limitless, so don't package the same crap all over again.
  2. Entertain in every level. Each level should be fun to play. Doing the same thing twice isn't fun.
  3. Leave no player behind. Goo allows you to skip baffling levels rather than requiring your user to fight through tough levels. They can always come back for levels later. This makes the game more fun and accessible.
  4. All the fun ideas, and nothing else. The game is small, but it is fun all along. That is far better than padding a game with mediocre content to increase the length.
The game is half a decade old, but is well worth playing.

Tuesday, May 15, 2012

What should you list on your resume?

This is some quick advice on the skills you should list on your resume.

There is a lot of wisdom about how you should format your resume, but there is little discussion on what you should put into it. You could list too little, and risk rejection because you did not have the required skills for the job. Or you could put too much, and risk looking boastful or dishonest. Where's the line? This article is written from the perspective of a Computer Science graduate. Other fields might list skills differently, so this might not apply to your field.

For new computing professionals, I follow this thumb-rule:
If you can answer an undergraduate-level question on the topic, list it on your resume.

Listing a skill expresses your confidence in the topic, and a willingness to answer questions on it.  An interviewer uses such a list to give you a chance to demonstrate your knowledge. The interviewer wants you to succeed, and you need to provide him a list of topics that you can succeed in.  Remember that an interviewer is chosen based on the skills on your resume, and someone with working familiarity with the topic will certainly know much more than you. Interviewers know this too, and try to put themselves in the candidate's shoes. They reason backwards and try to remember how much they knew before they started working. For most people, this takes them back to graduate or undergraduate level coursework. Questions generally start in that general area, and get tougher.

For example, listing C in your resume would invite this basic question. What's wrong with this code?
 int array[5], i, *ip;
 for(i = 0; i < 5; i++) array[i] = i;
 ip = array;
 printf("%d\n", *(ip + 3 * sizeof(int)));

A person with undergraduate-level familiarity with C is expected to answer this question. If you cannot answer this question, the interviewer cannot ask you anything tougher. The two of you have just wasted ten minutes that could have been spent demonstrating a different skill: Python/Java/Android....

Anything short of a full college course is not worthwhile putting on your resume. Your resume lists your capabilities versus other candidates in the same pool. If the skill is trivial, or your knowledge shallow, then it does not distinguish you from other candidates. Avoid cluttering your resume.

List skills on your resume that you wish to continue perfecting. If you disliked VHDL even though you have an excellent understanding of it, list it under a 'Know but Avoid' section. This points out that while you have a skill, you want to distance yourself from using it. If there is a skill that you know you are rusty on, you could mark it on your resume under a section titled 'Rusty', or 'Passable'. On my resume, I have both a 'Passable' section and an Avoid section.

Finally, if you realize that you have overestimated your knowledge of something: let the interviewer know. It saves both of you a lot of time.

If you liked this, you might enjoy reading my article on how to create beautiful resumes in LaTeX.

(Code coloring courtesy: Image courtesy:

Sunday, May 13, 2012

What is inside electronic devices?

Not many people see the insides of electronic devices. Here is a picture of a Linksys E-1200 router:

If you compare this with electronic boards made a decade ago, the emptiness of the board would strike you immediately. Most of the board is empty space and two black chips dominate the real estate. The remaining components are minor: resistors and capacitors.

There are two big black chips in the center of the board. In order of appearance from left to right are:
  1. Winbond W9425G6JH: That's memory, storage, or RAM.
  2. Broadcom BCM5357B0: That's everything else: CPU, wireless, ethernet, router. Everything
The fat black things in the bottom look like chips but they are not. The FPE 2020 are tranformers for electrical isolation of the ethernet signal.

Everyone knows that computers getting faster, smaller, more durable and more cost efficient. The silent revolution is in the ubiquity of computers. Tiny computers are everywhere. The desktop was once the only computer in the house. Then came along the laptop, then the smart phone. Then your television set-top-box. Routers, ebook readers, the telephone box to give you cheap international calling. Deep inside, all these devices are empty boards like the one above. One powerful chip containing a computer to do everything.

The other important fact is that these are a full, general-purpose computers. You can run browsers, games, and email programs on these computers. Manufacturers make a board with a general computer and then write router software for it. This method is cheaper than creating a specialized router-only computer. A router is very similar to a television set-top box: they both contain roughly the same parts. The only difference is in the software.

We are getting better at manufacturing these full computer chips: they cost less, last long, and fail less frequently. It is not unusual to run these computers constantly for years. This astonishing reliability is one reason why the repair industry is dying. The other reason is that there isn't much left to repair. Boards contain few parts, and if a CPU or RAM chip goes bad due to overheating or electrical surges, it is nearly impossible to repair it.  And capacitors and connectors fail much more often than CPU and RAM chips. Since there is nothing mechanical left to fail, and the failure rate of silicon components is low, electronic boards provide decades of service.

Another trend to notice is that many of these devices run Linux. Linux has many benefits: it is free, it has support for a wide variety of these new computers, and it is easy to modify.

(Image courtesy

Tuesday, April 03, 2012

Don't censor Facebook, fix law-and-order

There are reports of a riot breaking out in India because someone posted something objectionable to a religious group on Facebook. Two groups came out on the streets and fought it out because of something posted online. As usual, the knee jerk reaction is to try to censor posting on Facebook. As usual, this misses out on the real problems.

  1. Who posted something objectionable? Can't we try to find them? There is a law against posting hateful speech, and we should bring the offender to justice. I haven't seen the objectionable image here, but I'm guessing that if it is truly abhorrent, there will be reason to prosecute the poster.
  2. Is the image really abhorrent? Many religious groups are happy to impose their frail sensibilities on the world at large. People have been persecuted and harassed for artful depictions in the past, and I wouldn't be surprised if the religious group here is choosing to feel outraged at something mundane.
  3. Was the image being forced upon people? There is a ton of objectionable content on the Internet. You don't need to look hard to find very ugly and disgusting things. So what's new about this image? Why was it so hard to ignore it? What does it say about your religious sensibilities when you are looking at disgusting stuff online?
  4. Someone arranged the groups together to fight it out on the streets. Was that done on the Internet? Can we find who arranged to get the groups together? They needed to co-ordinate to get to one place, who did that? Can we bring them to justice?
  5. Who were the people in the groups? They were certainly breaking the law by destroying public and private property. Why can't we find these clowns and punish them?

Of course, the real question is, where was the police when this was happening? Remember them? Why isn't the headline: "Indian police fails to stop miscreants"?

This isn't a story about online censorship at all. I have doubts about the Indian police, they are frequently late, and are ineffective even when they are punctual. The core function of the police is to enforce law and order and it is clear that they failed in this job.

Sure, you can censor Facebook. You can ban all images. You could even ban the Internet. But that wouldn't fix any of the the core problems. Objectionable images can be printed on presses, they can be xeroxed. They can be hand-drawn and copied by carbon paper. The dedicated zealots can take offense at anything.

(Image courtesy: an unrelated article at The Guardian)

Thursday, March 22, 2012

The best restaurant website in the world

I often search for restaurants online, and I'm not alone. It is convenient to find places at home, look up their menu beforehand, and ensure that the place is open.

Far too often, restaurant websites are unusable. They fall into the trap of doing too much and trying to make an artistic statement when they should be all about functionality. Before we go over to the world's best restaurant website, let's look at the cardinal rules of restaurant websites.
  1. Be short.  Your customer has little time to make the decision. Restaurant websites should load quickly. Forget pictures, reviews, maps. The customer can look those up separately. They're coming to your website for just the facts. Give it to him, quickly.
  2. State the location. Location is everything. Where the hell are you? The customer is online, and is certainly not at your location. Tell him where you are.
  3. State the hours. Are you open right now? Are you closed on Mondays? Tell me now before I make the long trek up to find you guys.
  4. No flash, no music. Your website is a signboard, not a concert. And the signboard better be visible on mobile phones and every computer in use. Don't let the website 'guy' convince you otherwise.
  5. Give your menu. Save the customer the hassle of finding out what you've got. It is better to disappoint the customer in his house than at your restaurant.
You might have noticed that all these are trivial to follow. As a bonus, these rules will ensure you spend less money developing your website. Of course, the website-maker 'guy' will try to convince you that you need some flashy music, some trendy layout and lots of words about the owner, links to reviews, fancy this and that. He is lying to make more money. Fancy websites are great for stuffing his resume and his wallet.

And as proof, I present the world's best restaurant website. The China Dragon restaurant in Morro Bay has followed every rule, and their website consists of one page. All the facts and no bullshit.

You could claim that it is a cheap site with boring lettering. And you'd be right. It is a damn cheap site with boring lettering that loads fast even on slow networks. It gives all the information in a single page and doesn't waste my time. Its website loaded up faster than the three other restaurants I was considering.

You attract customers by giving customers what they want.

(Image courtesy: China Dragon in Morro Bay).

Wednesday, March 21, 2012

Book Review: The Continent of Circe by Nirad Chaudhuri

Want to read a possible theory about Hindus and Hindu behavior? Read the confusing book, "The Continent of Circe", by Nirad Chaudhuri.

"The Continent of Circe" is a book published in 1966 by Nirad Chaudhuri. He grew up in Bengal and writes about the Indian freedom struggle. His views are very different from mainstream views about India. He differs from both Western authors and Indian authors, which makes his writing unique. Some of the arguments made in this book are
  1. There is no religion called Hinduism. This is a name given to a group of people from a specific region.
  2. The Muslims and Hindus in India are completely different people. Conversions and intermarriages have done little to change the stock and behavior of the people. The two groups distrust one another and the relations are deteriorating over time.
  3. The Hindu caste system was the Aryan way of assimilating the local groups. It was never a barrier to professions, and that it might have done some good in maintaining social order and regulating competition between the competing groups: priets and warriers at the top were Aryan and the lower classes were local merchants.
  4. Hindus live among contradiction: (a) they espouse non-violence while their history is replete with butchery (b) they have a grand view of themselves while also professing humility (c) they hold a view of their unity while being deeply fragmented and divisive.
  5. The Indian weather molds Indian (specifically Hindu) behavior.
  6. Hindu thought is rather simple, and written analysis of Hindu thought makes it more profound that it really is.
That's as far as I made it through the book. As you can tell, some of the arguments are correct and obvious while others are strange andmoulds need explaining. And explanations are provided, though the language in the book is bizarre and complex. For one, the essays appear unedited. The language is complex, sentences are long and winding. The author rambles on, and paragraphs are disconnected and dry. Every other paragraph has some foreign phrase which makes it doubly hard to understand the intent. Here is a typical sentence:
Today, as an old man I would say that I have seen so much of this feckless tragedy of Hindu life on this green earth and under the blue sky, that the moment I see any sign of the Hindu dementia in me, I shall cry out, "Nunc dimittis..."
Entire passages from foreign languages are quoted. I gather there is some French, German, Latin involved, and I'm glad the typesetter did not have Cyrillic or Japanese or Chinese characters. I don't know what to make of the strange writing style and the profusion of Latin. I'm sure the words "De rerum indicarum natura: exempla gentium et seditionum" appeal to learned people. An illiterate villager like me has no idea what the hell just happened.

Is it pretentious writing? Did everyone write like this in 1960? Or am I too dumb to understand it?

One thing is certain. Nirad Chudhuri was original. He sees the vast difference between Indian and Western behavior and tries to explain the difference. He isn't pandering to either group: his observations are brutally honest and his analysis is equally impartial. The standard Indian reaction to him is to call him prejudiced and bitter. I don't agree with that. His brutal honesty hurts Indian sentiment. Indians prefer objectivity to be coated with lots of warm love about Indian greatness. Nirad Chudhuri also points out the poor aspects of Western behavior. His praise and condemnation is showered on both groups equally.
Read him, if only to see how honest and unabashed an Indian author can be.

(Image courtesy ManasTech's blog.)

Monday, March 19, 2012

Book Review: Life, in Pictures

Want to read a biographical cartoon book with literary depth? Read "Life, in Pictures", by Will Eisner.

I had written earlier about Will Eisner's book, "A Contract With God". I recently read "Life, in Pictures" which contains many autobiographical sketches about his life. It is comparable in depth and quality to A Contract With God.

The book is a collection of stories from Will Eisner's life. The first part is a story of how he got in the cartoon business. It is titled "The Dreamer", which describes the protagonist. It is a story of the harsh times during the depression when publishing was going out of business and a cartoonist was struggling to find work. Other stories are about his parents, about his life in the army. Each story is breathtakingly drawn and movingly narrated. This book, like others by Will Eisner, is a masterpiece dressed up as a graphic novel. It contains plenty of real life themes including betrayal, bigotry, and sexual adventures. Go get it, you won't be disappointed.

Will Eisner grew up in a world very different from ours. The economy was tumbling down, and there wasn't much for a young cartoonist to do: especially if he wanted to stick to principles and do the right thing. The World War intervened, and carried hundreds of thousands of young men to their graves. On their return, they found a different world and had to adapt to it. Their life  was a constant struggle and yet they did so well. I am reminded of "The Commander", Christopher Hitchens' father in Hitch-22. He fought in the Second World War, and returned to a victorious but shattered Britain. Through his life he wondered why his generation got such little credit, witnessing a country transforming every day. His generation should have been commended for the fine job they did, and instead they were snubbed every step of the way. The won the battle, and the war, and returned to a thankless, uncaring country.

Our generation is completely different. We grew up in times of plenty. Our lives lacked the constant struggle of our parents. We might have stumbled on our way to a good college, or towards a fulfilling job. But our struggles pale in comparison to the ones our parents had to make. Our lives would have been much harder a few years ago. The ones of us who moved from one country to the other have no idea how easy our lives are. Early immigrants to America had a crushingly hard life. In comparison, our generation is coasting along on its good education and upbringing, and doesn't realize it.

Honest stories about people's lives makes you reconsider your own circumstances and your definition of success. Biographies by famous people are often misleading. Their circumstances and opportunities led them to success or notoriety. The average person dies unknown, forgotten by everyone except their next of kin. If Will Eisner points out one thing, it is the brevity of life, and the foolishness of traditional measures of success.

(Image courtesy Google.)

Sunday, March 18, 2012

I am convinced this is news

The rise of blogging and the fall of newspaper readership is often blamed for the sad demise of newspapers. We are led to believe that the evil Internet is causing newspapers to die out. Nobody wants to pay for news any more, and the Internet and pimply faced bloggers are to blame.

I'm sure bloggers are to blame for providing local reporting at zero cost. The Internet is also to blame for allowing people to read rubbish at low cost, rather than having to pay a high-price for their rubbish. There's plenty of blame to go around. Craigslist is robbing the classified business of newspapers and hurting their revenue much more than amateur writers like me. Everyone is hitting news media.

What's really hitting news media is a realization that they aren't the best game in town. Newspapers used to be the only way to get reporting and to learn what the world was upto. You read what was in the newspapers because you had no alternative. And you imagined that their reporting was good. What blogging is exposing is how shallow and pointless reporting can be.

Here is a sample news article from one of the most respected papers, The New York Times. It is an article about Apple, and I would urge you to read the entire piece. My site not a spectator sport, so go read the article.

Yes, this article. Go read it. It isn't long.

Before I go on, I should point out that the New York Times is one of the best newspapers around. The quality of their journalism is high, the style and quality of writing is exceptional, and their opinion pieces are often thought-provoking.

Ok, now back to this article. The one you read a few minutes ago.

The entire article is:
Apple will make an announcement at 9am tomorrow.

That's it.

That's all.

And it is followed by paragraphs of completely pointless and completely inane speculation. That's what news has devolved into. One real point that can be summarized in five words followed by paragraphs of deeply worded and important sounding nonsense. Alright, I'm lying. The full article is "Apple will make an announcement about its cash at 9am tomorrow." That's eleven whole words and the summary is at least eight words, not five as I claimed. It is true that bloggers have no journalistic integrity.

Television news is a lot worse. There aren't that many newsworthy events in a day, and an even smaller number of events that the specific audience will care about. And considering that the audience might tune in at any time of the day, the same news has to be looped incessantly. Take the same point and restate it in a new way. Include commentary by the village idiot. I used to find it hilarious that television reporters would consult some random bystanders on their analysis of national events, like the government's planned budget. Enlightening as that was, the internet allows us to see what village idiots around the world have to say!

And media's obsession with celebrities is baffling too. So some actress goes to jail over some minor issue. Why do I care, and how does it affect my life at all? Unless she started teaching Mathematics at the local public school, I can't see how it will possibly impact me or my children. But media is obsessed with the smallest detail of celebrities: telling us just how white some person's teeth should be. Yes, please do tell me.  Wait, that's not sufficient. Could you include a panel of unknown dingbats to completely analyze the situation? Oh, that's so much better.

Celebrity gossip and inane commentary isn't news. And no amount of analysis can convince me otherwise.

(Image courtesy: Cox and Forkum.)

Book Review: Hitch 22

Want to read about the life of a brilliant and insightful political journalist? Grab Hitch 22 by Christopher Hitchens

I first came across Christopher Hitchens during the great Atheist resurgence of 2006. It seemed that atheism was everywhere. Richard Dawkins had written his brilliant book, "The God Delusion" and was debating the existence of religion in style. Dawkins was well known from his previous works on evolution and Biology like "The Blind Watchmaker". I hadn't heard about Hitchens at all, but I found his debating style witty and crisp. Here's a two hour debate in which Hitchens talks about why rationality and atheism is the only humane choice. I was intrigued.

I found out more about Hitchens, which is to say I learned everything Youtube had to say about him. I found that he had written a book about Mother Teresa, and that it wasn't complimentary. The title of the book says a lot about Hitchens' writing style and wit. It is called The Missionary Position: Mother Teresa in theory and practice. I couldn't wait to buy it so I was delighted to find that my library had a copy of the slim volume. From beginning to end, it was a delight. It made me realize how little I knew about Mother Teresa before considering her a saint. To this day, when I meet someone who claims to idolize Mother Teresa, I ask them to list exactly what they know about her. Often, the answer is vague and unsatisfactory. We are quick to idolize and deify.

It was a rude awakening, and when Hitchens wrote his book "God is Not Great", I rushed to get a copy. Like his other works, it was brilliant.

In Hitch-22, Christopher talks about friends and family in his life. It is a rare insight into his insightful mind as he relates formative incidents in his childhood and early adulthood. I was struck by how many notable poets and authors he got to know very early in life. His socialist leanings were not a revelation, but the manner in which he decided that contemporary socialism was lacking values was a captivating read. Along the way, he points out valuable lessons that he learned about independence of thought and the importance of action. He talks about going to Cuba back when travelers to Cuba were monitored closely and how he learned the rotten-ness of Soviet communism rather early. He talks of what he saw in Iraq and why he was a rare Left-leaning supporter of the war in Iraq. I did not agree with his views, but I see his point clearly now.

His writing style is charming and a pleasure to read. At times he gets academic and his sentences get long and laborious. But all through, he guides the reader through his life and allows the reader to draw their own conclusions. The ending is poetic and does justice to the confusing name.  A rare insight into a genius.

I'll miss you, Hitch.

(Image courtesy Google.)

Wednesday, February 29, 2012

Book Review: Me Talk Pretty One Day

Want to read hilarious non-fiction: get a copy of "Me Talk Pretty One Day" by David Sedaris.

David Sedaris writes about his observations of the world, growing up, getting a job, living in Chicago. While most people shrug nasty encounters or get mad about them, David finds a funny twist and brings out the humor in them.

This book is a disconnected collection of his experiences growing up, moving out of his parental home, and learning French. Some essays are brilliantly insightful, where he discusses how the French language has gender for inanimate objects and how he constructed stories involving household objects like Mr. Belt to drive this point home. Or his description of religious festivities and symbology in the chapter hilariously titled, "Jesus Shaves". David also talks about his family and their antics. The best chapter was the one in which he describes his working life as a mover: how he accompanied a schizophrenic, a murderer and a communist in the moving business. His murderer friend says to him, "I can't say I'll never murder another person. It's unrealistic to live your life within such rigid parameters."

Sometimes you wonder, is David telling the truth? Is it true that his father stores away food for later consumption. Then you realize that every family has quirks, and indeed everyone is surrounded by quirky people. It takes David's eye to find funniness in everything and to show it to others.

(Image courtesy Wikipedia)

Tuesday, February 28, 2012

Book Review: India - From Midnight to Millenium

Want to read some non-fiction about Indian politics and culture, read "India: From Midnight to Millenium", by Shashi Tharoor.

Much like other non-fiction by Shashi Tharoor, this book talks about India in some depth. It is a collection of essays about Indian political and cultural life. There were many interesting facts here. I loved his chapter on the Indian diaspora, including the hilarious tidbit that there was indeed an Indian merchant who maintained a supplies shop near the North Pole. Sounds like the setting for a perfect joke, doesn't it? The book talks about Shashi's experience as a Keralite who grew up in Bombay and then the US. I can feel his sense of detachment from his home-state as a youth, having grown up away from it. He also talks about how he defended the Emergency as an Indian abroad. At the time, American press was critical of Indira Gandhi. The book has some valuable points, about how India has developed politically in the presence of divisive elements like religion, language and ethnic affiliation.

The chapter on Indian economic liberalization was beautiful. It talked of how the Indian economy was forced to open due to a balance of payments crisis. Shashi talks of how politically sensitive liberalization was in the past. After the liberalization has improved the lives of middle-class Indians, it is unstoppable. No politician from either side wishes to turn back the clock and bring India back to the socialist license regime. Another chapter on the Indian political class was insightful. Shashi mentioned how Indira Gandhi had risen to the post of Indian Prime Minister, and how her son was hurriedly drafted for the job after she was assassinated. Other observations were equally fascinating: how Rajiv Gandhi's assassination helped the Congress by rallying the nation behind them for the sympathy vote.

Unfortunately, my book was hard to read. Physically hard to read. I have a paperback, and the binding of the book was uncomfortably rigid. For much of the book, I had to hold the stiff binding apart with both hands. I am too careful with books to crack the spine, something I should have done early with this book. Penguin publishers should look into better binding, one that doesn't cause aching hands after reading a book.

One shortcoming of the book is that it often diverges from the main point. For example, while talking about India, Shashi diverges to talk about Kerala, beginning the diversion with something along the lines of, "I hail from Kerala, a southern state in India, whose language Malayalam is the only language whose name is a palindrome in English." This fact of Malayalam being a palindrome is neither central to the discussion, nor a very interesting one. In addition to frequent diversions, the book labors some points repeatedly, like Kerala's high literacy rate. However, this is to be expected from any collection of essays by a single author.

The only strange chapter was the one discussing the incident of the elephant god Ganesh drinking milk in 1995 where Shashi claims that he was witness to this miracle. It is sad to see an educated person admit to such mumbo-jumbo. At the end of the chapter, there was mention of capillary action, even though capillary action cannot explain how metallic statues were reported to drink vast quantities of milk. Either Shashi is indeed religious or has acknowledged defeat in face of strong Indian sentiment.

So read this book as a collection of observations about Indian culture and political development. This book isn't as insightful as V.S. Naipaul's observations on India, but it does show how India changed after independence.