On Thursday, 15 December 2011 at 20:42:26 UTC, Jacob Carlborg
wrote:
On 2011-12-15 20:41, Walter Bright wrote:
On 12/15/2011 9:49 AM, Robert Clipsham wrote:
* Do it all in one go, and DO NOT GET DISTRACTED. The moment
you start
trying to
clean up code as well as finish porting it you introduce lots
of issues
I've done many projects that translated code from one language
to
another, some were pretty large. The One Big Most Important
Rule is:
!!!! DO NOT REFACTOR/ENHANCE/IMPROVE/FIX/CLEANUP THE CODE WHILE
TRANSLATING !!!!
I know how tempting it is. It's incredibly tempting. It's a
huge mistake.
The method that works is to turn your brain off, and simply
translate.
Strive for a 1:1 correspondence between the original code and
the
translated code. Do not divert from this until after your
translation is
done, and it behaves identically to the original.
The reason is that the translated version inevitably will not
behave
like the original. A lot of things will be broken. If you did
a 1:1
translation, you can instrument both, find where the
translation
diverges, and fix it in a fairly quick and straightforward
manner. If
you changed the way it is organized or works, then you have no
idea if
it is a translation error or your changes broke it, and you
have a much,
much harder time fixing it.
Having ported the Mac OS X version of SWT from Java to D (and a
couple of other code bases) I completely agree with everything
above. You just have to turn your mind off and work like a
machine when porting. It's extremely tempting do some small
fixes here and there but restrain yourself, you'll thank
yourself in the end.
Thanks for the tips!
Cheers, Jakob.