Thursday, July 10, 2008

Interview with Sir Clive Sinclair



When I was studying in 9th/10th standard, ZX Spectrum was my object of desire. I used to buy whatever books on ZX Spectrum I could get hold of. Finally Dad bought me a similar Z-80 based home computer called Color Genie.

The above is a spectacular interview with Sir Clive Sinclair, the man behind ZX Spectrum. Following is an excerpt:

Interviewer: They required you to get to grips with how they worked. You have to engage in primarily things where you played around with programming, and even kids like myself, if you wanted to write a game on the Spectrum that played at a reasonable speed, you have to effectively teach yourself to write Assembler which took a significant degree of technical understanding about how the machine worked. Everything now is very much plug and play. Do you think we miss out in the terms of getting to know how these machines work as a result?

Sir Clive: Very much so, and I regret that, because you know, your generation really understood the computers and today's generation know they are just a tool and they didn't get to grips with them, which I think, I find it very sad.

Spot on Sir! Hats off to you for the incredible inventions! Your work has been immensely inspirational for me and countless others.

Tuesday, June 24, 2008

String Comparison Gotcha in PHP!

Can you expect a mature language that has been around for 13 years, and powering many web sites to do basic string comparison properly? No, not really!!

$x[0] = "10000000000000000000001";
$x[1] = "11011000000000000010101";
$x[2] = "10101010101010101010101";

$toFind = "11011000000000000010001";
$k = array_search($toFind, $x);
echo "match is $k";

$p = ($toFind == $x[1]);
echo "match is $p";

Run the above code and see for yourself! It will match $toFind with $x[1]!! I got hit with this nasty surprise when calling the array_search() function for a programming contest problem. It appears like PHP is truncating these strings, which it thinks are numbers and comparing the first few characters. Can anyone give a logical explanation of what's going on? Am I doing something fundamentally wrong, or is PHP hosed?

Update: Jude pointed that using "strict" flag in array_search() uses "===", and hence gets rid of the problem. But the fundamental question still remains. Why would PHP do an automatic type cast to integer while comparing two strings?

Update 2: The fundamental issue can be traced to this single statement in PHP documentation - "If you compare two numerical strings, they are compared as integers." This was the root of all problems. I don't like that behavior, but hey this is PHP. I have a similar gripe with Tcl as well. Try this:

set x "072"
puts [incr $x]
set y "09"
puts [incr y]

It will print 59, followed by an error 'expected integer but got "09" (looks like invalid octal number)' as Tcl treats any string starting with 0 as octal - a tradition it borrows from C, but unfortunately, it overloads the string type!

Monday, June 23, 2008

My kids on mugs!


Played around with POV-Ray, GIMP and the photo I took, over the weekend. Oh the joys of ray tracing! Credits to Ian Shumsky for the mug object!

P.S: If you like any of your photos to be on the virtual mug, send it to me and I'll generate a scene similar to this and send it to you.

Monday, May 26, 2008

AWS Meetup Chennai

We, the motley crew from Impiger (Ashok, Abi, Ram, Priya, Umaima and myself) just returned from AWS Chennai meetup. It was a great evening and we were able to hear what's new in AWS from Jinesh Varia, the evangelist from Amazon.

One of the highlights of the event was the demos. The coolest, imho was from nboomi. It has some cool 3D models of homes which you can customize. It is flash based and the demo was fascinating. It seems they store the models in S3. When I tried it out though, my Firefox memory usage shot through the roof and I had to kill it. I'm sure they will fix those kinks pretty soon. Also, our demo of Boxcloud was received well. I also got introduced to Hadoop and TimesMachine.

One problem with AWS is the barrier to entry for developers, as they are required to sign up with a credit card. I suggested that Amazon lower that barrier by providing sandbox APIs. They can control it by clearing out the data periodically and limiting the number of hits from an IP per day. Jinesh is going to look into that. I hope one day it will happen :)

Saturday, May 24, 2008

Funny (but true) Quote!

Seen on the tagline of Slashdot user eldavojohn

"Can god code something so unusable even he can't use it? No, but I can and so can you: http://www.microsoft.com/careers"

*lol*

Sunday, May 4, 2008

RoR Scalability

I have written about this earlier. Now here we go again. It's about Twitter having problems scaling.

Volume Fade Out Sleep Timer

I usually take a nap Sunday afternoons, and I like to hear some streaming radio during that time. I wanted something that would fade the volume down to 0 after a certain period of time (say half hour). I decided to give it a shot myself. It's Tcl and Snack to the rescue! After twiddling with the Snack API for 5 mins, here is the code:


package require snack

set line [lindex [snack::mixer lines] 0]
snack::mixer volume $line v1 v2

set totalTime 1800; # half hour
set delay [expr $totalTime*10]

for {set v 100} {$v>=0} {incr v -1} {
set v1 $v
set v2 $v
puts "[clock format [clock seconds] -format "%T" ] - $v"
after $delay
}


It worked out well. And for the record, after I woke up, I googled to check if there is something out there that will do the same thing. There were many utilities, but the one stood out was this, based on something called AutoHotKey. I 've never heard of that before, but sounds very impressive.