Thoughts from WWDC 2011

The technical sessions
I can’t talk much about the technical sessions, because of the gag order, but trust me.. if you are a developer, you will be salivating at getting your hands on iOS5. Tons of new api’s, and lots of fixes/missing functionality

The Truth is in the cloud
This is a remarkable makeover for a desktop/device centric company. The transition is happening at a pretty remarkable pace too. iCloud makes it easier for iOS developers and consumers. Moving data is seamless, and requires very little effort.

Google is about the web. Apple is about native

Last year’s WWDC had a lot of HTML5 centric tracks. This year, they are all gone. There was no mention of it in any of their keynotes, and there was maybe one or two session on Safari/HTML5. They are adding tons of API’s for native, zilch for services.

My Take: Apple is deemphasizing web centric development, because they want to channel everything through the app store. It is not about technology, it is about control. For example, they want a cut from their ‘NewsStand’ functionality from subscriptions. And there are attempts to bypass them by publishers who are unhappy about this, like this interesting story about the Financial Times .

But what does this mean for companies that need to support iOS as well as other platforms, like Andriod? There are no web services available. It is unclear what the terms of service will say. For many companies, unless Apple moves to define web services for iCloud (as opposed to native bindings), iCloud will be worth avoiding. Using iCloud would mean support iCloud for iOS, plus additional services for non-Apple platforms.

I suspect that many companies will take a hybrid approach, like doing some stuff in a UIWebView, while other functionality will be in a native shell, and they will be stitched together using tools like PhoneGap.

‘It just works’

This will sound like a fanboy statement, but I believe Jobs when he says this. The demos on opening day were quite astounding. Make a change on one device, and it is available on another pretty much instantaneously. They have done a terrific job of making moving data part of an OS task, irrespective of whether the app is running, suspended or otherwise not running.

It truly did work. For me personally, this solves a big hassle of having data spread across multiple devices. I am looking forward to this.

Cutting the cord

Finally. I am ecstatic. iOS 5 will not require you to connect to a computer. While the statement seemed to be driven for people whose first and only computer is an ipad or an iphone, this will be a huge help for people with multiple devices also.

Yep, it will maintain MacOS as the leading ease of use OS. I wonder about the scroll part though (which has been reversed to make it consistent with touch behavior). I tried it out and it blew my mind instantly. It will take getting used to.

The $30 price tag makes the upgrade a no-brainer. Downloads only from the app store? How the heck does someone in say, India, download 4GB’s? It will be a killer, IMO. I struggle through Xcode installs now, at 4GB, and have to let it run overnight. (My cable modem ISP is throttling me, I’m pretty sure). I read the statement as ‘we don’t really care about non-1st world countries getting Lion’. Fortunately, incremental downloads are on their way.

There is a reason I prefer Chrome over Safari. Speed and the ease of upgrade. It just happens, and I don’t really care about uprades. Apple could learn a thing or two from Chrome.

Buy once, use everywhere
My wife and I both have iphones. We both have a MacOS machines. I do not need to buy apps multiple times – buy once and use it on all the machines associated with your account. Nice

Do Women rule the internet?

An interesting article doing the rounds is one titled ‘Why Women Rule The Internet‘. It is authored by Aileen Lee, who is a partner at Kleiner. The article is just strange. I fail to understand the premise and the conclusion it draws.

The premise of the article is
– Women are the majority of users on social websites
– Women shop a lot on the internet, more so than men
– More women are active on twitter. (Apparently, Twitter is supposed to be a ‘techie insider’ product. I am stunned)
– So Women rule the internet

It is no secret either that women are more active in social aspects of life, from relationships to parenthood. (I hope this does not sound chavunistic). Men’s magazines are about fast cars, girls and more fast cars. Women’s are about relationship, fashion and beauty. So why is it surprising that social web sites – all about relationships – attract more women than men?

How on earth is ‘Women shop a lot on the internet’ insightful? I have no interest in digging up stats on this, but really, is that so different from the experience in malls? Women shop more. The fact that they shop more on the internet – well, duh.

I find it interesting to see how ‘consuming’ is being mistaken for ‘ruling’. Consumers are not rulers: they are the suckers who purchase products and fork over their hard earned money. The producers of web properties are the rulers. They take your money to the bank. Women will rule the internet when they produce the web sites where consumers – men and women – go to consume. It is heartening to see more women entrepreneurs, as alluded to by the story. But to claim they rule the internet is silly. When the next generation of Facebook, Zynga, Groupon and Twitter has female CEO’s, there is a claim to be made. Till then, the only claims that can be made are ‘there are more women consumers of social and shopping web sites than men’ and ‘If you are selling stuff online, make sure you take female consumers into account’.

HTML5 Canvas ‘strangeness’

I was experimenting with the Canvas tag, and the code below worked great on Firefox, but would not on Safari or Chrome:


function draw(img) {
var canvas = document.getElementById("canvas");
if (canvas.getContext) {
var image = new Image();
image.src = "http://localhost:3000" + img;
var context = canvas.getContext("2d");

Quite baffling. No errors on the javascript console either. It took me a little while to figure out that the problem.

The problem is that the browser may load images simultaneously while executing your javascript If the image load is not complete, well, your image does not display properly, and as far as the browser is concerned, there is no problem. (interesting how firefox 4 beta worked every time)

The solution? Attach an event listener,



function draw(img) {
var canvas = document.getElementById("canvas");
if (canvas.getContext) {
var image = new Image();
image.src = "http://localhost:3000" + img;
var context = canvas.getContext("2d");
image.onload = function () {

Notice the addition of the eventlistener and the onload. That fixed it.

using ImageMagick+ paperclip with rails3 on MacOS

  • Download Imagemagick binaries from here

  • open a terminal and run ‘tax xvzf ImageMagick-x.x-x’

  • You will now have the untarred file, but not in the right location. I suggest installing it in /usr/local/imagemagick. So from your shell, do ‘sudo mkdir /usr/local/imagemagick’. This assumes that you are in the sudoers list

  • You will need to update your path so that the binaries are picked up. If you are using bash, go to your home directory and open .bashrc, and add this line:

  • [code]
    export PATH=/usr/local/imagemagick/bin:${PATH}

  • gem install paperclip

  • create paperclip.rb in config/environments of your rails project. Add these lines:
  • [code]
    Paperclip.options[:command_path] = "DYLD_LIBRARY_PATH=’/usr/local/imagemagick/lib’ /Users/sram/Downloads/ImageMagick-6.6.5/bin"
    Paperclip.options[:magick_home] = ‘/usr/local/imagemagick’


  • Restart your server, you should be good to go. Use Jim Neath’s excellent tutorial to use paperclip

Fun with websockets, Node.js and jQuery

Websockets have the potential to make a big difference to loading on webservers, and improve interactivity characteristics of client side.

Coupled with Redis for persistence and Node.js for a fast web server can make a huge difference to the performance of your web server. I will focus on websockets in this tutorial: Redis and Node.js will be covered later, and there are lots of good sources for them on the web.

I worked on a little experiment to see how Node.js & websockets work. If you are just getting started with websockets, this tutorial might help you out.

Make sure to use a browser that supports websockets. Firefox & Opera have removed support because of a security hole. I have tested with Chrome.

Client Setup
Here is some really simple HTML to build the demo:

[code lang="js"]
<!DOCTYPE html>
<title>Websocket test</title>
<script type="text/javascript" src=""></script>

<div class="dvStory">
<form id="fmStory">
<textarea id="taStory" rows="2" cols="20"></textarea>
<input type="submit" id="buStory" name="submit changes"/>

This will give you a text area and a submit button.

Let’s finish setting up the client. We’ll add some javascript to set up websockets

Add Javascript
We’ll set up some variables to use in javascript. The websocket code is really simple to setup and use

[code lang="js"]
<script type="text/javascript">
alert ("socket is null");
var fm = $("#fmStory");
var ta = $("#taStory");

function doOpen() {
var s= new WebSocket('ws://localhost:8081');
alert("socket open");
s.onopen = function () {
//s.send ("ok I am warmed up");
return s;

var socket = doOpen();

function sendData() {
// alert ("ta changed");
socket.send ( ta.val() );

doOpen() creates a new websocket, running at localhost port 8081, and sends a hello message to the server when the socket is opened. Pretty simple API. The variable socket gets initialized, and sendData() is called every time the client needs to receive data. Websockets are bidirectional, of course, so unlike regular HTTP connections, they can receive server initiated data, which needed other methods like Comet earlier (or usage of polling). We’ll look at how to recieve server data next.

[code lang="js"]
ta.change (function (event) {
$('#buStory').click (function () {
alert ("click event");
socket.send (ta.val());
return false;
socket.onmessage = function(event) {
//alert ("got message" +;


sendData gets called when a click even or a change event occurs. If you are not familiar with jQuery, just know that you can register for events and react to them, which is what ta.change() and $(‘#buStory’).click() do.
Finally, socket.onmessage is what gets executed when the server sends a message to the client. We just update the text area with the message pushed by the server.

This is the way the code works: Any client connected to the server will send a message to the server when a change event or a submit takes place. The Server will turn around and echo the change to all connected clients. So to try this out, have multiple windows open connected to the server.

Save the code in a file, client.html. You will be opening localhost:8081/client.html to try this out.

The Server Code
Download node.js and a nice library to make websocket usage more convenient,

Once you have installed it, type up the following code

get some libraries

[code lang="js"]
var sys = require("sys"),
path = require("path"),
http = require ("http"),
url = require ("url"),
fs = require("fs"),
debug = require("util"),
events = require("events");
// Library
var websocket = require('../lib/ws/server');

Create the webserver

[code lang="js"]
/ create web socket server
var server = websocket.createServer();
// listen on port 8081

Next, we need a way to have the server return HTML files. This part of the code is taken from the excellent tutorial at tutsplus

[code lang="js"]
function load_static_file(uri, response) {
var filename = path.join(process.cwd(), uri);

path.exists(filename, function(exists) {
if(!exists) {
response.sendHeader(404, {"Content-Type": "text/plain"});
response.write(filename + "404 Not Found\n");

fs.readFile(filename, "binary", function(err, file) {
if(err) {
response.sendHeader(500, {"Content-Type": "text/plain"});
response.write(err + "\n");

response.write(file, "binary");

Now, if our node.js server receives a regular HTTP call, we know it is looking for the client file , so we just return it

[code lang="js"]
server.addListener("request", function(req, res) {
var uri = url.parse(req.url).pathname;

So when the client connects with http://localhost:8081/client.html, the server will just return the HTML.

However, if the connection is a websocket one, here’s the code that gets invoked

[code lang="js"]
server.addListener("connection", function(conn) {
debug.print (" Yo, welcome!");
// when client writes something
conn.addListener("message", function(message) {
debug.print ("yo, got message " + message + "\n");
// iterate thorough all connected clients, and push this message
server.manager.forEach(function(connected_client) {
debug.print ("sending message to" + connected_client);
connected_client.write(JSON.stringify( + ": " + message));

What is happening here? We add a listener, which hangs around waiting for connections. When there is a connection, we wait for a message to come. When a message is received, we iterate over all the connections, and write it to all connected clients. debug.print can be used to debug on the server side.

Thats how simple using websockets is, and combined with node.js, they can be pretty awesome.

Should you roll over your IRA to a Roth?

There is some shockingly bad advice on the web about converting your traditional IRA to a Roth.The advice typically says that ‘Oh, you will grow your money tax free once it is rolled over, so you will end up with more money’. Even worse are statements like ‘the greater your expected rate of return, the more sense a Roth conversion makes’.

I am not a tax advisor, but I know


When I see it.

It is shocking to hear well respected tax advisors and other who you’d have expected to have take elementary math classes state this. let me disabuse you of this notion by presenting a simple example. But first, some background.

Let’s recap what the two IRA’s are. The traditional IRA, which is what most of us have, pays money in on a pre-tax basis: you have to pay taxes when you withdraw the money at retirement age, presumably when you are in a lower tax bracket than today.

In the Roth, on the other hand, you pay in money post-tax, and the money grows tax free. You can convert the Traditional to the Roth by paying taxes. The big change is that the limits on conversion – you had to earlier make less than a certain income – have been removed. Anyone can convert Traditional to roth by paying appropriate taxes.

For our example, the assumptions we make are

1. Whatever your expected rate of return is does not vary depending on whether it is a traditional or Roth IRA.

2. Your current tax rate and expected tax rate at retirement are the same. Let’s make this 20% (We will expand on this later)

Ok, here is a Math 101 explanation of what does and does not matter:

Let’s say that you have $1000 in your traditional IRA. Your money has grown 400% compounded at the point you withdraw money.

Scenario 1: No Roth

In scenario 1, you choose not to roll it to a Roth. How much money will you have at retirement?

Before taxes, you would have accumulated $1000*4 = $4000. The govt will swoop in and demand that you pay them 20%. So you will end up with $4000 – ($4000*.2) =$3200.

Note this down, kids: You will have $3200 in retirement if you do not roll over to a Roth.

Scenario 2: Roth Conversion

Let’s assume now, under presssure from your tax advisor, who presumably will have a little extra in his paycheck for giving you this advice, gets you to convert to a Roth. Let’s rerun our analysis.

Your tax bill (remember, we fixed our tax rate at 20%) = $1000 * .2 = 200.

Your tax free investment: = $800 (well, minus what you paid your advisor)

At 400% (Tax Free! Yay!) growth you will have: $800 *4 = $3200.

Wait, What? You end up with the same amount??

Yeah. As you learned in middle school, a*b = b*a.


If the expected tax rate at retirement is the same as your current tax rate, it matters not a whit whether you convert to Roth or not. You expected rate of return is irrelevant.

So what are relevant reasons for a Roth conversion?

There are subtleties to be aware of – after all, this is the US tax code.

The most obvious reason, already alluded to above, is the expected tax rate at retirement. if your expected retirement tax rate is going to be higher than your current, by all means, do the conversion – makes sense to pay less now. For many of us, this is not going to be true. Don’t do it if your expected tax rate in the future is going to be lower than your current.

One reason it might make sense to convert part of your traditional to a Roth is because of the  withdrawal regulations. at age 70.5, the IRS will take a penalty if you do not make a minimum withdrawal from your traditional. No such thing for the Roth.

Another subtle reason comes from the $200 tax bill that you paid up front for a conversion. If you were not using it for the roth conversion tax bill, you may have invested it – in a taxable account, which is subject to capital gains tax. The $200 will attract additional taxes.

Caveat Emptor!

Understanding the Tour De France

Once a year, there is a bicycle race held in france, called the ‘Tour de France’. French is, of course, different from english, and frequently they take the first two letters of a word and put it at the end. So, the english ‘detour’ becomes ‘Tour De’ in french. So the ‘Tour de France’ means that they will be taking a lot of detours in france, because french people love going on strike and frequently leave the roads in a dug up state.

The race consists of different types of stages. There are the flat stages on which men with large hamstring muscles compete with each other for a green colored jersey, but more importantly, for kisses from nubile french lassies. But the organizers of the Tour De France restrict the kisses to three apiece, much to their chagrin. There is a polka dot jersey awarded to the person who climbs up mountains quickly. This is presented by women wearing polka dot umbrellas instead of skirts. This is handy if it starts raining during presentations. in 2010, this was won by a frenchman named Anthony Chartreau, who took this name because of his penchant for wearing chartreuse colored pants.

Yellow is the color of the race. The leader of the race wears a yellow jersey. The French call the person wearing the yellow  jersey ‘Major John’ for reasons unknown to anyone. In order to win the yellow jersey, contendors (also known as contadors in french or spanish) have to cycle over big mountains and flatlands.  Some of the big mountains in the 2010 stage included the ‘Col de Tourmalet’ which translates in English to ‘Hard to suck in enough air’, and ‘Col d’Aspin’ which is an abbreviation of ‘Its cold and climbing it will give you an ass-spank’

The leader of the 2010 race is known as ‘Contador’ since most people ‘can’t adore’ him. He caused a big controversy by sprinting up a big ass hill when his competitor Andy Schleck’s chain slipped. Andy Schelck claims to be from a country called ‘Luxembourg’ which very few people have been able to find thus far. Schleck also claims to be the national champion of Luxembourg. All the people who have successfully found Luxembourg say this is true, but they add that there are only two bicycles in the whole country. The other bicyle in Luxembourg belongs to his brother, Frank.

Lance Armstrong won the race seven times. His former teammate, Floyd Landis, accused him of taking drugs. So did another Tour De France winner, Greg Le Mond, who is, inexplicably, american in spite of his name. Lance is famous for wearing and selling yellow rubber bands.

Teams in the Tour De France are sponsored by companies. The US teams are sponsored by Radio Shack and by Garmin-Transitions. The Radio Shack team members are eligible for upto 10% off on any purchases (in store only). The Garmin team gets a free GPS, but all the riders turned it down since they are all using iphones. There is a team sponsored by ‘LiquiGas’, which is pronounced by as ‘LeakyGas’. It is unclear why a company would call itself LeakyGas, and why any bicyclist would be willing to say ‘I have Leaky Gas’.

On TV, the race is hosted by a group of four people. Craig Hummer moderates it . Craig invented the  Hummer automobile after a long bike ride one day when he thought. ‘This is crazy. I could be in an air conditioned car and climb over 16 inch walls if I were to invent the Hummer’. The second person is Bob Roll, who was a pro bike rider before he got disqualified for making expansive gestures with his hands, and then found that television audiences loved it. There are two Britishers, Paul Sherwin and Phil Liggett. They spend a lot of time polishing thier accent and arguing about whether Cant-Adore should have waited for Andy Schleck when his chain slipped.

The race always finishes in Paris, on the Champs-Élysées. This allows the riders to finish shopping for their spouses after the race finishes, without which they are not allowed back home.

Once the race is over, everyone goes home and sleeps for the next 3 months to get over their exhaustion. Especially the radio announcers who need time to recover from their excitement and relieve their vocal cords, which are  stressed from the  high pitched sounds they have made for three weeks in a row. Fans forget about bicycles till the next time the Tour De France starts. Many of them then pretend to be Tour De France riders and put on silly pants and shirts that cost $100. This gives them the privilege of advertising for large corporations.

Comparing WWDC and Google I/O

I was lucky enough to have attended both WWDC and Google I/O this year. It was interesting comparing the two: There were clear cultural differences, differences in approaches and similarities in outcomes. Here are my thoughts:

1. You are lucky to be here vs Thanks for coming

It was quite clear to me that Apple considers me lucky to be able to attend WWDC. This was made obvious in several ways: Long, Long lines to get in, though it was well managed (and expected). The massive gift giving at Google (HTC Evo, Droid -what the heck were attendees supposed to do with 3 phones other than quickly sell two?)  vs the – oh wait, you were lucky enough to be standing in line to get into WWDC. All Google I/O sessions available to everyone vs very restricted distribution of WWDC sessions. The egalitarian $450 admission for I/O vs the $1600 for WWDC. Not to mention that after the two phone giveaways at I/O, you come out about $150 ahead, after some consultations with Craigslist.

Lunches at WWDC was quite horrible, compared to quite tolerable at I/O. (I am a vegetarian, so could not tell you much about the meat selections).

2. Slick and polished vs  Functional

No question, the presentations at WWDC were really polished. I was in awe. Presentations were incredible. So polished, so precise, so well put together and so well organized. I wonder how they rehearse them. I can’t remember a single incident where things did not go exactly to plan. Hats off to Apple engineers who did the presentations.

Not that the presentations at Google were bad. But they were what you’d expect a bunch of engineers to present. It totally lacked the polish. I think of Apple being a product management company, and Google being an engineering company. That explains the difference in presentations. Google could learn a thing or two from Apple here.

3. It’s HTML5 all the way, baby

Poor Adobe. Sorry buddy, but you’re so f’ed. All everyone at Google and Apple could talk about was HTML5. And it totally rocks. ( I will follow up with a post later on HTML5).

If you are doing web development, get on this bandwagon. This is one of those seminal events in technology. It has all the heavy hitters lined up behind it. Apple has put an extraordinary amount of effort into it, and the sessions on HTML5 were great at both I/O and WWDC. I preferred the Apple sessions just because of the additional polish in the presentations.

While the Adobe CEO was invited to the stage during the second day keynote, he got a very indifferent response. It was obvious to me – and I think most of the others – that Google was just inviting Adobe to the party to make noises about ‘openness’ not because they think flash has a future.

4. Baiting vs Ignoring

Vic Gundotra, the Google VP, was clearly going after Apple in his address with some nonsensical (IMO) talk about openness. Apple and Google have different business models, and they are executing to that. Some of the potshots were low blows, IMO. Jobs, and everyone else at WWDC, ignored Google for the most part – the feeling I got was that they were saying ‘eh? Android? What is that?’

5. Walk alone vs Partnerships

There was no partner pavilion at WWDC. I/O had a big one. WWDC is about Apple. I/O is about Google and friends

6. New friends and Old Enemies

Clearly, the Google vs Apple battle is now the new battle in town. The Microsoft vs Apple one is over. Apple spent a lot of time cozying upto Microsoft. Expect this partnership to deepen as they ally against their common enemy.

7. HTML5, again

This is where the enemies cross paths. Google and Apple clearly want HTML5 to win, and they work closely and deeply on advancing this. Safari 5 is pretty awesome, and a step ahead of chrome in HTML5 implementation.  Maybe Adobe can work on a nice implementation of an HTML5 editor


If Adobe is the clear loser with HTML5, Microsoft is going to get cleaned out in battle between the iPhone and Android devices. They should consider cutting their losses.

9. Focus, Focus, Focus

Apple made it very,very clear where they want developers to be: iPhone and iPad, XCode/iOS4 and HTML5. Thats it. forget MacOS. That is a sidenote. All the presentations were arranged accordingly.

On the other hand, I/O presented a smorgasbord of technologies, with no real underlying theme (well, maybe HTML5 & Android). Google Wave was still there . Buzz has a few sessions. There was even a session on engineering management. Huh? Please, attend the WWDC and understand how to run these.

10. The obvious

All the women at I/O were interviewed, as were all the women at WWDC. Both the ladies attending I/O and all three attending WWDC said they liked the sessions.

Did you attend either or both? Do you agree with my opinions? Let me know