I know how annoying it is when someone moves their blog but I'm afraid I have no choice. Comment spam, technical problems and also the fact that I now work for Microsoft have all contributed to me moving my blog to http://www.sriramkrishnan.com/blog. The new feed is at http://www.sriramkrishnan.com/blog/atom.xml.
So if you want your regular dose of Sriram Krishnan from now, update your aggregators :-)
[Updated with new blog home]
This blog has been silent for over a month - probably the longest stretch ever.I have a lot of excuses for this. I've been pretty busy with various things, from college exams to Imagine Cup zonal finals (which my team
won btw).
Tommorow is a pretty big day for me. I'm flying to Hyderabad to join Microsoft- I've accepted a PM offer on DevTools. For those who know me, you know how big a deal this is. I've been a fan of Microsoft for a long,long time and the idea of me being inside the company and watching Longhorn, Whidbey get shipped is just mind-blowing.
This also means that I'm leaving Chennai, the city where I have lived all of my 21 years. Moving to a new city and living alone is going to be a huge change for me, in more ways than one. I have a lot of connections to Chennai,to the people in it. I'm going to miss a lot of them.
There are a few people without who this wouldn't have been possible. You know who you are - I can't begin to thank you.
As for this blog, I'm not sure whether I'll continue blogging here. Comment spam, downtimes and other issues have made blogging here a less than pleasant experience. I'm mulling over whether to join the rest of the B0rg at blogs.msdn.com or set up my own domain and server. Anyway, I'll let you know here as soon as I'm set up.
So long Chennai...and thanks for the fish.
An’ here I go again on my own
Goin’ down the only road I’ve ever known,
Like a drifter I was born to walk alone
An’ I’ve made up my mind
I ain’t wasting no more time
But, here I go again,
Here I go again,
Here I go again,
Here I go...
[This post is dedicated to Vivek who gave me permission to blog this (it was his discovery) under the condition that I send some PageRank to his photoblog]
GMail has been sporting a counter on its homepage since April 1st, counting upwards from 2 GB. I saw blogposts calculating that counter to hit 3GB on Jan 1st 2006. But the interesting part is - that the counter is hardcoded to hit certain sizes by certain dates (take a bow,Vivek).
The hardcoded values changed very frequently (every few hours is what Vivek reported). So to see what the counter is programmed to hit,follow these steps.
1. Go to the Gmail homepage and view the source code.
2. Find something similar to this
var CP = [
[ 1112439600000, 2050 ],
[ 1114308000000, 2125 ]
]
You'll almost definitely have different numbers and/or different number of elements. The 2xxx number on the right is the size and the long number on the left is the time at which the counter is supposed to hit that size (in milliseconds).
3. Type this into the address bar of your favourite browser
javascript:alert((new Date(1114308000000)).toString());
replacing the long number by the one you saw inside the CP array.
You should see a popup telling you a date. In my case, due to my clairvoyant Javascript powers, I now know that GMail will have 2125 MB of space on April 24th.
Who says predicting the future is Nostradamus' monopoly?
In a little tidbit that you can't find anywhere else online, Scoble let slip that there won't be a sidebar in Longhorn. Later in the same thread, Scoble talks about how this is generally a good thing due to the screen real-estate the sidebar was taking up.
This is huge - for the sidebar was one of the big things shown off at the PDC (and even had Rory writing small sidebar tiles).
I'm not sure I agree on the real-estate argument. I've set up my taskbar on the right side of the screen due to the quick access it gives me to stuff on the quick launch bar. I'm sure running MSN on the sidebar would have been killer.
Longhorn is just around the corner and there is a sense of excitement in the air in Microsoft circles. To quote Sean Alexander
"..I'm getting that old feeling again. Like that first early morning when you can smell Spring in the air....And the more I talk to folks on the Longhorn team, the old excitement about shipping great software is back... "
I'm a huge admirer of President Kalam and it has always worried me that he didn't seem too friendly to proprietary software. I always thought that he's not getting the full story from our side of the fence. So it was a pleasant surprise to read his speech at the Microsoft Academic Summit.(http://www.presidentofindia.nic.in/scripts/eventslatest1.jsp?id=848)
I liked this quote especially
" Microsoft has done pioneering work in providing a cost effective operating system for the Personal computer segment, which is indeed user friendly "
We should make a huge poster out of this and put it up at all our conferences too :-)
The only thing I don't like about my broadband connection (Net4India) is their horrible connector. It's a Win32 application which opens up an ad-page every time I connect.Also, there's no connector available for Linux. On Windows, that application makes me disable all my other ethernet cards as it picks the first one it finds.
This evening, I got really annoyed - so I pulled out Ethereal and after some hacking, wrote my own connector. It works on Windows and it *should* work on Linux though I haven't tested it yet. Replace the username, password, dns server and ethernet mac address with your own.
On Windows, save the code below as Connector.py and run it after installing Python from www.python.org (for the benefit of those who are new to Python). On most Linux distros, you should have Python installed, so executing it shouldn't be a problem.
Of course, no guarantess and don't blame me if your computer explodes or Net4India sues you :-)
#!/usr/bin/env python
import sys
from socket import *
import time
# Simple Net4India Connector - fill in the values below and you're good to go.
#TODO:There's no explicit disconnection
# yet - you just have to kill the program.Net4India will disconnect you automatically within 5 minutes
#Not that it isn't possible - I'm just too lazy. If anyone is interested,
# all you have to do send "reqType=logout##@@##sessionID="+ session_id + "##@@##dummy=dummyone" + chr(10)
# Replace the following values with your own
user_name = "your_user_name"
password = "your_password"
# Find the MAC address by ipconfig /all on Win2k and above and winipcfg on Win9x.
# See /sbin/ifconfig eth0 on Linux. Replace eth0 with the correct ethernet card
mac_address = "00-0B-2B-13-C3-27" # Your mac address
# Ask your local guy what your DNS server address is. Or find it from ipconfig /all if already configured
dns_server = "10.32.0.2"
port = 6699
server_message = ""
def make_connection():
cli_sock = socket(AF_INET, SOCK_STREAM)
if cli_sock.connect( (dns_server,port)) == -1:
print "Connection error"
sys.exit(-1)
return cli_sock
def send_command(command):
global server_message
cli_sock = make_connection()
cli_sock.send(command)
server_message = cli_sock.recv(400)
cli_sock.close()
return server_message.startswith("YES")
def main():
print "Sriram's Net4India Connector SRIRAMK@GMAIL.COM"
mac_str = "reqType=init##@@##mac=" + mac_address + "##@@##dummy=dummy" + chr(10)
connect_str = "reqType=login##@@##user=" + user_name + "##@@##password=" + password + "##@@##macAddress=" + mac_address + "##@@##version=1, 0, 0, 6##@@##dummy=dummy" + chr(10)
if not send_command(mac_str):
print "MAC Authentication error. Wrong ethernet card or card not recognized by local provider"
sys.exit(-1)
if not send_command(connect_str):
print "Couldn't connect. Entire message is " + server_message
sys.exit(-1)
print "Connected!.Leave this program running to stay connected"
session_id = server_message.split("##@@##")[1] # See the other values of this list for things like
# data transferred, time left,etc.
#Connection has to be refreshed every 5 minutes. To play it safe,I'm refreshing every 4 minutes.
refresh_str = "reqType=refresh##@@##sessionID=" + session_id + "##@@##dummy=dummyone" + chr(10)
while True:
time.sleep(240)
if not send_command(refresh_str):
print "Couldn't refresh. Entire message is " + server_message
sys.exit(-1)
if __name__ == '__main__':
main()
For those among you who (like me) struggle with plain text mailing lists in Outlook, you might finally have an answer. Outlook QuoteFix (
http://home.in.tum.de/~jain/software/outlook-quotefix/) let's you bottom post easily, with proper quoting and all without having to cut-paste large amounts of text. It sits in the system tray and processes mails. I wish it were an add-in though - that would have been a lot easier to work with than having to launch Outlook from this application everytime.
http://www.google.com/googlegulp/faq.html
I found this part of their FAQ hilarious. I wish Google did April Fool's pranks on other days of the year too.
"
4. What if I don't want to use Auto-Drink™?
No problem–– simply turn off Auto-Dri™k™ on your Google Gulp preferences page.
5. Well, shouldn't Auto-Dr™nk™ be default-off?
You mean we should cripple a perfectly useful feature just because of a little bad PR? ..
9. I mean, isn't this whole invite-only thing kind of bogus?
Dude, it's like you've never even heard of viral marketing.
10. Will Google be coming out with more food products?
As a rule, Google doesn't comment on future product releases, but...let's just say for now that a cool, refreshing drink isn't complete without, oh, say, chips and dip, is it?
11. When will you take Google Gulp out of beta?
Man, if you pressure us, you just drive us away. We'll commit when we're ready, okay? Besides, what's so great about taking things out of beta? It ruins all the romance, the challenge, the possibilities, the right to explore. Carpe diem, ya know? Maybe we're jaded, but we've seen all these other companies leap headlong into 1.0, thinking their product is exactly what they've been dreaming of all their lives, that everything is perfect and hunky-d–ry – and the next thing you know some vanilla copycat release from Redmond is kicking their butt, the Board is holding emergency meetings and the CEO is on CNBC blathering sweatily about "a new direction" and "getting back to basics." No thanks, man. We like our freedom.
"
Watching this, I really felt as if I was watching the future of computers. Very inspiring video. And if I were part of the WinFS team,I would play this video at every single opportunity to show people what WinFS is here to do.
http://channel9.msdn.com/ShowPost.aspx?PostID=46813#46813
I just saw this Slashdot post on Indian police stopping militants from carrying out attacks against software companies in Delhi. I'm just shocked to see the sheer number of jokes on call-center quality, tech support and outsourcing in general. Moreover, I'm surprised to see that tons and tons of these posts have been modded up as well (totally around 138 comments as I'm reading this).
Perhaps some people should understand that people in those call-centers also have families, loved ones. They lead normal lives, play around with their kids, fall in love and do all those things normal human beings do. And if the only thought that hits you when you read something like that is "Gee...where will we get tech support now?",there's something seriously wrong with you.
Sorry for the rant folks. Tech stuff as scheduled from next post onwards.
[Update]
A close friend IMed me on seeing this post and quoted Shakespeare
If you prick us do we not bleed?
If you tickle us do we not laugh?
If you poison us do we not die?
And if you wrong us, shall we not revenge?
For all the folks (including me) who questioned Google's ability to ship software, you have another thing coming. Google Desktop (http://desktop.google.com) is now out of beta. Among the new features, you have full-fledged API support (which is really cool), a floating box on your desktop where you can search from and Thunderbird support. See http://battellemedia.com/archives/001305.php for more
[Update: This is why I love Google. On their submissions page, they have a text box for developers to specify Easter eggs.Awesome!]
I'm getting overwhelmed with the comment spam here and have temporarily turned off comments. If you want to say something, mail me at sriramk@gmail.com or better yet, blog about it and link to my post.
Sorry folks- some people spoilt it for everyone. Hopefully, once DotNetJunkies gets upgraded to CS 1.0, I should be able to turn on comments again.

For the first time , I saw a print ad from Google today. Though they were advertising for a relatively lowly Adwords position (lowly when compared to the more glamourous dev/PM jobs), it's still interesting to see Google jumping into the recruiting-ads fray. I would have thought that Google didn't need to advertise and that people would stream in - but perhaps that isn't happening. Or maybe Google is growing faster than it can handle.
The ad is cool though. :-)
I remember watching a video of one of the creators of Dylan where, when asked about his guiding philosophy, he says something to the effect of "Simplicity is tough - complexity is easy. It's easier to build complex things than to take the trouble to make them simple". It struck me back then as weird ,yet at the same time, profound.
Over the past week, we (the people working on Smoke) have been trying hard to make a lot of things simpler. For instance, we've cut down on the number of opcodes used. We've cut down on the work needed to be done by the compiler writers. We've slashed data structures built only for performance. In fact, in a lot of places, we're choosing simplicity over performance. The last thing I want to do is to have a piece of code, hand-optimized to the core, but unmaintainable and difficult to explain, understand and work with. As someone said, "People cycles are far more important than programmer cycles".
Simplicity also means something pretty painful - cutting features. In our case, we've had to cut features due to time constraints. Our problem is- something like a virtual machine is very difficult to design right the *very first time* and yet, that is exactly what we have to do if I'm going to stand any chance of demoing it 2 weeks from now. For example, I've cut down on the number of intrinsic types, some esoteric features,etc. The Lisp compiler may not happen now - if it is done, it'll probably be in a much simplified form.
This project reminds me of 'flying' from Hitchhiker's Guide to the Galaxy - we're throwing ourselves at the ground and trying to miss.
I feel really stupid after making 2 newbie STL mistakes. Next time, I promise that I'll read the documentation first before assuming that the a data structure would work similar to the equivalent in .NET/Python whatever
Container objects and pointers
Container objects run the destructor on their member objects when they destruct. However, if you're storing *pointers*, the destructors won't be called. If you don't call them manually, you'll have a memory leak. Lots of ways to solve this - using shared_ptr from the Boost library is probably the best. I personally wrote a wrapper because Boost introduces other problems for me.
Using character pointers as the key in a map or a hash_map
Basically..don't! Character pointers are bad,bad in C++ and if you're forced to use them like I am, read the following carefully.
If you do something like map<const char*, value>, you won't get the results you're looking for. STL will compare *the pointers* rather than the string itself. The best way around this is to use the inbuilt string objects or pass a custom comparer class.This is what I'm using - may be buggy but it seems to work for now
class WStringCmp
{
public:
bool operator() ( const WCHAR* s1, const WCHAR* s2 ) const
{
while( *s1 && *s2 && *s1 == *s2 )
{
s1 ++;
s2 ++;
}
return (*s1 < *s2);
}
};
[Update: This code actually has a bug in it, believe it or not! See
this post. Also, thanks Deepak for the conversation which led me to spot this bug!]
I've been poking around for operating systems or operating system-like environments written in managed environments. The two I could find pretty easily are Nachos and the fascinating Singularity project from MSR (which has very little public information). I have a little idea in mind for which I'm looking at previous work in the field.
Does anyone know of related work? Help would be deeply appreciated :-)
I've been watching this flash video(http://www.microsoft.com/mscorp/innovation/yourpotential/main.html) - and I have to say, apart from the video itself, the music totally rocks.
Does anyone know which song that is? I've been trying to find out but with no luck :-(
Update: Found it! It is a piece called '
At the Edge' by Jonathan Elias. Thanks to the commenter who pointed me to
adforums.com
I was talking to a former MSFT employee who worked on the CLR team. The conversation drifted towards languages used to implement virtual machines. Here's what I learnt.
The CLR's Garbage Collection was initially written in Lisp by a Patrick Dussud (I can't find a blog). This code was then run through a Lisp->C converter which was then cleaned up by an intern.
No more arguments about the practicality of Lisp from yours truly. I'm truly stunned.
Don't you love the way all my titles in this series refer to famous movies. Well - I think it's cool anyway.:) As always, if you want to help out, you'll find the links at http://smokevm.sourceforge.net - though there's nothing much there yet.
Writing a VM (like writing anything else) involves a series of choices. Some of them are clear cut if you take things like your goal, resources,etc into consideration while others can be real head-scratchers.Here are a few of those choices (I might write about them in detail in a later post)
Calling a function - Register-based vs Stack based
All the popular mainstream VMs(JVM/CLR,etc) today are stack-based.This means that for every function call, the arguments are pushed onto the stack and any form of communication involves pushing and popping off the stack. Parrot, however, uses a different register based mechanism.It has a zillion registers where you can pretty much stuff in anything. So, instead of pushing in 2 integer variables for an 'add' function, you just put them in 2 integer registers and call the function.
Now, both have their pros and cons - the Parrot folks are convinced that their way is better as it offers better performance (the theory being that compiler writers know how to write compilers for register-based machines better). Now, as tempting as this looks, I played safe on this one and stuck to a stack-based VM as I was safe ground on that one.
Calling functions - Continuation Passing Style or Not
Continuation Passing Style (or CPS in short) is this elegant way of calling functions used mainly by the Lisp guys. If you don't understand continuations, don't even bother trying to understand this. Basically, instead of every function returning its value to its parent, the parent function tells the child function which function to pass the result to. No function call ever returns. Yes - I know it doesn't make sense. Dan says it better than I ever could.
Probably the most famous application was Guy Steele's work on the RABBIT compiler for Scheme back in the 70s. Parrot uses a CPS-style to call functions too (they seem to do all the cool things).
Again, I decided to play it safe and stick to stack based mechanism. Though having a CPS mechanism would make it easy for me to do continuations in the VM, I wasn't sure as to how to convert all programs to CPS style. However, the way my VM is structured, we could probably add CPS without too much effort.
Executing byte code (Direct function calls vs. Indirect function calls vs. TIL vs. the Big Switch vs. JIT)
Now, you have the byte code with you - but how do you go about executing it? You have a bunch of options again. Frankly, I didn't know much about this till I looked at Dan Sugalski's presentation on the topic. We decided to go with the big switch for now - but with the extra feature of the programmer having the ability to add opcodes and handle them *at runtime*. Kaushik is itching to finish everything else and do the JIT :-) - so I'll leave a discussion on the JIT to him.
Garbage collection (Ref counting vs Mark-Sweep vs Copying vs Generational)
This thing deserves its own blog post - so when I find the time, I'll write up something on it. Right now, we're going with a ref counting mechanism (cyclic references be damned!) till we find the time to do a mark-sweep. As for a generational GC, that just seems like too much work considering the limited time we have
The language - C or C++
We went for C++ in the end as I saw most code written in C for VMs trying to emulate classes and objects anyway. Kaushik still hasn't forgiven me for this ;-)
Every day, we run into several design choices, though these were probably the biggest ones. I'll blog the others if I find any interesting