> In an interview a candidate was asked the question "Why We dont Have pointers in JAVA?", to which he replied like this:
>
>
>
> " I married a widow who had a grown-up daughter. My father, who visited us quite often, fell in love with my step daughter and married
> her. Hence, my father became my son-in-law, and my step-daughter became my mother. Some months later, my wife gave birth to a son, who
> became the brother in law of my father as well as my uncle. "
>
> " The wife of my father, that is my step daughter, also had a son. Thereby, i got a brother and at the same time a grandson. My wife is
> my grandmother, since she is my mother's mother. Hence, i am my wife's husband and at the same time her step-grandson; in other words, i am
> my own grandfather. "
>
> " I guess that's why we don't have pointer in Java..."
>
>
Well. In java you can still be your own grandson. Nothing stops you.
There's only one thing that happens in Java that doesn't happen in C,
C++. You are allowed to produce as many children as you want. And beyond
a point when they are useless to you, you may well throw them out of
your house. Some strange unknown being called the 'Garbage Collector'
takes them to some lonely place, and buries them, and they will never
come back to you many years later claiming to be your offspring.
So, that's indeed something great about Java: you create all the mess
you want to create, and forget about them when you are done. Someone
else takes care of that. That's Java!
Bye,
Sujit
The definite strength of C (and probably the terrifying this as well)
is its pointer functionality. To imagine that a language of this sort
existed even about 30 years back is indeed remarkable. And not much
about C has changed.
The only problem with using pointers in C is that one has to remember
to clear them up once they have been used. Not doing so can turn out to
be a nightmare. Worse, if you have problems with your code where you
have used pointers extensively and not got it working.
But having said all this, its ideal to use a language like C to handle
huge amounts of data. given the speed of operation, I cannot imagine
JAVA finishing the processing in twice the time. when I was
interviewing with a company, I told them outright that I despised
programming in JAVA. I must have learned prior to going in there that
all their work was in JAVA. Its only obvious that I didnt get that job.
Vinod, dont fret. They arent very difficult. Just nee! d to know the
right means of handling them. Dont give up!!
A
SUJIT WROTE:
Abhinandan, I would say, you mustn't think badly of Java as bad because it
doesn't have pointers. If you remember your lessons of programming
languages, even functional and logic programming languages (ML, lisp...)
have there automatic garbage collection. Java is an excellent language.
It's clean, having a stricter type system, and a near complete library.
The fact that it runs slower definitely can't be used against it for long.
It scores over C++ in most points, not just from the point of view of the
programmer, but even a programming language designer.
The 'only problem' that you have pointed out about C (or C++) is a very
big problem indeed! :)
But, I also confess that I am still a C++ buff. But my reason doesn't have
any rational basis. Apart from operator overloading and templates, I like
it because C++ makes it more difficult for me by not cleaning the garbage
I create. I have been continuously trying to find out patterns in coding
that would prevent me from not cleaning up my garbage allocations, or
would save me from dereferencing a null-pointer. I (like many others) have
met with only a partial success. And it can't be denied that my ways won't
scale to the kind of environments in which softwares are written: millions
of lines of code, written by unknown predecessors, to fixed and delivered
before the next Monday. I have painfully learned to accept that beyond a
point, human brains can't handle all this. I accept that come a difficult
enough situation I will quickly ditch my geeky ego and will switch to
something that makes my job manageable. Even if it's Java. :)
Vinod Kumar B G wrote: