Bits of Learning

Learning sometimes happens in big jumps, but mostly in little tiny steps. I share my baby steps of learning here, mostly on topics around programming, programming languages, software engineering, and computing in general. But occasionally, even on other disciplines of engineering or even science. I mostly learn through examples and doing. And this place is a logbook of my experiences in learning something. You may find several things interesting here: little cute snippets of (hopefully useful) code, a bit of backing theory, and a lot of gyan on how learning can be so much fun.

Tuesday, February 07, 2006

JAVA ho java, aur vapas mat aava

Vinod Kumar B G wrote:
> 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:
>> First of all I am very happy that SujjuD included me in the
>> conversation. To be frank I can only write simple programs which solves
>> certain family of PDE's. In fact that is purely the application part.
>> But I dont know how to make my program efficient(so that it wont make
>> unwanted calculations, eat up too much of RAM space...such kind of
>> stuffs)...I think knowing how a program works may help me to a wide
>> extent. So I request Sujit Da to give me some Fundaa.. I am ready to
>> come to Ur room whenever U R free. U can give me some assignments as
>> well so that I can get a clear insight of the subject.
>>
>> Please consider this as an official request letter...
>>
>> Thank U...

Sujit wrote:
Hello Vinod Bhaiyya. I am full of gratitude for your interest. As I said,
> I know little, and all that is at your service. Let me give you my first
> funda here itself: Writing good programs goes much much beyond writing
> fast and efficient programs. Speed and memory requirements will always
> remain important requirements, but they are not the most important ones
> for the programmers these days. For example, had resource consumption
> (compute time and memory) been the only criteria for writing good
> programs, then our discussion about Java that started yesterday wouldn't
> have arisen. Java doesn't come anywhere close to the speed of C and C++.
> But Java survives because of many of its other advantages.
>
> If you think you want to be a good programmer (even if for your research
> purpose), try this acid test. Write a program of a slightly bigger size
> than the most trivial. Say about 300-400 lines. Let it be for anything.
> After you get it working, forget about it for sometime. Say for 2 weeks.
> Then come back to it, and try making some non-trivial enhancements in the
> code. See how much time it takes you to do that. If you find it easy, most
> probably the program you wrote two weeks ago was a well-written program.
> If you waste hours of your time trying to figure out the meaning of some
> very clever piece of very cryptic code, then the program is most probably
> not a well-written one. Moreover, that clever piece of code that might
> have saved you a couple of seconds or minutes of time could well become a
> reason for your wasting hours of your time now. That's definitely not a
> happy deal. Isn't it?!
>
> Good programming is not about writing fast, smart and cryptic code; it's
> about writing simple, clean code that can be easily used and modified
> weeks, months or years after they had been written, perhaps by someone
> else.
>
> Yup. Sujit


ut my
major grudges against Java have been the following:

1) Variable names as long as can be - Whew.........
I USE VARIABLE-NAME AS BIG IN C++ AND EVEN PERL! :) I LIKE BEING OBNOXIOUS TO GEEKS AND PLEASANT TO HUMAN PROGRAMMERS! ;) (A program of mine attached. Pure C; Java like names!)

2) A lousy naming system for the file system - making directories with a certain package name and stuff.
THERE SOMEHOW I CAN'T DIFFER FROM YOU.

3) My life undergoes irrepairable damage the moment I start programming in JAVA.
HM.


But yeah, I perfectly accept your points about the advantages of Java. I am told that .NET is an excellent alternative to JAVA. I am an expert in neither to comment on that. Sujit, I also endorse your opinion that this could be moved into a private chat room. I am most willing to learn about the negatives of C!!
WELL! C RULES! That's the bottomline. :D

Emtiyaz wrote...

That's why the name JAVA ho java, aur vapas mat aava... :)
emt

No comments: