Chapter 2 Key Takeaways
The Essentials
-
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.
-
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.
-
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.
-
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.
-
Every Pascal program follows the same structure: a
programheader, optional declaration sections (uses,const,type,var), and abegin...end.main block. The program always ends withend.(period, not semicolon). -
WriteLnoutputs text and a newline;Writeoutputs text without a newline;ReadLnwaits 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
fpcis "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 ofend.— The finalendof 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.pasworks 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.