First, A bit of history…
Pascal was invented as a teaching language, and had several academic implementations. It was later implemented on PCs, including the early Macintosh, Atari ST, etc. Where it really took off, though, was on the PC, where Borland’s Turbo Pascal became a huge hit. After Windows became popular, Borland ported Turbo Pascal to Windows, added database connectivity, and created a GUI designer system. This entire system is known as “Delphi”. Although Delphi has changed owners several times over the last decade, it is still marketed under the same name today. Delphi was also produced for Linux, marketed under the name Kylix. Since Kylix was abandoned after the 3rd release, we won’t go into it here. There is another competing Delphi-like system, known as Sibyl, however the focus of that project is support of the OS/2 operating system, so we won’t cover it in detail here. For most people, their realistic options will boil down to Delphi and Lazarus.
Reasons for Choosing Lazarus
Many programmers started out on Delphi, and want migrate to a newer version, but aren’t sure of the value proposition of paying the license fee to upgrade to the latest version of Delphi. For others, they started out on Windows, but want to migrate to Linux of Mac OS. FreePascal and Lazarus can enable a number of scenarios that aren’t possible with Delphi, but there are some differences. Finally, some programmers may be migrating from a legacy system, such as Turbo Pascal, Virtual Pascal, an older version of Delphi or Kylix, etc., and want to know where the best place to spend their effort will be.
Advantages of FreePascal/Lazarus Vs. Delphi/Kylix
1. The compiler is written in FreePascal, making it easier to modify if needed.
2. The compiler and IDE source code is available, making it possible to modify.
3. There are no artificial restrictions, or “editions”.
4. FreePascal currently has support for Windows, Mac OS, and other Unix systems (f.e. Linux, BSD, etc.)
5. Unlike Kylix it is not necessary to deploy QT DLLs/Shared Libraries
6. FreePascal can cross-compile to ARM (and other embedded processors) to write code for Smart Phones, etc.
7. FreePascal still supports targets such as PC-DOS and OS/2, which is useful for targeting some devices such as certain cash registers, etc.
8. FreePascal supports ObjectivePascal, an object oriented model which is compatible with ObjectiveC, making development of native Mac OS X and iOS software easier.
9. Since FPC and Lazarus are open source software, the long term viability of both projects is ensured.
Advantages of Delphi Vs. FreePascal
1. Commercial support is available from the vendor
2. Compatible with more 3rd party components and libraries (Applies mainly to visual components)
3. Complementary related .NET and C++ packages are offered by the same vendor.
4. More polished and full-featured GUI for native Windows applications
Further Points & Compatibility Notes
At the end of the day, it’s actually easy to maintain source code which compiles in both Delphi and FreePascal. Both compilers support ObjectPascal, so normal code will work in both. Further, compatibility is continuously improving. While the visual component libraries on both are similar, they are not identical, meaning that GUI code should be kept to a minimum and produced separately for Delphi and Lazarus. (Lazarus has the ability to import Delphi forms, but this is a one-way compatibility).
In general, FPC is more advanced, supporting many features that Delphi does not, such as C style syntax, ObjectivePascal, etc. Due to these differences, code is more likely to be compatible is written in Delphi and ported to FPC than code written in FPC and ported to Delphi.
VCL vs. LCL
The Delphi GUI component library is called VCL (Visual Component Library), and was originally designed as an encapsulation of the the native Windows 32bit API. Kylix uses CLX (Also supported by some Delphi releases), which is an encapsulation of the QT framework. Lazarus uses LCL (Lazarus Class Library), which is very similar to VCL, yes was designed to be more generic and cross-platform from the beginning, and thus has some important differences. The LCL itself supports several GUI “Widget Sets”, including native Windows GUI functionality, Mac OS Carbon (With Cocoa in progress), QT, GTK, and more.
Support and Migration Strategies:
1. Many companies who need to support both Windows and DOS try to keep their code compatible with turbo Pascal 7 and Delphi. Since Turbo Pascal 7 is no longer evolving, this becomes very painful, as newer language elements may not be used in any code which must compile in TP7. By switching to FPC, compatibility can be increased.
2. If you want to use Delphi on Windows and Lazarus on other platforms, (Or leave the possibility open for easier migration later) make sure to factor out as much code as possible into units which are not related to the forms. That is, separate the GUI part of the application from the non-GUI portion. This is good design in general, but unfortunately not always followed by Windows programmers. Furthermore, don’t use hidden GUI components for non-GUI related processing.
3. If you want to prepare for migration of a graphical Delphi app to Lazarus, evaluate how many custom controls are used in your application, and whether they can be converted to standard controls without a major loss of functionality. Also check whether those components may have been ported to Lazarus already.
4. If you don’t need any features which are only available in Delphi, consider migrating your program to Lazarus entirely. This will allow you to maintain only one set of forms, instead of two.