This page is designed to provide background information for people who want to publish Free Pascal related news. It can be used freely for any use; no copyrights will be claimed.
- 1 What is Free Pascal
- 2 The Pascal language
- 3 Architecture
- 4 Optimization power
- 5 Internal assembler and linker
- 6 Why Free Pascal is important
- 7 What about other Pascal compilers
What is Free Pascal
Free Pascal is an open source Pascal compiler. Work started in 1993 by Florian Klämpfl. Since 1993 Free Pascal has evolved into an advanced piece of technology. Nowadays it is widely considered one of the best Pascal compilers ever written.
Free Pascal is not just a compiler. The Free Pascal development team writes and maintains:
- The compiler
- A runtime library for many operating systems
- Many software libraries
- Interfaces to many software libraries written in C
- An integrated development environment
- A set of manuals
What is Lazarus
Lazarus is a sister project of Free Pascal. Its aim is to provide an integrated graphical development environment for designing applications. It specializes in creating modern GUI applications at great ease.
The Lazarus team designs and maintains:
- The Lazarus development environment
- The Lazarus component library of GUI widgets (called the LCL)
Platforms and architectures
Free Pascal is available for the following platforms:
- 32-bit Dos (GO32V2 dos extender)
- Windows Win32
- Windows Win64
- Windows CE
- Game Boy Advance
- MacOS Classic
- MacOS X
- Nintendo DS
- Novell Netware
Free Pascal has also supported the following platforms in the past:
Additionally people are constantly doing experiments with new platforms. It is likely we will be able to provide support for the Gameboy Advance platform soon.
Free Pascal programs can usually be recompiled for different platforms without large code changes. Portability is heavily dependent on the used code architecture; however, the Free Pascal runtime library bridges the gap between Unix (Posix) derived platforms and Dos derived platforms quite well.
Lazarus is available for Linux, Microsoft Windows, and MacOS X. The aim is to make programs useable on all three platforms without code changes.
Compiler source code sizes:
- Compiler: 11,3 MB
- Runtime Library: 16,5 MB
- Integrated Development Environment: 2,0 MB
- Free Component Library: 6,0 MB
- Test suite: 12,8 MB
- Packages (Pascal libraries and interfaces to C libraries): 34,0 MB
- Documentation: 13,3 MB
Amount of users: estimated between 20000 and 30000
- ftp.freepascal.org: 400-500GB/month, +/- 50000 files/month
- Sourceforge: +/- 300GB/month, +/- 20000 files/month
- Mirrors unknown
Free Pascal is flexible, it is useable for a wide range of projects. Examples include:
- Development of GUI applications
- Development of operating systems
- Development of computer games
- Development of command line tools
- Development of database applications
Free Pascal also continues the tradition of being a good tool for newcomers to programming.
Since the original Pascal from 1970, many compilers have extended the Pascal language. This evolved into two major groups of compilers: Those that implement the ISO Pascal dialect and those that implement the USCD-Pascal dialect. Free Pascal is a compiler from the UCSD dialect group. It has native modes which are mostly compatible with Turbo Pascal and Delphi, and special compatibility modes that are intended to be 100% compatible with Turbo Pascal/Delphi or Mac Pascal (the Pascal dialects used on Apple platforms). Free Pascal does not implement ISO Extended Pascal.
The Pascal language
The Pascal language has a rich history. It was designed in 1970 by Niklaus Wirth and introduced the concept of structural programming. This concept has revolutionized programming, and the ideas behind it in turn inspired many other programming languages.
Pascal is a language that has evolved a lot throughout the years. One of the revolutions inspired by Pascal was byte code, first pioneered in the USCD P-system, today the basis of Java and .NET.
Turbo Pascal introduced another paradigm shift, the Integrated Development Environment. Programs could now be written quicker than ever. Turbo Pascal introduced many enhancement to the Pascal language, including object oriented programming.
While innovations in its successor, Delphi, were not entirely new to the world, Delphi is regarded as one of the best development environments in existence. Delphi enhanced the language too and prepared it for the next decades.
While Pascal has evolved a lot, it has unmistakenly remained itself and remained close to the original spirit.
The Free Pascal project is dedicated to promote the use of the Pascal language. We are also dedicated to free software. The Free Pascal development team wants to provide the tools that make Pascal an as realistic option as other mainstream languages and believes the use of the Pascal language leads to better software.
Pascal is a language designed to be easily readable and has succeeded remarkable well. Most programmers unfamiliar to it can read Pascal code.
The language uses strong typing, which allows increased compile time possibilities for verification of code.
Low level types are available, such as byte, char, word, integer, as well as structured types like arrays and records. Dynamic structures can be implemented using pointers.
High level types that are available are strings, sets, objects & classes. Unique object oriented programming features are properties, dynamic constructors and interfaces.
Code is modularized into units, which offer a clear separation between interface and implementation. Units need to be loaded when used, it is not necessary to parse their interface or something. Dependencies between units can be figured out by the compiler, eliminating the need for the "make" tool.
Other features are easy integration with assembler code, exception handling, thread variables, nested procedures.
Pascal programs have direct access to external libraries. No wrappers around external libraries are necessary, an import unit is used to couple the assembler symbols in the external library to Pascal identifiers. Types and constants for use with the library are defined in such units as well.
Pascal and the programming language universum of today
The programming language spectrum has changed over the years. There are many languages the have come and gone, while others have remained remarkably durable.
There are several reasons why Pascal is still around 35 years after its birth. First, Pascal has adapted very well to new developments. Over the years the language has been extended a lot, and in many cases extended well; Pascal does not feel a crippled language because of its age. These extensions was often done so well that Pascal has beaten "successors" to itself, for example Modula-2. The improvements that these languages provided could be implemented in Pascal as well, which had better tools and provided backward compatibility.
Compatibility is certainly an important reason why Pascal is still around to day. A language vendor that destroys backward compatibility effectively kills all previous investments in software written in that language. This makes people wonder, if they should invest either in the latest hype, or a more stable language.
Scripting languages verses compiled languages
Scripting languages receive a great amount of attention today. Scripting languages are often special purpose languages specially designed for certain tasks and provide unmatched productivity for those tasks. Efficiency is often rather as low, as memory consumption is high.
Scripting languages have augmented the tools programmers have at their disposal. It is to be expected that scripting languages will remain to be very popular, while not undermining compiled languages.
Compiled languages will not undermine scripting languages as well. However, Pascal is a traditional compiled language, but is not as bare to the metal as C is; it is possible to program at a higher abstraction level. Because of this, it can be usefull in situations where scripting languages are tradionally used, but do not perform enough. A good example is web programming, for which Pascal based solutions start to appear.
Managed languages versus unmanaged languages
Pascal is a tradional compiled language. A lot of hype lately is centered around managed languages, especially Java and .NET. This is partially caused by breakthroughs in the efficiency of those languages, and partially because .NET is supposed to be the next big thing in Windows programming. While it is possible to change Pascal to become a managed language, Free Pascal has chosen to remain a traditional compiled language.
Managed languages have their use. By means of byte code, programs written with them can be easily run on multiple processor architectures. Automatic memory management should prevent people from ever having to think about memory references again.
The Free Pascal development team is sceptical regarding this hype. We are certain that there will be a role for those languages, but they will not threaten the existance of traditional languages. It should be noted that Pascal has pioneered byte code, but it did not turn out to be a success.
The limitations of managed languages lie in both portability and efficiency limitations. Byte code languages are supposed to be very portable, but they depend on a runtime environment to provide functionality. This runtime environment provides the least common denominator of functionality and often provides it by means of emulation. This puts constraints on available features, and thus limits progress, while emulation provides non-native behaviour.
Efficiency limitations can be found in huge, bloated runtime environments and memory management issues. While automatic memory management removes a burden for the programmer, users are often not pleased to see eating simple programs hundreds of megabytes of memory and don't like sluggish software.
It should be pointed out that Free Pascal already offers many of the features promised by managed languages, such as increased security, full portability between Windows and Linux, and easier, safer, programming.
Native applications can provide very tiny tools with very low memory usage. Taking advantage of the platform is easier, because the functionality is already provided.
It has during the last years become clear that native languages will remain the most dominant in programming. Unlike originally promised, the big .NET Windows release, Windows Vista, hardly uses any .NET code. The Win64 API will be the next big thing in Windows programming, which Free Pascal supports.
The reason why Free Pascal will not support .NET at all is that it would require invasive changes without backwards compatibility, and a complete new set of libraries. No current code in such an environment exists, and it is highly doubtfull if people will be educated to write code for such an environment.
Which leaves us with C as Pascal's biggest competitor.
The C language has been Pascal's biggest competitor ever since the beginning. Both languages were developed at the same time, offer a very similar programming model, but differ greatly in philosophy.
In the 90's C became more dominant than it ever was. The reason was a lack of good Pascal tools; Turbo Pascal, a 16 bit compiler has been discontinued and Delphi was not a universal replacement tool. Today, in the Windows world Pascal still has a healthy market share. In the 90's Pascal vanished from game development (because there was no 32 bit Dos compiler), and later, on Linux, it couldn't compete with C due to lack of good tools. Free Pascal, then heavily in construction, wasn't able to compete seriously either.
Pascal is nowadays more competitive against C than ever, it provides a reasonably safe language at comparable performance, better productivity and is nowadays backed by an advanced open source compiler tool.
Free Pascal has been written in Pascal itself. It can recompile itself and does so to port itself to new platforms. The lack of dependency on external tools ensures high portability, one only needs to port Free Pascal itself to port it and not rewrite handling of external interfaces or tools.
It also ensures reliability of the compiler, any bug that will hurt stability will be noticed immedeately by compiler developers. One can write millions of lines of code without fear of being plagued by compiler failures or limitations.
Scanner & parser
Free Pascal uses a handcrafted scanner with built-in preprocessor that converts Pascal source code into tokens. While implemented with OOP, it is mostly procedural. The parser is also hand crafted. The parser receives the stream of tokens from the scanner and creates tree nodes, while interacting with the symbol table. The parser works fully procedural.
Tree node system
The heart of Free Pascal is an innovative object oriented code generation design. Every feature of the Pascal language, i.e. add, array subscript, pointer dereference, gets converted into a tree node. This is done like in a traditional compiler.
These tree nodes are, however, classes that can be overrided. The front-end generator overrides all of these nodes and implements code generation procedures by making calls to primitives in the back end code generator while working with the processor independend register allocator.
It is possible to implement a code generator by implementing the back end code generator. This makes Free Pascal highly portable. One can, however, also override parts of the front-end code generator, to take advantage of information at a higher level to generate optimized code for a certain processor. This functionality is highly usefull to take advantage of processor specific features like i386 addressing modes, MMX, or shifterop on the ARM processor.
Generated assembler code is processed by the assembler optimizer. This one performs peephole optimizations, cpu model tuning, common subexpression elimination and dataflow analysis at assembler level.
Free Pascal generates very competitive code, and can win in a few cases against the GCC compiler engine. In general we can say though, that GCC still has more optimization powers. This is for i386 only. For some platforms, Free Pascal generates faster code than GCC. Over the years, Free Pascal has catched up, and it is certain that it will catch up even more.
FPC can use the GNU assembler and linker, allowing the compiler to be easily ported to many platforms but also has a built-in assembler and linker. Neither the GNU-assembler or linker have been designed for the load FPC pushes on them. This means that in some situations, like smartlinking, the compile speeds aren't optimal or memory usage is excessive. The built-in assembler and linker have been designed to address this, they allow faster compile times, better size optimizations. Furthermore, they allow ports to platforms not supported by the GNU assembler and linker. For example, the Win64 port was started long before the GNU binutils supported it, therefore, Free Pascal was the first open source compiler to support this platform.
Why Free Pascal is important
Free Pascal is, to our knowledge, the most advanced open source compiler engine besides the GCC compiler. It can generate speed competitive code, but also implements high level functionality, and extreme compatibility to language dialects.
The compiler's innovative code generator design makes the compiler itself highly portable, but also the design of the libraries promotes portable software. This allows availability of software for many platforms at low effort. Due to low portability efforts, small operating systems can quickly have the entire compiler toolset available.
Free Pascal is also very developer friendly. It compiles fast, many times faster than GCC, and provides clear, helpful error messages. It should also be noted that many programmers will greatly appreciate the extensive documentation. There are also extensive support options for people who are stuck.
The real reason why Free Pascal is important though, is that it solves some of the issues the free software community is currently coping with. There is demand for languages and development environments that make people more productive than in C. Many languages promise this, but at a cost for the user of those programs: performance.
Pascal programs are experienced to be fast. They start very quickly (yes, even faster than C programs). They react quickly to user input, and provide good throughput of actual work. Try it: Checkbook Tracker and Pixel32 are good examples, and feel the responsiveness.
Lazarus is the most serious free software attempt at providing a full graphical development environment. There are many open source tools and libraries to build GUIs on open source (and proprietary) operating systems, but few do a combination of a full graphical design, full customizability of the actual GUI, full control to the programmer, and all tools you expect in a normal IDE. Add to that the powerful language it is based on and the result is that quality applications can, and are, produced. As a bonus, programs written in Lazarus run on Linux, Windows and MacOS with very little effort.
The result is both very good productivity for the programmer and quality software for the user.
Furthermore, Lazarus is the only toolkit that can generate native look and feel for all platforms. Competing tools sometimes emulate native look and feel. Lazarus, in contrast, uses the actual native GTK1/GTK2/QT/Win32/WinCE/Carbon GUI element, which guarantees the look and feel is close to as native as possible. This is done with a single source code, all that is needed to switch an application to a different graphical toolkit, is just a recompile!
The combination of a language and compiler that is fully comparable to the traditional C development, with the comfort of a safer, more powerfull language, and development tools that are designed and optimized to build desktop applications can be a very good solution to base an open source desktop on.
What about other Pascal compilers
Delphi is still a superior tool for writing Windows applications. Borland wants to make their flagship product the ideal tool to develop .NET applications. This is done without full backward compatibility. Whether this a good idea is highly doubted by many people in the Pascal world.
Delphi will be influential for the Pascal language for the forseeable time, though.
GNU-Pascal is an attempt to provide a Pascal compiler using the GCC compiler back end. While still active, this compiler has progressed a lot less than Free Pascal. The compiler tried to implement ISO Extended Pascal. While enhancing the original Pascal language considerably, the problem with ISO Extended Pascal is that no code exists in this dialect (and no programmers are being educated to write it), while it is mutually exclusive with the Turbo Pascal and Delphi dialects and their language extensions. This caused an unfortunate effect that no serious code bases existed that this compiler could compile, something which it still is recovering from today.
Rem Objects Chrome
This compiler does not implement Pascal, but a Pascal-like language for .NET. It is nice for .NET programmers, but it cannot really compile Pascal code, and also Delphi .NET code cannot be compiled with this compiler.
Virtual Pascal was a great 32-bit compiler with high Turbo Pascal compatibility, used by many OS/2 programmers to write real world applications. Over time, support for other x86 platforms was added, especially Win32 and DOS (various 32-bit PM extenders supported) and partly Linux, plus the supported dialect was extended to provide compatibility with Delphi 2. Unfortunately the compiler was from the beginning written in Turbo Assembler, which made it impossible, or at least very hard, to port to other platforms, extend with new features and maintain in general. That resulted in official announcement of Virtual Pascal death by its maintainer and copyright owner. Full source code has never been available, so nobody can really continue officially (except for fixing some RTL issues, etc.).