XPlatform Object Pascal
I’ve followed FreePascal for some time now. FreePascal has always been interesting in that their compiler architecture has supported multiple CPU targets for a long time, yet only now is Embarcadero working on such support. Unfortunately, it looks like Embarcadero is writing their own from scratch rather than leveraging FPC, so a free, open source, and fully compatible compiler is not going to be available any time soon.
FPC supports multiple compatibility modes, and fpc libraries use similar if not the same names as library units from Delphi. You would think porting a Delphi application to use FPC in order to get 64 bit Windows support or porting an application to Mac OS/X or Linux would be trivial.
The sad truth of the matter is that the moment if you want to port a Delphi app from Windows to a different OS you have to deal with UI toolkit differences and even on Windows porting to FPC can be a challenge because of the limited UI components and compiler compatibility. That’s slowly changing with visual component frameworks like fpGUI, wxForms, and VGScene (assuming you used their framework to begin with). Other components are being supplemented by a growing community via the Lazarus CCR, and vendors like REMObjects, and BRAIN PATCHWORK DX, LLC (the maker of DXSocks). Lots of open source projects also support FPC, and the number seems to be growing. If you’ve ever questioned the need for a cross platform Object Pascal compiler I think the community has already given it’s answer.
Tonight I tried to compile hcOPF using the latest version of FPC (2.4) on Mac OS/X. I used the instructions on Donald Shimoda’s blog and it was absolutely painless. I installed the Lazarus package for Mac OS/X and fired it up.
Initially I had some problems in my hcOPF port, figuring out why FPC couldn’t find my include files. When I found out where to plug in the include file path, I thought I was off to the races until I got a “Could not find identifier TDate” error message. It appears that on Mac OS/X FPC has a Controls unit, and so does Lazarus, but the FPC Unit is first in the path. Once I got past that error, I discovered that the DBConsts unit in Delphi is named DBConst in FPC and it’s missing a number of resource strings. After adding a whole bunch of IFDEFs, I hit a show stopper. FPC doesn’t support the implements feature of the Delphi compiler to delegate the implementation of an interface to another object. I use this in ThcObject to implement the IObserver interface. This is a well known problem as documented here. Unfortunately until this issue is solved, some of the best libraries will not be available to FPC developers. I mean of course, the JVCL ;>)