"C++ code runs faster than Java" is, to some extent, a hold-over from
the early days of Java, when JVMs where pure Bytecode interpreters.
These days, it gets compiled, and optimized, as it is running. The
optimizer has more data than a C++ optimizer, because it can see what
flows are being used in that workload on that day.
If I were writing a straightforward number-crunching program like a
linear equation solver I would probably write it in Fortran or C++, not
Java, but that is not the sort of program we are talking about here.
I am just getting started on AOO, and don't know the history of this
discussion, but here are some general advantages of Java:
* No pointer arithmetic. Java "references", which are either null or a
pointer to an object, are not subject to any direct arithmetic.
Everything done with them is checked to ensure they always point to an
object of appropriate class for the type of the pointer. If you see a
java.lang.String reference it is either null or points to a String object.
* Every array carries around with it its size information, and all array
accesses are checked to ensure they are accessing into the array, not
before it or after it. No buffer overflow.
* Automatic garbage collection. Memory management is just a matter of
making sure each component only keeps references to objects it is going
to need in the future. This is actually what switched me from C++ to
Java. I was working on performance models of large servers. I needed to
keep the object representing e.g. a cache miss around until both address
path and data path operations were complete, and either could finish
first. My C++ program worked, but I had put a lot of thought into memory
management. The next system I worked on I modeled in Java. I spent
practically no time and smartness cycles on memory management.
In general, my experience is that it is easier to get to a solidly
working program in Java than C++, easier to localize bugs, and easier to
make changes safely. That ease of programming translates into easier
changes in algorithms and data structures, and those are the changes
that bring the really big performance wins for more complicated programs.
If we were starting from scratch, with no existing code, and discussing
the choice of language for AOO I would be pushing extremely strongly for
Java. As it is, you have a valid point about the effort and time for
migration, which has to be traded off against the benefits.
Patricia
On 11/8/2015 5:19 AM, #PATHANGI JANARDHANAN JATINSHRAVAN# wrote:
Hi, I am pretty much a noob and have only started out contributing,
but may I ask why moving to Java from C++ is being considered? This
migration will take effort and time, and I was of the understanding
that C++ code runs faster than Java.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org