On Sat, Oct 15, 2016 at 4:17 PM, Alex Suk <esh1...@gmail.com> wrote:
> Damjan Jovanovic wrote
> > But even at a rate of rewriting 1000 lines per day in Java, it would take
> > 10000 days, which is about 28 man years, to rewrite OpenOffice's 10
> > million
> > lines of code...
> I am no programmer but this is very interesting!
> Do 10M lines in C++ convert to 10M lines in Java? Is it a 1:1 conversion?
> Are there successful examples similar in magnitude to AOO in the software
> world of such code rewrites from language A to language B? How did they
> Is it possible to reduce the 10M lines for conversion by for example
> omitting Draw and Base from the suite?
> Can this conversion be performed in a modular way?
> Many thanks for answering.
Some language constructs only allow 1 expression. For example both C++ and
Java require 1 expression as the while loop condition. If the conversion
generated more expressions in Java than there were in C++, there would be
the serious issue of having to modify surrounding code to evaluate these
expressions, so their results can combine into 1 while loop condition
There are places where Java must use multiple expressions where C++ had 1,
for example because Java's bit shift operators on int only shift by the
lowest 5 bits, while C++'s shift by the entire value (it's "undefined
behaviour" to shift beyond the first operand size according to the
specification, but I follow actual GCC and Clang behaviour on amd64). So 1
<< 128 overflows to 0 in C++, but remains 1 in Java.
x << y in C++ would have to translate into this in Java:
(y & ~0x1f) == 0 ? (x << y) : 0
which can't be done like that, as y is evaluated twice, with potential side
effects: if the expression was 5 << i++, i would be incremented twice. We
thus have to make a copy of y and evaluate the copy. This would be an extra
statement that has to be added somewhere. So far I've dealt with that by
compiling such expressions into calls to helper methods like
Integers.shiftLeft(), which make copies of the parameters and operate on
those copies, thus keeping the conversion 1:1.
I am not sure what can be omitted. After all you can draw in a spreadsheet,
and you can import database data.
Yes, at least some of the conversion could be done module-at-a-time for
modules that are only accessed through UNO.