harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitry Serebrennikov <dmitr...@earthlink.net>
Subject Re: I hope the JVM implements most using Java itself
Date Fri, 13 May 2005 04:50:11 GMT
I've been trying to process the idea of building java vm in java and 
with the comments on this and other threads it is starting to make 
sense, but I have a couple of specific question below. I would 
appreciate if someone could put in a few words of explanation, perhaps 
it will help others as well. Here goes...

I can see the argument for the code generator written in Java - it still 
produces the same machine code, so the fact that it is written in Java 
does not matter.

I can also see the argument that it is algorithms that matter, not the 
language in which they are written. At least that algorithms matter more.

Ok, but here are the questions.
First one is of the chicken-vs-egg variety -- as the GC algorithm 
written in Java executes, won't it generate garbage of its own, and 
won't it then need to be stopped and the tiny little "real" garbage 
collector run to clean up after it? I can only see two alternatives -- 
either it is going to cleanup its own garbage, which would be truly 
fantastacal... Or it will somehow not generate any garbage, which I 
think is not realistic for a Java program...

This brings me to the second question. In my experience, writing in Java 
and writing in C (and therefore thinking in Java and thinking in C) 
tends to produce very different programs. The languages just lead you in 
different directions. "Language shapes thought," you know. So, although 
one can argue that a Java program will ultimately be JITed (or WATed or 
whatever) to machine code, the program itself will not be written in the 
same way as a C program would be. Again, this is subjective and I expect 
people will not always agree with this. But I find that when I write C 
code, I'm thinking of CPU efficiency, changing strings in-place, and 
using pointers. Maybe *because* C is so painful, I tend to think of the 
simplest, most direct way to accomplish what is needed.
However, when writing Java, I find that I think more of correct object 
abstraction for the problem at hand, code reuse, classes that maintain 
consistent state. I don't think twice of using a HashMap if it happens 
to be convinient, or that inheritance will cause extra indirections at 
To summarize (and to get to the question already) - the point is that 
language shapes thought. In other words, a program designed in Java will 
naturally tend to be slower then a program designed in C, simply because 
Java most naturally expresses slower designs then C does. And the 
question is - does this agree with anyone elses experiences? And if it 
does, is it a valid argument against using Java for the design and 
implementation of the VM?


View raw message