Chapter 39 Self-Assessment Quiz: The Pascal Ecosystem

Test your understanding of the Pascal ecosystem covered in Chapter 39.


Section 1: Multiple Choice

Q1. The Free Pascal compiler is "self-hosting." This means:

(a) It can only compile programs on the same machine where it was installed (b) It is written in Pascal and compiles itself (c) It does not require an internet connection (d) It hosts a web server for documentation

Answer (b) A self-hosting compiler is written in the language it compiles. Free Pascal is written entirely in Pascal and compiles its own source code. This demonstrates the language's capability and means that improvements to the compiler immediately benefit its own compilation.

Q2. Which of the following is NOT a processor architecture supported by Free Pascal?

(a) x86-64 (b) ARM (AArch64) (c) RISC-V (d) Itanium (IA-64)

Answer (d) As of Free Pascal 3.2, Itanium (IA-64) is not a supported target. Free Pascal supports x86, x86-64, ARM, AArch64, MIPS, PowerPC, SPARC, RISC-V, WebAssembly, JVM, and AVR, among others — but not Intel's Itanium architecture, which Intel itself has discontinued.

Q3. In Free Pascal, the {$mode delphi} directive is used to:

(a) Convert Free Pascal code to Delphi format for export (b) Enable maximum compatibility with Delphi's Object Pascal dialect (c) Require a Delphi license to compile (d) Disable Free Pascal-specific features permanently

Answer (b) The {$mode delphi} directive tells Free Pascal to use Delphi-compatible syntax and semantics. This means generics use Delphi syntax (no specialize keyword), the @ operator is not required for procedure variables, and other Delphi conventions are followed. It allows most Delphi code to compile with Free Pascal without modification.

Q4. What is the Lazarus Online Package Manager (OPM)?

(a) A store for purchasing Lazarus extensions (b) A tool for managing Free Pascal compiler versions (c) A built-in feature for installing community-contributed component packages with one click (d) A version control system for Lazarus projects

Answer (c) The OPM is a built-in feature of the Lazarus IDE that provides a searchable catalog of community-contributed packages. Users can browse, install, and update packages directly from the IDE. Packages include components, libraries, and tools that extend Lazarus's capabilities. All packages in the OPM are free.

Q5. Delphi's FireMonkey (FMX) framework differs from VCL in that:

(a) FMX is open-source while VCL is proprietary (b) FMX is cross-platform (Windows, macOS, Linux, iOS, Android) while VCL is Windows-only (c) FMX uses native OS controls while VCL uses custom-rendered controls (d) FMX is for console applications while VCL is for GUI applications

Answer (b) VCL (Visual Component Library) is Windows-only and uses native Win32 controls. FMX (FireMonkey) is cross-platform and uses GPU-accelerated custom-rendered controls that provide a consistent appearance across Windows, macOS, Linux, iOS, and Android. Note that (c) is backwards — VCL uses native controls, FMX uses custom-rendered ones.

Q6. Which library would be most appropriate for building a 2D game in Pascal?

(a) mORMot (b) Synapse (c) Castle Game Engine (d) ZeosLib

Answer (c) Castle Game Engine is a complete 3D and 2D game engine written in Object Pascal. It includes a visual editor, physics engine, sprite support, tilemaps, audio, and cross-platform deployment. mORMot is an ORM/SOA framework (not for games), Synapse is a networking library, and ZeosLib is a database connectivity library.

Q7. The chapter mentions that Free Pascal's GPL license includes a "static linking exception." What does this exception allow?

(a) Programs compiled with FPC can be distributed under any license, not just GPL (b) FPC can link against proprietary C libraries (c) FPC can compile proprietary Delphi code (d) Programs compiled with FPC are exempt from all copyright law

Answer (a) The static linking exception means that while the Free Pascal compiler itself is GPL-licensed, the compiled output (your program) can be distributed under any license you choose — proprietary, open-source, or anything in between. Without this exception, the GPL would require all programs compiled with FPC to also be GPL-licensed. This is the same model used by GCC.

Q8. According to the chapter, which of the following industries has significant Pascal/Delphi usage?

(a) Social media startups (b) Healthcare and medical software (c) Cryptocurrency mining (d) Mobile game development

Answer (b) Healthcare and medical software is one of the sectors where Pascal/Delphi usage is most prevalent. Medical software has long regulatory approval cycles, and many systems approved by regulatory authorities were built in Delphi. Rewriting them in another language would require re-certification, so they continue to be maintained and extended in Delphi.

Section 2: Short Answer

Q9. Name three types of contributions you could make to the Free Pascal or Lazarus projects, in order from easiest to most difficult.

Answer From easiest to most difficult: (1) Bug reports — file a clear, reproducible bug report with a minimal test case. This requires no programming beyond creating a small example. (2) Documentation — fix typos, add examples, or clarify explanations in the Free Pascal documentation. This requires reading and writing ability but no compiler knowledge. (3) Code patches — fix a bug or add a feature in the compiler or IDE source code. This requires understanding the compiler's internal architecture and following the contribution guidelines.

Q10. The chapter identifies a "supply-demand imbalance" in the Delphi job market. Explain this imbalance and its implications for someone considering learning Pascal/Delphi professionally.

Answer The imbalance is: (1) there are fewer Delphi job postings than for mainstream languages (500-2,000 vs. tens of thousands for Java/Python), but (2) there are also far fewer Delphi developers, especially as the generation that learned Delphi in the 1990s-2000s approaches retirement. The result is that while the absolute number of Delphi jobs is small, the competition for each job is also small, and experienced Delphi developers can often command premium salaries. For someone considering Pascal/Delphi professionally, this means it is unlikely to be your sole career path, but it can be a valuable specialization — particularly in healthcare, finance, government, and industrial automation where legacy Delphi systems are common.

Q11. Why does the chapter recommend {$mode objfpc}` for new projects rather than `{$mode delphi}?

Answer {$mode objfpc} enables all of Free Pascal's modern features and native syntax conventions. It is the mode designed for Free Pascal specifically, while {$mode delphi} is a compatibility mode designed for porting existing Delphi code. Using {$mode objfpc} for new projects ensures you are using the features as the Free Pascal developers intended, with explicit syntax that makes intent clear (e.g., specialize for generic instantiation, @ for address-of). {$mode delphi} is recommended only when porting existing Delphi code or working in a mixed FPC/Delphi codebase.

Q12. Compare Synapse and Indy as networking libraries. When would you choose each?

Answer Synapse is lightweight, simple, and well-documented. It provides basic TCP/UDP, HTTP, SMTP, and SSL support. Choose Synapse for simple networking tasks (making HTTP requests, sending emails, basic socket programming) where you want minimal dependencies and easy integration. Indy is comprehensive, supporting dozens of protocols (HTTP, FTP, SMTP, POP3, IMAP, SSH, LDAP, DNS, and more). Choose Indy when you need a specific protocol that Synapse does not support, or when you need advanced features like connection pooling or protocol-level control. The tradeoff: Synapse is easier to learn, Indy is more feature-complete.