Monday, March 31, 2008

Movies and books make a good weekend (or Han mujhe ye pasand hai)

Movies I watched this weekend -

K-PAX

You see Mark, what Einstein actually said was that nothing can accelerate to the speed of light because its mass would become infinite. Einstein said nothing about entities already traveling at the speed of light or faster. -prot

Prot claims to be from the planet 'K-PAX' and is sent quite unsurprisingly to the psychiatric institute. The movie revolves around his interactions with his doctor, Mark and the rest of the patients. Though the movie does not explicitly say whether prot is really an alien or not, I liked the movie. Some of the dialogs are quite insightful (and it had been ages since I watched an insightful movie).

Race

Ab aayega mazaa.. -RD

The plot is a bit convoluted, but execution is decent. People keep changing allies, so it is a bit hard to keep track of who is with whom. You will be better off using an E-R diagram. Saif gets a cool new look. But the female cast is a big disappointment (in terms of acting). Special effects are good, and I liked the song 'O Janejaa'. Overall, a paisa vasool movie.

Also made a trip to Crosswords. Here is what I bought -
The emotional brain by Joseph Ledoux
Bill and Dave by Michael Malone
Mathematical Mysteries by Calvin Clawson
Hasawanuk, Batatyachi Chal, Aghalpaghal and Marathi Sahityacha Gaaliv Itihas - all by P.L.Deshpande

But it has been a (bad) habit of mine to buy a bunch of books, read 1/2 and then buy the next bunch. I hope I'll get rid of it soon. Bye for now.



Wednesday, March 26, 2008

Hello, World..

Take a close look..

Object 1:











Object 2:

HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE


Object 3:
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++
.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.
------.--------.>+.>.

Now tell me, what is the similarity between 'Object1', 'Object 2' and 'Object 3'?

Turns out they are expressions of the famous 'Hello World' program in different programming languages. Yes, actual runnable programs!!!

First program is written in piet, a language 'in which programs look like abstract paintings'. It is named after Piet Mondrian, who pioneered the field of geometric abstract art. The change in color expresses commands. Like they say, What an Idea...

The second program will appear familiar to programmers. It is written in lolcode, oops.. LOLCODE. It is 'Programming the LOL way'. So the program entertains both you and (presumably) the computer. LOL!!!

And the third is written in a programming language whose link appears in the next paragraph. It has only 8 characters, truly minimalistic!! All I will further add is it lives upto its name, truly...

To know more about these languages, follow these links Piet, LOLCODE, and the third language :-).
There is also a wiki which cites many more esoteric programming languages.

And don't think that these languages are somehow esoteric by design. Here is a familiar example..

int n[]={0x48,0x65,0x6C,0x6C,0x6F,0x2C,0x20,0x77,0x6F,0x72,0x6C,0x64,0x21, 0x0A,0x00},*m=n;
main(n){putchar (*m)!='\0'?main (m++):exit(n++);}

This is 'Hello, World' in C that works with gcc, which most of us use everyday, taken from here.

So what is the lesson here? I like to look at it as a celebration of boundless human creativity. I think the readers will agree..


Wednesday, March 12, 2008

Can you top this regex?

Regular expressions (regex) is an indispensable tool for string processing. Languages like Perl are specially optimized for their use (as a side note, Perl was also the first popular high level language to have them built-in). Recently I was looking for a regex to validate an email address. How hard can it be? After all an email address is just something of the form 'something@something.something'. As it happens there is an RFC (RFC 822 to be precise) that describes the form of a valid email address. So you need to check the email address against that RFC. Now the power of 'the net' is precisely that somebody might have already solved your problem. And here is the deal, there exists a regular expression to validate an email address. Now you will ask, what is so special? You got stuck, googled it and found a solution, big deal huh? So let me tell you, the point is not that I found a solution, but what I found. Paul Warren wrote this particular regular expression as part of the perl module Mail::RFC822::Address and it is 6343 character long. Yes, you read it right, Six thousand three hundred and forty three characters. Take a look, here.

And why is it so complex? Because as per the standard '!@' is a valid email address :-). I am sure there are many more such cases. To quote the author, "The grammar described in RFC 822 is surprisingly complex. Implementing validation with regular expressions somewhat pushes the limits of what it is sensible to do with regular expressions, although Perl copes well."

I for my life never imagined there could be a regex this long (and useful too). So what is the lesson here? Can we do with simpler standards (which have a better chance of being implemented correctly (and efficiently))? I think so.


Monday, March 10, 2008

Notes from the weekend..

Friday 00:09 - Aahh, here comes the most beautiful day of the week, Friday. Just the tingling sensation of the coming weekend makes this day special.
Itni shiddat se maine tumhe paane ki koshish ki hai,
Ke har jarre ne mujhe tumse milane ki sajish ki hai.. (wah.. wah..)
Maybe I will someday write 'The joy of Friday', but now, time to go home. Did I tell you I am still in the office?

Saturday 05:03 - The weekend begins, 2 days of 'Do what you want to do' and not 'What needs to be done' and also have 'a lot of fun' (arre ye to poem ban gayi). Saturday also means no hurry, sleep as much as you want. But why am I awake at this ungodly hour? Of course because I am still in the office..

Not much about the rest of the saturday, you see I don't do much when I am sleeping..

Sunday 12:03 - Just woke up, Now need to watch a movie, but which? My options are 'Jodha Akbar' and 'Welcome'. I started watching 'Welcome', expecting it to be a good timepass, but to tell the truth, it squashed all my expectations. Bad jokes, bad storyline and bad direction. Ohk, I will watch 'Jodha-Akbar' then, hope it won't s$%^ this much, you see I really need to watch a movie.
Now I am not a big fan of historical movies, not the least because I can't understand the language very properly. Like 'Shahenshaho ko Shahenshah' ya 'Malika ye Hindostaa'. I don't understand how people managed to keep their jaws from falling off using these mouthful phrases (but sometimes it is good to listen, I'll admit). The movie seems good in fragments, but you probably can't watch it in one sitting. So long and so slow. Better if it had been made in two parts :-).
Did nothing much after the movie. Just ate and slept.
The weekend was not exactly what I had wished for, but that does not mean it was any less fun.(yes, pulling an all nighter is still fun :-D)

P.S.
One more thing, Jaggi returned on Saturday with a spanky new XBox 360, but we could not turn it on (our power supply did not like it much I guess, and in the process we managed to fry a fuse, :-)).

P.P.S.
I also fulfilled my long time desire to watch 'Sivaji - the Boss' this weekend, this movie is amazing. Rajnikanth does so many things in so little time. He beats the crap out of thousands of gunda log, after returning from US as a multimillionaire, becomes poor and turns the tables using just a single one rupee coin, changes his getup couple of hundred times and also eats a plateful of red chillies to show his love to the heroine. Usake samne sab hollywood superheroes (superman, spiderman and the rest of baccha party) look like 'paani kam chai'. hehehe..