Chapter 2 Key Takeaways

The Essentials

  1. Free Pascal is the compiler; Lazarus is the IDE. Free Pascal (fpc) translates Pascal source code into native executables. Lazarus provides a visual editor, debugger, and form designer. You can use them independently or together.

  2. The compilation pipeline has three stages: compile, link, execute. The compiler checks your code and produces an object file. The linker combines the object file with the runtime library to produce a standalone executable. The operating system executes the result.

  3. Pascal is a compiled language. This means the compiler verifies your entire program — types, declarations, syntax — before producing an executable. Errors are caught at compile time, not at runtime.

  4. Executables are self-contained. A program compiled with Free Pascal runs on any compatible machine without installing a compiler, runtime, or interpreter. This is "native compiled code matters" in action.

  5. Every Pascal program follows the same structure: a program header, optional declaration sections (uses, const, type, var), and a begin...end. main block. The program always ends with end. (period, not semicolon).

  6. WriteLn outputs text and a newline; Write outputs text without a newline; ReadLn waits for user input. These three built-in procedures handle basic console I/O.

Common Mistakes to Avoid

  • Forgetting to add Free Pascal to PATH — If fpc is "not recognized," the PATH is not set correctly. See Section 2.8.
  • Using double quotes instead of single quotes — Pascal strings use 'single quotes', not "double quotes".
  • Ending the program with end; instead of end. — The final end of a program requires a period.
  • Not rebooting / opening a new terminal after PATH changes — Environment variable changes do not affect terminals that were already open.
  • Using a word processor instead of a text editor — Rich text formatting (bold, italic, fonts) produces characters the compiler cannot parse.

Rules of Thumb

  • If fpc hello.pas works but Lazarus cannot compile, the problem is Lazarus configuration, not your code.
  • Read the error message. The compiler tells you the file, line number, column number, and a description of the problem. Go to that line.
  • The error is almost always on the reported line or the line immediately above it.
  • When in doubt, add ReadLn; at the end of console programs so you can see the output before the terminal closes.

Looking Ahead

Chapter 3 introduces Pascal's type system: integers, real numbers, characters, strings, Booleans, constants, and variables. You will discover why declaring types explicitly is not busywork but one of Pascal's most powerful features — the compiler uses your declarations to catch bugs that would otherwise hide until your program is in production.