Thursday, December 29, 2005

From CLX to VCL

Back in 2002, when the project was being designed, it was meant to be cross-platform (well, at least Windows and Linux on i386). The choice was Delphi/Kylix; instead of VCL, we used CLX from day one. This was bad - because Kylix is dead by now - but also good, because we were forced to code in a cleaner way - no Windows API calls, very few third-party components, etc.

Coding for both Delphi and Kylix was an {$IFDEF} nightmare. Most coding was being done in Delphi, under Windows, and everytime we fired up Kylix to compile a Linux version, a lot of changes were needed. Then, early this year, some customers started to try the win32 program under Wine, getting very good results. With little effort we made it work 100% under Wine, and it became clear that it was easier to run the application under Wine than code for Kylix.

The CLX is very buggy (and slow); a couple months ago we started to port to VCL. We also evaluated the possibility of porting directly from CLX to Lazarus, but our studies have shown it would be a huge step. So we decided to port to VCL first. A tool was used for this task: Convert Files, by Dennys dos Santos Sobrinho. As expected, the conversion did not worked in the first try; a lot of changes were needed and we could not afford to mantain a branch just for this task. So we decided to gradually reduce the gap, by removing obstacles at each official release.

It was a major refactoring task - a lot of code was rewritten, third-party components were replaced with standard ones (new code was needed to accomplish the missing features), points of conflict of method signatures between CLX and VCL were concentrated in fewer places, xpm icons were replaced by bmp, png or ico files, etc. Every week we tried the conversion process with the current codebase; the gap was becoming small.

And today, at last, we managed to get a working VCL port! It's a lot faster (at least 3 x), a lot of CLX bugs are gone (mouse scroll works now, form focus is not crazy anymore, etc) and with XP Manifest the project got a nicer look under Windows. Of course the entire project needs some revision to fix minor visual glitches, but overall it's working. We plan to issue an official VCL release in a couple weeks.

No comments: