Originally posted by xenthorious
I was thinking, and here's my thoughts:
>C++ and Java can work on any system, but only java can execute on any system without changes.
>Why is C++ different, and how could we change C++ to be the same as Java without losing the performance difference?
>What is java known to be good for: Middleware.
>So if Java is good to be known for middleware, but middleware and the way Java works, degrades performance, how can we eliminate this?
Then this simple word came through my mind; Polymorphism.
How is this one method of programming so valuable in this circumstances?
Correct me if I'm wrong, but the biggest cause for why so many values in C++ need to be changed is because of how the program with associate with the operating system. So let's say, we made a Java program that operated as a System Ananlist, which evaluated everything on the operating system of which it felt the program would need. Let us say, it collected the information, and after feeling the program could run; passed the information to a C++ program which compiled the information to an understandable format for the program by working directly with the java program. The C++ program then instanciate the values from a script file of which that first C++ program generated. At this point, the Java program and the first C++ program would be shutting down. After the values were pulled, the program would then go online, and operate with the operating system directly based on the values it found on that script file. Java would ultimately be the responsable data member of which allowed C++ to work on any computer without the limitation of slow performance from how Java works.
In a nut shell, if Java would simple collect the information of the operatign system, and have the first C++ program compile it to a usable data, then final and main program could operate on any operating system because any value of difference between each and every operating system would be made the same.
Does this sound like a valid hypothephis?
@grug
Java is intended to be machine-independent, though. Whereas C/C++ that's left up to the programmer (in Java any problems are basically a maturation issue).
----
The pain-in-the-tits aspect of C, IIRc, is handling memory allocation, pointer, etc; at the same time, that's where you can finetune performance, which is why odds are a well-written C/c++ program will be faster than a well-written Java one.
The aspect of speeding up java on machines by compiling to assembly is a fairly simple one, albeit relying upon optimizing compilers. The main problem, IIRC, is that Java doesn't run in that way. It runs over 2 stages; java bytecode on JVM, and JVM on machine. If you switch to compiling directly to machine code, then you move back to the C++ model (so why abstract out any machine details?) -
but it means you have to compile on every machine.
That's a problem - one of the main advantages of Java is not only that a class file will run unaltered on multiple architectures, but that a distributed system can dynamically distribute and run those classes. for example, agent systems (mobile code that moves and executes between hosts). Or what I've been working no for the last 36 weeks, which will require (for lack of a better term, and to avoid giving patent info away) servers to be dynamically and rapidly relocated to new physical hosts.
In all those cases, requiring recompilation sacrifices (switch) performance, and also places external requirements upon the host environment. You go from 'write once, run anywhere', to 'write once, run anywhere which has the right stuff'.
Move to - concretely- supporting local compilation, and you risk sacrificing this ability. And you lose one of the reasons for selecting Java over, for example, C or C++.
Ultimately, if you want to maximise Java performance, what you need to do is optimize your bytecode, and hope Sun optimizes the arse off of the local JVM.....
NB: not really fair to compare C++/Java - both have different purposes, different stages of maturation and use. It's been
suggested to me (by professors nonetheless), that there's increasingly less benefit learning C++ as an adjunct to Java compared to C. In the business world, that may be true.