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)