Wednesday, October 12, 2011

RIP Dennis M Ritchie

Dear Dr. Dennis Ritchie,

I just heard of your demise. My condolences to your family.

You have been an inspiration to many engineers like me. I feel it is my honor & privilege to have read the book you co-authored with Dr. Brian Kernigham and set me on the path to becoming a programmer. I am also glad that all my co-students who thought that that book was "difficult to read" have either become managers or salespersons. The fact that I read it many years after I stopped actively programming in C, just so that I strengthen my basics, is a small tribute to that masterpiece.

Your creations - both Unix & C, have had a phenomenal impact on the computer industry spawning dozens of thousands of innovative products and almost single handedly powering many many industries and helping the entire computer engineering manpower to make their livelihood. I find it an honor that every language I programmed in has been either a direct or indirect descendant of C.

I believe you have left a lasting impact on my life.

Rest In Peace. 

Thursday, July 7, 2011

Kindle - the review

Its been about 5-6 weeks since I have started using a Kindle and I believe it is long enough to write a review. My Kindle is a 3rd Generation Kindle (with the small screen) with special offers - worth USD 114. For the record, it was a gift from my lovely wife on my just-passed birthday. I picked a good partner.

I will write more about Kindle in the following lines, but it is a device meant only for reading. Don't buy it to do anything else. This is for bibliophiles - not geeks. If you are a geek - buy an iPad or something like that - where you can read books and read emails and browse internet and listen to music and watch movies and video chat and so on. The Kindle is not a general purpose electronic device, and I repeat, it is meant only for reading. Did I tell you, it is only for book lovers?

Right, now that I have put the reason d'etre of Kindle in clear perspective, let's proceed. Here are my quick notes:


  • Best device to read. With a nice black and white display and fluid options for page navigation, it is easy enough to read and addictive enough to keep you hooked.
  • Form factor is good - fits nice into your palms, easy to hold with a single hand too and still navigate pages with ease. The only complaint I have is that it too thin and too light that it can easily slip out of your hands or hold (I have dropped it a few times already - unfortunately.)
  • The hardware seems rigid - and as I said I have dropped it a few times and no major damage done. It also doesn't heat up - so you can hold it in your hands for many hours.
  • The battery life is just about brilliant. I don't bother with charging. Seriously, I don't. Once in a while, when I plug it into my laptop for copying books, it gets enough charge to last me till the next such occasion. For the record, the Kindle can go 3 weeks without a charge if you don't use Wifi and 2 weeks if you turn your Wifi on.
  • In terms of supported formats - the primary support is for AZW, amazon's own format and generally available only from amazon, and mobi. In general, this is good enough since calibre can easy convert almost any format into mobi and the experience is promising. PDF reading is a bit of an issue though, because reading it directly means that the screen is too small and if you adjust your zoom level, then you are left with too much scrolling for the experience to be good. Converting PDFs into mobi is ok for PDFs with primarily text content - but if you have PDFs with lots of images and such, skip it. 
  • Getting content for the Kindle is reasonably straight forward - amazon itself is the best source - it has free and paid books. Prices are costly if you compare to Indian retail prices, but not if you compare to Singapore retail prices. There is of course a decent supply of free content around the internet - both legal and illegal - so chose your pick. 
  • The e-Ink technology is just about brilliant - no glare, very easy on the eyes - and the comparable technologies - iPad (too much glare), Computer (again, glare and not easy on the eyes) don't even come close.
  • No distractions - all you are doing is reading a book - and not getting a popup here and there for an email or a text message or a call. That makes the experience well rounded.
  • The special offers that comes with this price is totally non-intrusive and not detrimental to the reading experience.
  • Lastly, it is the price. US$114 (plus shipping to Singapore made it SGD 157) is attractive enough that you should consider buying it. It is cheaper that your mobile (and cheaper than say even 3 months of mobile bills), TV, Computer, A bicycle, a dinner at a costly restaurant with drinks or two dinners at a not-so-costly-restaurant. It is great pricing.
If you are a book lover, who reads at least 10 books a year, Kindle is the device for you.

Saturday, April 23, 2011

Buying my second Android Phone


A few months back, I blogged when I bought my first Android phone - Samsung Galaxy S. I had my fair share of disappointments and had written that the idea that I cannot upgrade to the latest versions of AndroidOS when the updates had been launched was too disappointing to bear. When finally I did get 2.2 on the phone, it was a massive improvement and suddenly the phone started looking a lot more closer to the iPhone experience. 

Subsequently, when my iPhone 3G (the one that I had passed to my wife when I got the Galaxy S) contract ended, I decided to continue with the AndroidOS. These are the reasons:
  • I don't use too many apps - I have a minimal set of apps that are mandatory, then everything else doesn't matter much. To that extent, Apple & Android are about the same - the minimal apps are good in both OSes - Twitter, Browsers, Skype, Email, LinkedIn, FB and the likes.
  • Google experience - Gmail, Chat, Picassa etc is a lot better on Android than on iPhone.
  • For people like me who like to read a lot on the screen, the screen size and quality of some Android phones (like the Galaxy S) is a big plus.
  • Battery life is normally good, and you can replace the batteries.
  • WiFi hotspot - I can't count the number of times this has been a life saver for both me and my friends/colleagues.
So, I am now the proud owner of a Samsung Nexus S - the Android 2.3 phone (and my wife has moved on to Galaxy S). The biggest plus is that it is a pure Android phone - which means updating stuff should be pretty easy. On the other hand, Samsung had done a good job of creating an OS version with more utilities (video player, file browser and such) than the standard OS and I had to spend some time to get up to speed with that. All in all, I am yet to have any major complaints and am generally quite impressed with the product.

To address the concerns of the previous blog post
  • Touch screen becoming unusable while charging - you get used to not using the phone when it is charging. Doesn't seem much of a bummer now.
  • GMail App gripes: I had a few of those - but as I have been using the app, I feel the flow of usage is a lot more suited to my usage and works better than the Apple Native Email option.
  • Browser: Both on 2.2 and 2.3, Android's browser is a lot faster and has a better feel to using it. I still have the problem of closing a browser which I have been using for a bit, but then, I am now used to using the task manager to killing the browser. I still feel Google can do something about this.
  • Multiple calendar works and works precisely as expected in both 2.2 and 2.3 of Android OS.
  • Contacts usability: Once you get used to searching instead of browsing for contacts, life is back to being good on Android - and so is the case with me.
  • 3g/2g switching - still as bad as it was in 2.1, but with better battery lives, I have stopped worrying about switching to 2g altogether.
  • Skype VoIP: Skype is still a rather poor experience on Android as compared to iPhone. Call quality is very poor and the phones freeze when trying to use skype. Can't help but hope for a better version of skype on Android - stable & fast.


Friday, October 22, 2010

Google App Engine vs Amazon: Our decision at Vocanic

When I joined Vocanic about 10 weeks back, one of the key mandates for me was to move our applications to a better infrastructure. We were running a old style hosting environment based out of a colo in the US and it just didn't seem like a scalable solution. There was already an instance where one of the apps brought in heavy traffic and brought down the site - so we wanted something that can be scaled at a short notice.

To just complete the context, we are a social media marketing agency - so we run a lot of social media applications for our clients - facebook apps, apps that interact with Foursquare, Twitter and the likes.

As a fan of the Google App Engine (GAE), I was quick to point out that option. As soon as I joined, I showed the engineers some of the apps I had built on the GAE and spoke passionately about moving into that direction.

Then I started evaluating Amazon's EC2 - specially because Amazon had set shop in Singapore recently and we were hoping to ride the Next Gen NBN wave in Singapore (most of our user base is from the region and if we could avoid sending their traffic across the pacific, it would be a boon for us) and I quickly saw why GAE was so much more a restricted environment in comparison to Amazon's EC2.

We decided to go with Amazon EC2 and having been on it for about 6 weeks now and though we were a skeptical bunch in the beginning, I have to admit that it proved to be a good choice. The specific reasons include:
  1. GAE psupports two domain landings per app - one from appspot.com and one custom domain (say shreeni.info) of your choice. We often ran apps on multiple custom domains - if the client so wishes. In EC2, we could just hack up the apache vhosts file, but there is no such option in GAE.
  2. GAE's data storage engine while being quite well designed for scaling up, is rather a pain to deal with - specially since any single app of ours never scales to a million rows for us, but taken together, they add up to that order. We did not want a store where we could not do arbitrary DB operations - you can't do count(*) operation on GAE, for instance - and we didn't find the trade-off of retraining all our engineers to be GAE-storage-restrictions-aware when we were not going to get any benefits in return. Amazon's RDS storage, running a MySQL InnoDB engine was good enough - and it is fairly trivial to upgrade the storage on that while still retaining all our MySQL-training intact.
  3. We did not want to tie ourselves down to Java or Python - the two programming environments supported on GAE - specifically since we are veering towards using PHP as our default programming language (more on that in a separate post).
  4. We found some of the restrictions a little too er.. restrictive - timing out page requests after a few seconds, for instance. So, if we wanted to run a cron job that took more than a few seconds, we would have to go and redo the whole thing to fit into the GAE restrictions. Considering that we often launch entire apps within a few days and sometime in few hours, having to deal with altering our thought process just because GAE has that restriction seemed too time-consuming and detracting to me.
  5. Of course, serving the traffic from Singapore (one of EC2 colos) was going to make our pages faster than from GAE, which doesn't specify a region from where it will serve traffic. It might as well be doing it from Singapore, but unless it spells it out, we assumed it was from across the oceans.
  6. Amazon is showing a lot more innovation - SNS and RDS Read Replicas being launched within the last month, while GAE hasn't shown enough new development in the last year and half I have been following them.
Starting up, one of the considerations we had was the cost of EC2 - almost ~$100 per instance per month for the lowest instance. But just in time for us, Amazon launched Micro Instances - and at ~$25 per instance per month, that was a perfect deal - our traffic, thankfully, fits perfectly on to the micro-instance-plus-RDS architecture.  

We already have a EC2 setup where we have launched a few client applications with higher availability and reliability than in our previous setup and it has so far been a good experience. This is not to say we won't be building GAE apps at all - I still see a role for that kind of environment in our setup, but it didn't fit into what we wanted to be our primary infrastructure base.

In conclusion, GAE takes upon a lot of responsibility vis-a-vis Amazon EC2, but cuts down on a lot of a developer's authority. We chose to have a higher authority in exchange of accepting a higher responsibility.

Sunday, October 3, 2010

Musings on Android

I am hardly alone in the thoughts that Android is spreading itself too thin (thanks to @getanis who reached the same thought as I did). It seems that between Google, the manufacturers and the telecom operators, there are way too many parties involved, each of whom have the ability to screw up the final product. In the good old iPhone world, Apple took most of the responsibility - they designed, manufactured it (through FoxConn of course, but the specifications were Apple's), tested it, ran the apps, sold it and even did a significant share of customer service. And to me, that seems like a working model.

When the flash issue came up a few months back, some thought of it as a repeat of the Mac vs PC battle that was clearly won by PC in terms of market share. Yet, I believe this round of the battle is different - it is more like Windows vs Linux with Apple taking on the monopoly part and Android taking on the Linux part. Linux was fundamentally sound - open, and with lots of technical merits and yet, it fought a hard and mostly losing battle to win over desktop users. I always felt that Linux had way too many versions of the products flying around with little or no hand holding for the vast majority of the desktop users who needed a consistent experience across machines and over a reasonable period of time. Something similar might happen to Android with every body from Google to Verizon to Amazon wanting to run market places, and somewhere along the line, the experience might get diluted. Some feel Android is too open (to the detriment of end-users) and probably too supportive of operators - the parties who have killed innovation for too long.

The more pertinent thought for me, however, is that the economics don't seem to add up in favor of Android. When Apple alone is working on one product that can sell as much as a dozen Android phone, the the number of $s it can invest in making that model perfect is always going to be more and hence the product management, engineering and testing resources will always be more available for an Apple team to build a better product vis-a-vis Android products - which will be split between Google (who isn't going to be making much money per activation), manufacturers (like Samsung or HTC who will never boast of the best product/software-engineering teams) or the operators (let's just forget them as being the gatekeepers of phone quality - the best they can do is to provide good network coverage.)

(Observers of news on Yahoo will be wise to remember the peanut butter manifesto which covered the same issue - spreading yourself too thin.)

This is not to say that Apple won't mess things up - we have already seen Antennagate - but it seems that the dice is loaded in their favor of producing one good smartphone a year that can sell more profitably and can satisfy consumers a lot more than all the Android models put together in the same year.

What do you think?

Sunday, September 5, 2010

My Humble Take on Android vs iPhone

[Update: Read follow up post written after buying a second Android phone]

I recently shifted from an iPhone 3G to Samsung Galaxy S. Sort of, because I actually gave away the Nokia E63 that my wife held in exchange for the Galaxy S, while my old iPhone 3G was taken up by her. I have used it for about 10 days now and done about same kind of things I used to do with my iPhone - so I believe this review is well-placed.

To start off with, one of the primary motivations to buy the Galaxy S was because of the Android appeal. Android is one of the most talked about OSes out there and purported to be the real competitor to iPhone OS4. Secondly Android was often whispered to solve some of the thorny issues in iPhone - push Gmail, support for multiple exchange accounts, ability to run widgets and stuff, radio and in general openness (Oh, the tyranny of iPhone app store!).

The secondary motivation was that it was cheaper. After trading in my Nokia E63 and signing up a new contract for 2 years, the Galaxy S was delivered without me paying a cent. To compare, the iPhone 4 would have costed me $110 on top of that. Nothing much, but still the allure of moving to a more open OS coupled with it being cheap was too much to let pass. So, the Galaxy S.

Now the actual review. (Green means positive, red means negative, if you did not guess it already):

Hardware:
[Compared is a brand new Samsung Galaxy S with 18 month old iPhone 3G.]

  • The screen size is bigger and it doesn't lose out of clarity w.r.t iPhone 3G. For that bigger screen, it doesn't become any difficult to handle or keep in your pocket. In general, a plus.
  • It is so much lighter than the iPhone 3G. After handling it for a few days, when I pick up the iPhone 3G, it feels like lifting a brick.
  • The batteries can be replaced. One of my big gripes is that smart phones in general are a drain on batteries - they must be since they run so many radios and a powerful display - and hence the ability to change batteries is a must - for two reasons, one so that you can keep a spare battery fully charged up if you are a power user, and two to replace the battery a year later so that you can prolong the life of the phone itself (most phones degrade mostly on the battery front). On the other hand, the display on this phone consumes so much battery that it goes from 100%-4% within 12 hours with about 2 hours of actual usage. Turning off 3G doesn't help, as it did on iPhone, because the display is the real culprit here. More so, charging the phone from say 5% to 100% takes nothing less than 3-4 hours. iPhone 3G would do that in just over an hour.
  • Galaxy S is so slim that I am often afraid that it will drop it or it will slip from my hands.
  • For some strange reason (I am guessing that the electronics majors would throw some light here), the touch-screen becomes completely unusable when charging. The sensitivity is all thrown off and it assumes taps all the time, even when I didn't actually tap. In general, I disconnect it from the charger before using it.

Software:
[Compared is Android OS 2.1 to iOS 3.1.3. I don't care if Android fans respond to these arguments with Android 2.2 features because iOS 4.0 also has its own set of rather impressive victories.]

  • Swype. It is the way forward on inputting words on a phone. Typing just feels so 2000ish after using swype.
  • Gmail App is OK. I know, everybody seems to love the app, but I will give it passing marks at best. In general, it is good to have full web functionality, but iPhone always had that support through the browser while the native client covered 90% of my use cases. My main gripe is that the new mail alert disappears once I open the app, but not actually read the unread messages. On a busy day, I often open the app, see that the mail is not important and come back later, but with the alert gone, I am often deceived into believing I have nothing to read. The iPhone native mail client got it right - keep the number of unread messages always consistent with the actual unread messages inside, neatly updated every time you read something through the web browser (if you used IMAP/Exchange). On a minor note, usability hasn't been thought through - if you have a back button and you are in the inbox of one account, with other accounts also configured, what do you expect to happen when you click on back button? On iPhone it goes to the page listing all your accounts so you can go to one of the other accounts - intuitive, very intuitive. On Galaxy S, it exits the app itself. To go to one of the other accounts, click menu, then accounts and then you get list of accounts.
  • Usability of browser. Imagine you have been clicking around links and now you want to close the browser. How do you do it? On the iPhone you clicked home and you are done. On Android, you click back (which closes other apps) and you go to the previous page. So, you need to track back your entire browsing history to close it. Or you click home, leaving the browser running in the background, then go to app manager and then mark it closed. This was a big bummer.
  • Mutiple Calendar fail. One of the reasons I wanted Android was because of the full exchange support for multiple exchange accounts. Turns out they can't handle multiple calendar accounts, even if those calendars are all hosted on Gmail. This was again, a rather big bummer.
  • Widget/Calendar usability. You would imagine that a widget holding weather and stock information which comes default packaged with the phone would show you the current weather and stock information, right? Wrong. The widget sits right there with the information from the day you last refreshed it. If you want to update it, you have to click refresh. Now, who the hell was smoking cheap pot when designing this feature? Also, what is it with Calendar not notifying me when a meeting or appointment is due? iPhone did it neatly with an alert, but Android seems to do nothing of the sort. There is a tiny little message on the top, but if you didn't open the phone, you wouldn't get to know.
  • Contacts usability. I was using the iPhone to sync my contacts to Gmail. And on the web interface, I had filtered the contacts using groups such that only the most important and relevant would come on the phone (using "My Contacts"). In fact, in anticipation of buying an Android, I had spent hours organizing the groups to my best convenience - and guess what? The OS built by Google doesn't support the groups running on Google's gmail interface. In fact, the entire concept of groups is thrown off on Android's contacts app. If that wasn't bad enough, try updating an existing contact with a number from which you just received a call. On that interface alone, "search" is disabled. So, Android expects me to browse from 1000s (which is actually only 100s if the phone respected the groups that I created on Gmail) of contacts to update the contact. Absolute FAIL. It is so bad (and error prone) that I have stopped updating contacts using the phone and instead do it through the laptop when I get the chance.
  • 3G/2G switching. You would think that you, as a techie, knowing that 3G meant "faster internet but more battery consuming" and 2G, aliased as GPRS, meant "slower internet but less battery consumption", were learned enough to switch between the two on the Android, right? Wrong. You also need to know that 2G is "GSM only" and 3G is "WCDMA" and that "GSM/WCDMA (auto)" means auto switching between the two. Unfortunately, I did not. So, I couldn't figure out how to switch off my 3G to save battery. And after clicking on the GSM only mode (because I thought my phone was GSM and not a CDMA one), I couldn't figure out why my phone wouldn't run 3G. It took some wikipediaing to figure out that WCDMA meant 3G. Big big FAIL.
  • VoIP. For some strange reason, Skype is listed on Android market place, but only for phones sold on Verizon network in the US. Tried it on my phone's market app. Nothing turns up. Tried a few other methods. Then eventually tried installing it through back door entry (download APK, put it on dropbox and then install, as suggested by @jasonong), but it was a skype lite feature which wants me to pay for receiving calls on the phone while my Skype app is running. It is rather sad to read articles which talk about the dirty little secret of Android and realizing that it could all be true (and that I am contributing to it) and in the name of openness, we might be handing the power back to the very same companies who couldn't innovate a proper smart phone.
  • Background Apps. It is good to have the feature. At least half the world has been singing a positive song about it - except that I can't seem to figure out why to use it? I was really happy with my iPhone usage and never felt the need to have background apps except for VoIP. Now that VoIP support isn't state-of-the-art (without skype), background apps looks like a superfluous feature. I am yet to use it. (In the meanwhile, I am seething that iPhone 4 has both background apps and state-of-the-art VoIP.)
  • The whole marketplace tyranny issue. If Apple has been criticized from running a tightly controlled App Store, then Google should also be criticized for running a haphazard app store. There are apps for one provider but not for others (i.e. skype). There are also apps whose reviews will tell you how it works on one device and not other. The democrat in me (wanting an open marketplace) is losing left right and center to the user in me (one who wants the apps to just be available and work).
In summary, Galaxy S is reasonably good hardware, but with Android's usability, and the phone's usability in general, being average at best, specially if you are coming from the iPhone experience (even an old iPhone OS experience) you might feel disappointed. The "open" Android isn't as usable as the "closed" iPhone. And in general, the $110 you are bound to save is just not worth the money.

[Update: Read follow up post written after buying a second Android phone]

Friday, August 6, 2010

Strongly Typed vs Weakly Typed Languages - an interesting episode

There is no dearth of online content about either side of the battle about using either Strongly Typed Languages or Weakly Typed Languages. At a professional end, I don't really care as long as the job gets done.

Personally though, as an engineer, I have always favored using Strongly Typed Languages because it allows me better control of what is getting done. It requires extra effort because you need to be conscious about not just the variables, but also their types. Yet, that effort is easily offset by the lack of nagging bugs that happen because programmers just assumed all was hunky dory till the implementation detail of how the type conversions are done come back to bite you big time. This looks like a prime example of a Leaky Abstraction.

One of those examples came to bite us big time recently. Here is what was happening - we had to segregate all our users into two buckets so that the load can be balanced across farms. Since we had to keep this consistent over time, any standard hashing algorithm mapping strings to integers would have work.

The buggy code, written in PHP, applied the bin2hex function on the user id and then applied the modulo operator (to segregate into buckets) - something like "$bucket = bin2hex($id)%$bucket_count;". If you haven't figured it out yet, this is bad because bin2hex returns a string and when the modulo operator is applied on this, the result is well nigh unpredictable.

Internally, PHP converts this into an integer using intval and then applies the modulo value. Unfortunately, intval just ignores everything after the first alphabetic character it sees (returning 21 for "21a21a") or if the number is sufficiently large (for example "12345677778888999"), return the max value permitted by int which is 2147483647.


The net result of all this was a disastrous bucketing where one farm was receiving an inordinate load causing performance problems. We finally fixed it to use crc32, a PHP function accepting a string, returning an integer and then applying the modulo on this.

Now, if this were a strongly typed language, the modulo operation wouldn't be permitted on the string and hence forced the programmer to take the right step - use a function that mapped a string to an integer domain. This is where the consciousness of the type of the variable helps.

Lets now look at some of the arguments presented for weak typed languages. First is that it facilitates faster coding but I believe it just facilitates faster production of buggy code. After all, the aim of programmers should be to produce high quality code - not just code.

The second argument is that the quality of developers is what matters - languages like PHP can still enable great code, if the developer is right. Thats a fair argument, except that when you throw a language like that at a vast variety of programmers in a company where the number of engineers are in 4 and 5 digits, it is only a disaster waiting to happen. I will never accept that any company with that many engineers will only have superstars (unless we change the very definition of a super star).

The final argument is that PHP can be run in strict mode, but that just defeats the purpose, won't it?

I am not trying to say that a weakly typed language is totally unnecessary, just that it is a bad idea to use in you business logic and backend layers, which are prone to being buggy unless written with careful consideration of the type of the variables used. PHP, for instance is probably good for generating HTML code. I know this is a contentious topic, yet what's the fun of being an engineer and being agreed upon all the time?