Part I: Foundations

In which we meet Pascal, set up our workshop, and discover that a language designed to teach discipline turns out to be a language worth mastering.


Every programming language carries within it a philosophy — a set of beliefs about how humans and machines ought to communicate. Some languages believe in radical freedom: write anything, anywhere, in any style, and the compiler will do its best to make sense of the mess. Others believe in ceremony: annotate everything, declare your intentions in triplicate, and perhaps the type-checker will let you run your code by Thursday.

Pascal believes in clarity.

When Niklaus Wirth created Pascal in 1970, he did not set out to build a toy. He set out to build a language that would teach structured programming — and in doing so, he inadvertently built a language so well-designed that engineers used it to write the Apple Lisa's operating system, Skype's original codebase, and embedded controllers that still run industrial equipment half a century later. Pascal's insistence on declaring before using, on explicit types, on clean block structure — these are not training wheels. They are engineering principles. And they are the principles that will guide you through the eight chapters ahead.

What You Will Build

By the end of Part I, you will be able to write substantial, well-structured Pascal programs. Not scripts. Not snippets. Programs — with procedures, functions, proper control flow, and a design that another programmer could read and understand.

Your vehicle for this journey is PennyWise, the Personal Finance Manager that serves as this textbook's progressive project. In Part I, PennyWise begins its life as a concept and ends as a functioning console expense tracker. You will start by printing a welcome message to the screen. By Chapter 8, you will have a program with multiple procedures, user input validation, formatted output, and the ability to categorize and subtotal expenses — all running from the command line, all written in clean Pascal.

Along the way, you will also encounter GradeBook Pro, our anchor example for data-processing fundamentals, and glimpse the early logic that will eventually power Crypts of Pascalia, the text adventure game that makes data structures and algorithms tangible.

What These Chapters Cover

Chapter 1 introduces Pascal's history and philosophy. You will meet Niklaus Wirth, understand why Pascal was created, and see where the language stands today in its Free Pascal and Delphi incarnations. More importantly, you will understand why learning Pascal in the twenty-first century is not nostalgia — it is strategy.

Chapter 2 gets your hands dirty. You will install Free Pascal and Lazarus, configure your editor, compile your first program, and understand the compile-link-run cycle that Pascal makes explicit. No hidden magic. No mystery build systems. You write code, the compiler tells you exactly what is wrong, and you fix it.

Chapters 3 and 4 introduce variables, data types, constants, and expressions. Pascal's type system is one of its great gifts: it catches errors before your program runs, it documents your intentions in the code itself, and it forces you to think clearly about what kind of data you are working with. Rosa Martinelli, our freelance graphic designer, discovers this when she starts modeling her expenses — an amount is not a string, a category is not a number, and Pascal will not let her confuse the two.

Chapter 5 covers input and output: reading from the keyboard, writing to the screen, and formatting results so they look professional. Tomás Vieira, our college student on a tight budget, builds his first interactive program here — a simple expense entry system that reads what he spent and tells him how much remains. It is not glamorous. It works.

Chapter 6 introduces control flow: if-then-else, case statements, for loops, while loops, repeat-until. This is where programs stop being calculators and start being programs. You will write code that makes decisions, that repeats until a condition is met, that branches based on user input. PennyWise gains its first menu system here.

Chapters 7 and 8 are the crown of Part I: procedures, functions, parameters, and scope. These chapters transform you from someone who writes code into someone who designs programs. You will learn to decompose a problem into named, reusable pieces. You will understand the difference between value parameters and variable parameters — a distinction Pascal makes explicit in a way that languages like Python and JavaScript simply do not. You will learn about local and global scope, and why the discipline of keeping variables local is not a restriction but a liberation.

The Themes That Begin Here

Several themes run through this entire textbook, and all of them take root in Part I.

Discipline enables creativity. Pascal's strictness is not an obstacle to expression — it is the foundation for it. When the compiler enforces structure, your mind is free to think about the problem instead of chasing down bugs caused by ambiguity. Rosa learns this firsthand: her first attempt at PennyWise in pseudocode is full of vague variable names and implicit assumptions. Her Pascal version is longer, more explicit — and it works on the first compile.

Read the error message. Pascal's compiler errors are specific, located, and almost always correct. Part I trains you to treat the compiler as a collaborator, not an adversary. When it says "Identifier not found," it means you forgot to declare something. When it says "Incompatible types," it means you are trying to mix data that should not be mixed. These messages are not punishments. They are gifts.

Think before you type. Pascal's declare-before-use philosophy encourages you to plan your data before you write your logic. This habit — sketching out your types and procedures before writing the body of your program — will serve you in every language you ever use.

Programs are for people. Pascal was designed to be readable. Its English-like keywords (begin, end, if, then, else, while, do) mean that a well-written Pascal program can be understood by someone who has never seen Pascal before. In Part I, you will develop the habit of writing code that communicates its intent — not just to the compiler, but to the human who reads it next. That human is often you, six months from now.

A Word About Pace

Part I assumes no prior programming experience. If you have programmed before — in Python, in C, in JavaScript — you will move quickly through some chapters and find others surprisingly illuminating. Pascal's explicitness reveals things that other languages hide. The var parameter mechanism makes pass-by-reference visible. The strict type system makes implicit conversions impossible. The block structure makes scope tangible.

If you have never programmed before, welcome. Pascal is, in the opinion of many experienced educators, the finest language in which to learn. Not because it is simple — it is not, particularly — but because it is honest. It shows you what is happening. It tells you when you are wrong. And it rewards clean thinking with programs that work.

Let us begin.

Chapters in This Part