Thursday, September 29, 2005

Adrian Carmack Fired

It seems Adrian Carmack is fired from id. Read more

Friday, September 16, 2005

Language Integrated Query

Microsoft has come up with something called Language Integrated Query (LINQ) in C#3.0 (actually it is supported in CLR, so in also). This is too cool. What this means is that you will be able to write SQL kind of queries directly in the language. How this differs, well take an example in java where i try to query something

PreparedStatement pstmt = con.prepareStatement("select name from Employee");

Now the query is just a string. It doesnt have any compile time checking, say if you write mame instead of name, you will need to wait until runtime to find that error. (Not that this makes a big difference, because you should always write unit tests to verify your program parts).
Lets see how this is with C#3.0

Customers[] customers = ...

var q = from c in customers
where c.City == "London"
select new {c.CompanyName, c.Phone};

Now lets look at this in detail.

First, we see that whatever query we are writing is working on customer array. So the LINQ not only works with database, but with in memory collection, xml etc. So it is in fact "integrated" with language(C#), database, xml.

Second, we see that from comes before select unlike in SQL. (in sql you write
select foo from bar
from bar select foo
). Why this is so? well if you think about it the bar scope should actually come before foo. ie foo is a field in bar. so if you dont specify bar before foo, how the can say editor know about foo.

ie say you are writing in the ide

from bar select .. 
(and press ctrl + space)
you get all the fields in bar, because we specified bar before select.

if it was the other way around

select .. 
(press ctrl + space)
nobody has any idea on what object you are writing query .. (bar is still in your head)

So in C# they made from before select. You get intellisense in your query!

Third, we see something
new {c.CompanyName, c.Phone}
. what is this? well this is a new object which has fields CompanyName & Phone. You dont have to create a new class for it, it is anonymous.and the type of q is if you say q. (ctrl + space), only CompanyName and Phone pops up. Well there are many more type inferencing going on with anonymous functions (lambda) etc .. all with compile time type checking. (well even though i love python with dynamic typing, intellisense is one thing which is the way to go).

I dont know how many lines of code are going to be reduced because of these new features.

From Anders Hejlsbergs video, i see a lot of things .. please do check it from here

Java is trailing behind C# .. they have good Generics support with reification, .. now this LINQ. All are looking so cool. It will be interesting to see how java catches up.
Talking about microsoft, there are tons of stuff they are coming up with ie7, sparkle... in this year's PDC .. see them at channel9

Update: covered in slashdot

Thursday, September 01, 2005


Ive been looking for an abdomen excercise equipment for a long time. The rate at which my tummy is growing meant something to be done quickly. Since im too lazy to go to gym, having something at home turns out the only option. I finally found one shop where they give one such thing, the "ab king pro". You must have seen it many times in tv, during the teleshopping breaks. I quickly fell in love for that one :). Well, even after seeing in discovery channel how the marketing guys in tele shopping network bundles crap and sells stuff, my decision didnt change. So yesterday, i went with my friend , who intern wanted to buy a handycam, to search for it. After spending considerable time in sony world we got a handycam. It was already late, around 8:30pm, and when we went to a nearby gym shop, it was closed. So i decided to go for my old gym shop. Its somewhat far, around 2km from forum, the shopping mall. I enquired for the stuff, and indeed it was there. I tried few crunches and decided to go for it. The thing was pretty big, and it needed to be assembled. There was a middle aged couple there trying out different things. The guy came and tried the ab king pro in the least difficult position. He had a respectable tummy. I wanted to make a joke in malayalam(my native lang), that with that tummy he wont be able to rise, but didnt cos you dont know who he will turn out to be, and has happened to me many a times in bangalore. Since it needed to be assembled, they agreed to send a guy to home for it. I was insisting that it was not required, and to my surprise the earlier guy started giving me advice in malayalam saying it was better if i take that guy along, since some screws etc may be missing. phew .. my experience turned worthfull. Now the task was how to take it home. It was night and getting an auto seemed hard. I left the shop, with the guy carrying the equipment. My friend also left to his house. So, me and the guy waited there for some time waving hands to all the passing autos, and none of them stopped. The guy adviced to walk to nearby bus stop, since there was fair chance of getting autos there. So we walked till there, and again tried. Now the place where i want to go is called Hongasandra, which is some 2kms from Bommanahalli. There is something about Bommanahalli, which makes every auto driver treat you in contempt. We tried enticing drivers with nearby places like Madivala, but with no success. Finally one guy seemed up for it. When i told its Hongasandra, he said even said yes to it. The gym guy needed lift till forum, so i took him along. I wondered what made the driver go to Hongasandra, at late this night with meter on. Then i thought he might not know about the road from Bommanahalli to Hongasandra. The gym guy left at forum. The driver tried asking me something in kannada. He wanted to know what was inside the big case. I told him it was exercise equipment which he didnt understand. When i told "gym", he understood. Since i coudnt understand kannada much, he tried asking my native language, whether it was tamil or not. Finally we settled on hindi.

Him: people who dont understand hindi are worthless .. and some people think that hindi is pakistan's language.
Me: hmm ..
Him: So how much is that thing worth

now i was a bit worried. late this night, he is asking the price of this thing, what is his intention, to mug? ..

Me: some 3k

Him: what is it for
Me: for stomach exercise
Him: So .. (with cunning smile) its for building stomach
Me: no .. its for reducing it
Him: In bangalore, everybody seems to be getting tummy..

he started talking bit on that .. then about the traffic, why it was oneway etc.
Him: Hongasandra is far from Bommanahalli right?
Me: (so he does know Hongasandra) .. ya, around 2kms from there

after some time, we reached Bommanahalli, and the road to Hongasandra was horrible as usual. With some miraculous escape from traffic, we started ..
Him: I once came here in Hongasandra.

Now the main transport between Hongasandra and Bommanahalli is share auto. Its ordinary auto, but they will take around 3-4 (sometimes even 6!)people. The charge 5rs per person. Its nice to have that facility anyway. I really dont know how many autos are there, but i can assure you, the probability of getting one the moment you step outside is nearly one.

Him: Well, while returning back i put on my meter, and people said they will give only 5rs, because thats the way it is. I thought if there are three people giving 5rs, fair enough.

Me: ya .. thats how it is

Him: There was a girl also in the group. When i reached Bommanahalli, i talked a little bit about the charge. She also talked a bit, and said suddenly "are you married?" I asked why, and she asked, "do you want to try something". Well i was
dumb struck by that, and asked how will i do that?

She: i go to (some) computer institute around this time, so you can catch me .. what do you think?

He started saying general things about these
Him: What the hell should i do in such situations? This is what happens. Think of the guy who marries her. Will she also try some other people
Me: (in deep thought) hmm..
Him: Usually girls say they "love" somebody, and this may go on with many no of guys. Then they will finally say "ive been raped". Well i ask its not peoples fault if they virtually come and ask "rape me". My marriage has also been a love marrige, but think if somebody married her.The problem is, if you encounter such a girl in your life, you might as well end up thinking all girls are like that, you may not be able to face another.
Me: true .. (still in my thought .. well there has been many cases of misbehaviour against girls.. and some people here even started some movement, where they go to the extremes .. like now its considered "looking at a girl" as sexual harassment .. for some people. The guy has a point .. some of the girls itself ask for it)

Him: so finally what happened was, i told her that i will consider this, but let me ask my wife. You should have seen her face when i told this

Me: haha ..

Him: There was another incident like this once .. i met a guy in auto, he was from sikkim .. we talked about various things, i knew even the name of this guy. After some day, he came in my auto again. He didnt remember me, but i remembered his name. I called by his name, and he was startled .. i said, you are from sikkim .. blah blah. He was startled.. then i told about the previous time i met him .. he seemed to remember a bit

Him(driver): you look tired .. what happened
guy: well iam debarred from college
Him: what happened ... (and i knew looking at him that he used some kind of drug) .. do you take drugs?
guy: no!! ..
Him: well there is no need to shy .. even i take
guy: is it ..

By the time we reached near our house .. some more to go, i showed him the routes
Him: After that, the guy asked whether you would like to come see his group. It seems there are even girls taking drugs .. he started saying about different drugs like affine, gancha, snake poison ..
Me: snake poison?
Him: Well i have been in this town for a long time .. and i never knew such drugs are available here .. and see this guy who has been here for a little over 6months and taking all these . Anyway, i thought of checking the place .. i had my uniform over my shirt, so i removed my uniform and went like a college guy. When i got inside, i was shocked to see that many people smoking drugs. Then suddenly a girl came to me and kissed me! .. i immediately left .. because i knew longer i stayed there, the chances of getting AIDS are high

Me: this is the place

Him: I usually avoid coming to places like Hongasandra at night .. because if your tyre goes flat, you are gone

Me: true ..

I unloaded my ab king pro .. The meter read 49rs .. I gave him 100rs and waved him goodbye.