Tuesday, July 25, 2006

"What makes man a man?"

“What makes man a man? A friend of mine once wondered. Is it his origins? The way he comes to life? I don’t think so. It’s the choices he make. Not how he starts things but how he decides to end them.”
- From Hell Boy

Saturday, July 22, 2006

Nonsense on The Big Fight

This is about The big Fight program broadcasted today on NDTV 24x7. It was a discussion about "Internet: Is it dangerous, should it be regulated" etc.

It was full of nonsense. I wonder how literate were the people on stage about the Internet usage/technology to discuss about this topic. The focus was on a very narrow subject of what people write on blogs. Later, it diverted a little bit towards child pornography and safeguarding minors from predators on Internet. One of them kept on saying that there should be regulation at the ISPs level, they should monitor what is put on Internet and what is not and then filter them; they didn't do their job properly as required by the law.. etc. That is is so much of nonsense. ISPs deal at the level of IP protocol. On top of that there are so many protocol layers. Information can be communicated in many different ways. There is no way anyone can or should want to regulate, control the information flow. It is like saying I'm providing telephone connections to people, therefore I'm responsible for what people talk to each other over it.
They said Internet allows anyone to say whatever they want no matter how derogatory & false it is, anonymously and therefore it is not accountable. And they say that is the difference between a conventional medial like news paper and TV to Internet. I say, if something is said anonymously, then it has least credibily. People believe or accept what is said based on who said it.
Not everything that is said and shown on tv channel is also true. So much of it will be the opinion of people who come on talk shows. News itself is such an influence on people. For most of it tv channel will have a disclaimer saying it is the participents opinion and not that of the tv channel. It may be agued that all these influence people to become violent/terrorist. Does that mean the tv channel is a terrorism instigating channel? People are mis-informed and ill-informed many times everyday. If someone decides to change their lives just based on what they hear from others, then they are mostly weak minded. Internet is not the only medium that can influence such people that way.
When someone says something (on a talk show, in a blog, wherever) I decide to accept it or reject it based purely on its merits and that depends on who is saying it. To simply assume that anyone can make you believe anything is just naive.

There are bigger perils of Internet like aiding easy anonymous mass piracy of Intellectual property which is unique to this medium and very difficult in any other medium. They never even mention this topic in their discussion. Its real sad to see our news media getting diluted like this.

Wednesday, July 19, 2006

Blogspot blocked in India??

Since sometime yesterday, I'm not able to open any Blogger blogs from Airtel Broadband. Seems like they have blocked it. Here is my analysis as of now. (I'm able to open blogger.com. That's how I'm posting this.)

#dig vinay-ys.blogspot.com

; <<>> DiG 9.3.2 <<>> xxxyyyzzz.blogspot.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 816
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 4, ADDITIONAL: 0

;xxxyyyzzz.blogspot.com. IN A

xxxyyyzzz.blogspot.com. 344544 IN CNAME blogspot.blogger.com.
blogspot.blogger.com. 1703 IN A

blogger.com. 344614 IN NS ns4.google.com.
blogger.com. 344614 IN NS ns1.google.com.
blogger.com. 344614 IN NS ns2.google.com.
blogger.com. 344614 IN NS ns3.google.com.

;; Query time: 40 msec
;; SERVER: 125.xxx.yyy.zzz#53(125.xxx.yyy.zzz)
;; WHEN: Wed Jul 19 14:51:16 2006
;; MSG SIZE rcvd: 165

Then I do a tracert to that address.

#tracert blogspot.blogger.com

Tracing route to blogspot.blogger.com []
over a maximum of 30 hops:

1 46 ms 41 ms 43 ms dsl-KK-xxx.yyy.zzz.ccc.touchtelindia.net [xxx.yyy.zzz.ccc]
2 39 ms 38 ms 41 ms dsl-KK- []
3 38 ms 35 ms 36 ms
4 40 ms 39 ms 41 ms
5 reports: Destination host unreachable.

Trace complete.

Where as other traces complete just fine.
#tracert google.com

Tracing route to google.com []
over a maximum of 30 hops:

1 40 ms 37 ms 36 ms dsl-KK-xxx.yyy.zzz.ccc.touchtelindia.net [xxx.yyy.zzz.ccc]
2 38 ms 39 ms 38 ms dsl-KK- []
3 36 ms 32 ms 34 ms
4 40 ms 40 ms 44 ms
5 40 ms 41 ms 44 ms
6 284 ms 285 ms 291 ms
7 287 ms 288 ms 281 ms
8 271 ms 277 ms 272 ms
9 275 ms 264 ms 275 ms
10 300 ms 306 ms 302 ms
11 302 ms 301 ms 303 ms
12 303 ms 307 ms 307 ms
13 305 ms 313 ms 315 ms
14 306 ms 305 ms 303 ms

Trace complete.


Has anyone else seen this problem? on other service providers.?

Update: 21/07/2006
Seems like they have unblocked it now. It seems to be working.!!

Wednesday, July 05, 2006

"What's so pure about Pure Virtual Functions in C++?!"

I was asked this by someone.

Scene is somewhat like this. I'm explaining some class hierarchy and while doing so I explain
"....can be a abstract base class. It has virtual functions that define the interface and one of the functions as pure virtual. Even the pure virtual function can have implementation in the base class...."

At this point, the person listening to me shows surprise and asks, " Can a pure virtual function have implementation in the base class.. if so what is so pure about it??! ". And then, goes on and says, " no you are wrong, it can't have implementation".

Later, I checked Lippman et.al., which is the book from which I learnt C++ initially, and there is very little about pure virtual functions(p 926 - 927). There is nothing about providing a implementation to a pure virtual function. Infact he only says,
"..The language provides us with a syntactic construct by which to signify that a virtual function is providing a interface for subsequent subtypes to override but not itself be invoked through virtual mechanism: a pure virtual function. ..."

Then he explains further to say that a object of such a class can't be created('cuz you would end up invoking that function directly from that object).

The things that got missed out of this explanation and many people don't know is this:
even though you are restricted from invoking a pure virtual function from an object of that class, and hence, you are restricted from creating an object of that class, you can invoke a pure virtual function from within; ie., from its constructor, destructor, or any other function and from functions within the derived types!! Now, armed with this knowledge, think about the original question. Does the body for a pure virtual function make sense? Answer is yes, depends!.

To dwell deeper, here is a piece of code.

// Filename PureVirtualDemo.cpp
// Demo code to demostrate pure virtual functions having definition.

// A typical use for this feature would be to provide default implementation or
// the common part that will be used by all concrete instances

#include <iostream>
using namespace std;

class AbstractType
virtual void test() = 0;

void AbstractType::test()
// Put the {common stuff}/{minimal thing} here.

// This may be doing the minimal thing or it may
// be doing the common stuff. Depends.
cout << " Inside AbstractType::test() " << endl;

class ConcreteType : public AbstractType
void test()
cout << " Inside ConcreteType::test() " << endl;
// Call the common part
// Now do the specific stuff if you have any.
// Or if its the minimal thing that you have, you are done.

int main()
AbstractType *obj = new ConcreteType;
return 0;
Output after compiling in g++ and running on a GNU/Linux machine.

[vinay@technicolor_sounds ~]$ g++ PureVirtualDemo.cpp -o pvd
[vinay@technicolor_sounds ~]$ ./pvd
Inside ConcreteType::test()
Inside AbstractType::test()

// vim: ts=4:sw=4:expandtab:ai:cindent

So, this code clearly proves the point. And sometimes, pure virtual
functions can get called accidentally from within the object and it becomes a very hard bug to find. So, even if you don't have requirements as described above, its best to provide body for pure virtual functions with proper comments and doing an assert(false) inside it would gets the debugger's attention in such case.

Hope you have enjoyed this piece!:-)