Wednesday, November 30, 2005

Daily Blogs!: Thinking of the Abstract

Daily Blogs!: Thinking of the Abstract This is a trackback to one of Thite's blogs. It's about an essay he wrote in the tenth standard, about abstractions. Go read it first to grok the context of this post.

This is a pretty good piece of writing for a tenth grader. I don't think I ever came close to writing anything like this back then - just the usual tripe they saddled us with in school. As with many things, whatever little ability I have with the written word seemingly sprang into being like Athena springing fully grown from the head of Zeus. I can't remember ever actually practicing or anything...

This may have had something to do with the fact that I never really wrote anything for the hell of it back then. :)

*BEGIN PEDANTIC SPIEL*

Er, one doesn't think *of* the abstract, but rather *in* the abstract - hence the phrase 'thinking in the abstract' . Inconsistent? Not if you're Spanish - AFAIK they always say pensar en rather than pensar de, which would be the direct English translation...

I suspect the real reason for this confusion is that a fifteen year old Thite didn't appreciate the distinction between the words 'abstract' and 'abstraction'. A little creative substitution will confirm this hypothesis.

*END PEDANTIC SPIEL*

"Where two abstracts meet we find physical existence. One man can alone think of an abstract idea. But then he himself cannot imagine it physically. Add another person with the same idea. Let them debate on it. Let them decide. And physical presence will originate."
I beg to differ. Two people debating on complex numbers will not give them any physical presence, since they aren't properly isomorphic to real world entities. Unless you count their weird quantum-mechanical uses to represent probabilities, which on quantum scales have both magnitude and direction, and are pretty abstract themselves...

What you think is *not* reality - that's independent of your image of the world. It's pretty obvious that you can't hold an exact model of the universe in your head - too much complexity. (Remember H2G2's Total Perspective Vortex?) So you make do with a little approximation, something close enough to get you across the road without being run over.

Q: Why did the chicken cross the road?
A: Because Nadeem was using him as a lame example to support some dumb idea in a blog post.
This business of 'your mind creates reality' pisses me off no end. Consciousness does not manipulate the universe - at least not at the macroscopic level we inhabit. And for those about to invoke quantum mechanics, be warned that a camera(or something similar) can collapse wave functions too. Go figure.

(If you don't get the wave function part, forget it. That bit wasn't addressed to you anyway.)

Stuff like this reminds me of those New Age dopes who go around talking about 'energy' and such stuff. For Einstein's sake people, get it through your heads that energy isn't this glowing thingy that keeps moving all around us. You wanna see that, gawk at a neon light or something. And enough with the 'positive energy' stupidity. The adjectives you can stick before the word 'energy' are words like 'mechanical', 'kinetic', 'electrical', and so forth. Even 'potential', though that's slightly deeper. Physicists and others who get the context can get away with using the term 'potential'. Those who don't should stick to saying 'mechanical potential energy' or 'electrical potential energy'.

Human beings often grab at an idea for the reason expressed in the sentence 'Oooh - shiny!'.

The reason so many people buy the 'energy' crap is because it sounds semi-scientific and has weird(but cool sounding) mystical connotations, with the usual dose of omnipresence that appeals to their theistic inclinations. That's a very devilish meme to fight.

Enough with the ranting now. Here, look at this disclaimer instead.

Disclaimer: Keep in mind that the views expressed in the essay are those of Hrishikesh Thite circa five years ago. Presumably he's older and wiser now. Eh, Thite? :)

The weird ending was probably just an attempt at coming up with a grandiose climax to get more marks. God knows I've written plenty of weird but stylish conclusions with only tenuous connections to the subject at hand. I've probably done it on this blog too, but at least here I preface such specimens with the usual 'incoherent and disconnected rantings' tag, or words to that effect. There's no excuse for doing that in an essay, but dumb tenth graders don't really know any better.

Some teachers don't know any better either. I remember consistently scoring incredible marks in ninth standard English because the teacher apparently appreciated my style. Unfortunately my tenth standard teacher didn't appreciate it that much, being of a more staid school of thought. Sad, but at least she could appreciate really good English. A lot of the people who correct English papers for the SSC board exams aren't even English teachers, or are bad English teachers. My school(which rocked) never had bad teachers(seems so strange now), so I never ran into that problem there, but it's still a fact that they are more crappy English teachers than good ones. In fact, there are occasionally ads in the paper for a certain big coaching class of the slave-driver persuasion, and they write in this really hilarious English. Typical Indian gaffes are literally dripping from their ads. And to top it off, one of their founders apparently teaches English, and there's usually a message from him that takes the cake.

Looks like I've been ranting again. Sigh...

For those who haven't figured it out yet, this entire post was mostly an excuse to avoid studying Advanced Microprocessors. Just a bit of the usual stretch-your-fingers blogging I do occasionally.

Tuesday, November 29, 2005

One down

So that's it for Intelligent Systems. Pretty okay exam, except for the scary first question asking us to design an expert system for software testing. Naturally, most people wrote stuff about all sorts of related things, while dancing around/diverting attention from the main question. Makes you wonder how many of our politicians are engineers...:)

Incredibly, they actually asked us a question on genetic algorithms. I hadn't studied a word about it, but that didn't make a difference, since I wrote a little genetic algorithms framework in Java over a year ago, and then ported it to Python to boot. I have a feeling that I and Hrishikesh were the only people who weren't caught on the wrong foot by it.

Sagar blogs again! It's a miracle...

He actually plans to do it again today. That'll be another miracle.

I'm beginning to wonder if I should produce one blog post after every exam. With the nice long holidays, I shouldn't have any trouble fitting it in with the usual punishing schedule of studies.

Off I go to fight with my sister for a bit...

Monday, November 28, 2005

Something wicked this way comes...

And that thing is the exams. Yep, the moment of truth has arrived - or will in about 10 hours.

Every semester, I'm reminded of one word at exam time - Kralizec, the Typhoon Struggle. In the world of Dune, the Fremen use this word to mean the cataclysmic battle at the end of the universe. It's never really very clear who exactly they expect to fight, but a myth is a myth is a myth...

In any case, comparing Mumbai University Engineering exams to the Typhoon Struggle is like comparing the Battle of the Alamo to a minor roadside altercation. And no, I haven't messed up the order. It's the sort of thing a hell-and-damnation type of preacher cooks up to illustrate the tortures of hell to his unbelieving flock. Abandon all hope, ye who enter here.

Once more unto the breach...

Sunday, November 27, 2005

Charles Babbage on dumbasses

"On two occasions I have been asked[by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
10/10 for the way he describes that weird feeling of incredulity you get when techno-dumbos say something stupid. The ancients always did have a knack for subtlety.

This just came up because I was doing First Order Predicate Logic, and remembered the old 'Falsity implies anything' business. In other words, the right answers may or may not come out. It depends on the calculation you happen to be making. False premises can imply true conclusions, or false ones. That's why you should always be sure of the veracity of your basic assumptions.

Check out these links:
  1. Wikipedia on Babbage.
  2. Computer Stupidities.
Back to studies again...

Yet another uninspired blog post

So the exams are just two days away now - the first paper is Intelligent Systems on Tuesday. While we do have really long intervals between exams(3 and 4 days in each case), it looks like I'm going to have to do some tremendously intensive studying a la standard 8 and 9, when I usually studied about a week before the exams and always did unreasonably well. There was a guy I knew years ago who was always really pissed off about this sort of thing, since he studied as hard as he could and still had his ass kicked by unworthy nuts like me with no preparation at all.

I just hope the old magic is still alive and kicking - I've been so incredibly busy sending off apps that I've barely touched anything. I don't think I've ever been this underprepared for an exam - ever. Thankfully I have all the studying I did for the vivas to fall back on. Hail Mumbai University - at least they had one good idea.

Oh yeah - the apps are all gone now. So that's finally over.

There's a pigeon nesting outside my kitchen window. There's a grill there, on which my mom, who has something of a green thumb, has arranged a number of flowerpots with a pretty incredible variety of plants. Ditto for the living room window, which looks even better. I have a sneaking suspicion that all this new foliage is the reason there seem to be more birds around here nowadays.

Anyway, the aforementioned Mrs. Pigeon has taken up residence in an empty flowerpot. She deposited two eggs(my mom claims there were three) there a few days ago. Unfortunately, the depredations of crows and an eagle have left her with just one egg. Sad.

Just went over to the kitchen to take a look. Mrs. Pigeon was sitting on the eggs, though she seemed somewhat sleepy - her eyes were closed and she didn't notice the first few seconds of my visit. Sleepless nights?

When she did see me(through the window), she did something I'd only read about- she puffed up to almost twice her normal size! I didn't even know pigeons could do that, but she does seem to have received extreme provocation. Woe to any would-be egg eaters - they're going to have to fight one very pissed off mother. I wonder if she would be willing to take on the eagle my mom saw. It probably wouldn't be much of a contest - eagles are bigger, stronger, not to mention bred to kill.

Still, I've given up on trying to figure out the weird powers that mothers have. I'm pretty sure most people have received the "It's going to rain. Take your umbrella along" prediction from their mothers, on a completely cloudless day. Needless to say, we all disregard this advice and are duly soaked.

Hmmm, maybe there's a reason we say Mother Earth and Mother Nature...

Tuesday, November 22, 2005

Of hidebound reptilian humanoids, otherwise known as bureaucrats

Just when you begin to feel better disposed towards the bureaucracy, some specimen of that wretched caste comes along and leaves you with the conviction that the entire race of bureaucrats are the bastard offspring of an unholy ménage à trois involving a human, a reptile of some sort, and some species of dung beetle.

Bureaucrats. Bah humbug.

Sunday, November 20, 2005

News and stuff

What follows is a long-winded, idiosyncratically arranged and rather disjointed set of rantings, descriptions, commentary, and the other sort of useless writing that can usually be found on my blog. I'm not exactly sure why I'm blogging about all this stuff, though. Sometimes it just feels good to have prose flow from your mind, through your fingers into RAM/virtual memory, and eventually onto the Web.

Sagar and Thite had the CAT today. For those who don't know, that's one of the world's deadliest entrance exams, used for getting into the IIMs and other fancy management institutes. Even I find it a bit scary, and I actually cleared the IIT-JEE...Anyway, not being a management type(at least not yet), I didn't have to suffer the tension of competing for about 2000 seats with about 175000 applicants. That's right - 175000. After all, India accounts for about a sixth of the world's population. Big numbers like that are inevitable. They also account for the inertia that prevents things from being changed easily in most walks of life. Add to that a self-satisfied entrenched bureaucracy, and there's enough material to rant about for a year or so. This I choose not to do at the moment.

In any event, Thite and Sagar both had a bit of a shock when they were confronted with 90 questions rather than the usual 150. Why is this bad, you ask? For the simple reason that the CAT isn't meant to be finished in the time they give you - they've built it so that completing everything is impossible. The real key is to do as many as possible in the time you have, so you need not just skill at solving, but skill at choosing too. Thus when you have fewer questions, choice is no longer as big a factor, and because solving these things is so terribly difficult, most people are deprived of their chance to score. Presumably this year they're looking for people with more skill than luck.

Next up, sis and Mom are leaving for Bangalore tonight. My cousin's wedding reception is being held there. I would have gone along, but as I mentioned in a previous post, I'm stuck here. Sana, if you're reading this, a gazillion apologies - I really wanted to make it. The universe is just giving me a raw deal. I say we chuck the current administration out of office, since they don't seem to be doing such a great job anyway. Naturally, I am willing to step in graciously to accept the burden of cosmic power. And I've always wanted to stand on the Empire State, with lightning flashing in the background, and thunder modulating itself into the words "I am the Almighty Silicon God! My will be done!"

It also helps that since my view of God is practically deistic(God, the do-nothing king), I can just sit back and leave the universe to run itself for all eternity. Rather boring, of course, but then this measly universe is hardly worth my divine attention...Perhaps I'll make a few more of them, more suited to my tastes. Might also take Sundays off, a tradition the present incumbent established quite clearly in the book of Genesis :) ...Maybe it's a union rule, and if not, it ought to be.

Ran into an interesting MSDN article by James McCaffrey on generating permutations using these weird things called factoradics. This is getting really interesting, so I think I'll go take a closer look at it, and then write my own Java implementation. Maybe even port it to Python after that - after all, I did use Python to generate permutations even before I learnt anything about the traditional backtracking algorithm. That was rather icky code, too.

Hmmm, this looks like the second time this week I've referred to my earlier code as ugly/icky/incompetent. Reminds me of Paul Graham pointing out the difference between the way coders learn to code, and physicists or mathematicians learn to do physics or maths. The physics guys start out by doing good stuff(i.e - solving problem sets) and eventually get original. On the other hand, coders start original(the aforementioned ugly code) and get good. At least that's what I remember of his comment.

So it isn't that surprising that my early attempts at coding stuff were ugly. It's like trying to prove the Theorem of Pythagoras without knowing much geometry. You might just come up with a proof, but odds are it's gonna be anything but elegant.

Saturday, November 19, 2005

And I rise again!

Just finished off SRM 272 and had a nice healthy rating increase - a cool 70 points from 1266 to 1336! Now after they finish the usual ratings rerun after removing cheaters and all that, I'm hoping that I end up with just one more point. That way I can brag that I am officially '1337'.

PS: If you can't figure that out, try reading the numbers as letters. If you still don't get it, try saying the word out loud. And if you still don't get it, read this article at Wikipedia.

Friday, November 18, 2005

Of binary searches and undefined behaviour

The java.util.Arrays class provides a little binarySearch() function. I was reading through it's documentation, and I came across this interesting line:
If the array contains multiple elements with the specified value, there is no guarantee which one will be found.
If you ask me, this is a painful restriction. Binary search is pretty commonly used, and it's not that difficult to think up a version of binary search that finds either the first or the last of the multiple occurrences. I'm a bit surprised that they didn't do that - it's not a very large piece of code.

Anyway, it turns out that you can use a binary search to pull off something like this, with practically no difference in code size. In fact, it actually seems smaller than the conventional implementation. The difference is presumably that you only check for equality right at the end, when the interval is just one unit in size.

Here's the stuff I hacked up. I had a slightly weirder version up a while ago, but it didn't work for certain inputs. This one seems to be perfect.

// Returns 0-based index of the key if it exists, -1 if it's not in the list.
public static int binarySearch(int[] list, int key)
{
int n = list.length;
int lo = -1, hi = n-1;
while(hi-lo > 1)
{
int mid = (hi+lo)/2;
if(list[mid] < key)
lo = mid;
else hi = mid;
}
return list[hi] == key ? hi: -1;
}

Suggestions and challenge cases are welcome. Feel free to try and break this code.

Side issue: The Blogger edit window goes nuts whenever I try to edit this post. Something about the code is conflicting with the HTML or something. My guess is the way HTML encodes '<' and other signs('&lt' anyone?) . Any ideas?

The Law of Leaky Abstractions - Joel on Software

This article is a must-read. It's about abstractions, how they occasionally slip('break' as Joel puts it) and what that means in actual development.

Condensed version: All non-trivial abstractions are a bit leaky. Thus they save us time working, but not time learning, since at some point the abstraction slips and you have to look below it to figure out what's going on.

There's also an interesting example at the end. I quote:
And when you need to hire a programmer to do mostly VB programming, it's not good enough to hire a VB programmer, because they will get completely stuck in tar every time the VB abstraction leaks.
No wonder I dislike VB. Programming is heavily dependent on creating, understanding and using abstractions. After a few years of this, it's hardly surprising that VB sets off alarms in my head. On some subconscious level, my mind can see the leakiness of the VB abstraction, and it is an ugly leakiness. Far uglier than the C++ string class or the inconsistent query execution times of SQL.

Reading this essay has actually made me able to articulate something that I've been trying to say for a long time. It probably doesn't sound as clear as it is in my head, but that's the essential dilemma of communication, eh? Here goes...

Never completely trust abstractions. Not until you understand the stuff they abstract, and just how and where they leak. And even then, stay on your guard.

Saving the Net: How to Keep the Carriers from Flushing the Net Down the Tubes | Linux Journal

Saving the Net: How to Keep the Carriers from Flushing the Net Down the Tubes | Linux Journal

Definitely one of the finest and most insightful essays I have seen in a long time. Doc Searls does an incredible job of explaining just why network carriers and content industries cannot ever be allowed to control the Internet and its content. Secondly, his characterization of the entire debate as a battle of competing metaphors is so utterly penetrating that I've been left completely speechless. Simply brilliant.

Why is it that legislators always respond to things by adding more laws? Most of the problems with the world's legal systems stem from the fact that there are too many laws, not too few. Government power should always be painfully limited. History shows that eventually they just end up interfering with every aspect of our lives, when it is we who should be breathing down their necks, watching them like hawks, just waiting for an opportunity to toss them out of office. Kill corruption by making it so tremendously difficult that they die of heart attacks for fear of being discovered. Natural selection at its best.

Sadly, no such system has ever been put into practice as far as I know. If it ever is, I recommend basing it on the following principle - aside from the fundamental rights, no law should be valid for more than 10 years. After that, it should be unceremoniously thrown out unless someone can make a clear case for its continued existence at that point in time, at which point it should be rewritten before being passed again.

Why is this good? Because the sheer pain of having to redo the same stuff over and over again will force the lawmakers to pare the law books down to a very small core set of laws that can be effectively dealt with. Naturally, this would require a total revamping of the judicial and legal systems, so I don't foresee it happening in any currently existing society. Perhaps in a post-Singularity society, something like this might be implemented from the time of conception. It might just take posthuman minds to pull it off.

And while they're at it, they might consider simplifying the tax code...

Wednesday, November 16, 2005

Er...

Clogged sinuses. Very annoying.

(Blows nose loudly. No use. Still completely blocked.)

One of the downsides of being me is the useless sinuses you end up with. Once every few weeks, my nose decides to withdraw from full duty and proceeds to cut my air supply in half. Rather considerate, that - leaving me half a nostril free each time. Still bloody annoying.

Still, after 10 years, you get used to it. I've got to be the only guy alive who carries two handkerchiefs - one for the nose, and the other for the sweat that's inevitable in Mumbai's humid climate...

What you don't get used to is those cases that occur once in a blue moon, when your sinuses go AWOL, and your nose effectively retires into private life. On days like this(or nights, more often - for some reason it really comes into its own after dark) the only recourse is to walk around with a hanky, blowing your nose at regular intervals and hoping that it will fix itself. Nose drops help, but you tend to develop a dependence on those - natural resolution of the problem becomes next to impossible.

What bugs me is that I get very irritable when these cases occur. When you're making pathetic attempts to fix your nasal equipment, your Anti-Irritation ShieldTM has a little too much to deal with. It's amazing how much irritating stuff we put up with every day without a second thought. Far more amazing is how people you're very comfortable with - close friends, family - do and say irritating stuff all day long. We just don't notice. Man, can we adapt!

I've always been irritated by people showing pointless/unjustified irritation/anger. This weird response is amplified by the aforementioned state of irritability on my part. I have this urge to snap at people. Thankfully, my iron self-control usually wins out, and I remove myself from potentially annoying situations without killing anyone...The only person I end up snapping at is my sister, but since she snaps at me day and night, for no greater crime than my existence, I see no reason to miss getting in an occasional jab in this thoroughly one-sided contest. *Sigh*, sibling rivalry...

There's a subset of this 'Get annoyed/angry for stupid reasons' group that deserves special mention. These are the insensitive idiots who get annoyed when you're blowing your nose or trying to clear your throat(this is because throat congestion is almost inevitable in the bad cases). The worst of these go so far as to say: "Why don't you just do it once and for all?" in a very condescending voice, like someone who has been doing you a great favour by tolerating you all this time. For these guys, come the Revolution, I shall roast them over a slow fire and say "Why don't you just burn up all at once?"

Enough with that rant. Back to more mundane matters. Pause for a moment while I blow my nose to symbolically end this section of the post, full of venom, bitterness and mucus as it is...

Mom and sis are still in Lucknow at my cousin's wedding. Dad got back at the beginning of the week. Sis and Mom are due on the 18th or so, and then they'll be off again to the reception in Bangalore a couple of days later. This time I was planning to go along for about 5 days, but since I haven't been able to study much with all these grad school applications going out, I've decided to opt out and cram maniacally...Huge disappointment for a lot of people who were expecting to see me there. Huge disappointment for me - I actually enjoy these gatherings, crowded though they are...

Time now to try steam inhalation - maybe that will help unclog my sinuses. On the other hand, there's a small problem with that idea.

Yep. That's right. I can't inhale anymore.