Preface
In 1970, a Swiss computer scientist named Niklaus Wirth published the specification for a new programming language. He had a specific problem in mind: the languages available to teach programming — FORTRAN, COBOL, the various assembly languages — were designed for professionals writing production code, not for students learning to think computationally. They were full of historical accidents, cryptic syntax, and shortcuts that rewarded experience over clarity. Wirth wanted a language where the right way to do something was also the obvious way. He wanted a language that would make students think before they typed.
He called it Pascal.
Over the next two decades, Pascal became the dominant language for computer science education worldwide. It taught a generation of programmers — many of whom went on to build the systems that run the modern world — that programs should be structured, that types should be declared, that procedures should have clear interfaces, and that readable code is better code. Anders Hejlsberg learned Pascal before creating Turbo Pascal, then Delphi, then C#. The developers of the original Macintosh operating system wrote large portions of it in Pascal. The language's influence runs quietly through the DNA of almost every modern programming language.
Then, somewhere around the mid-1990s, the industry moved on. C++ conquered systems programming. Java conquered enterprise software. Python conquered education. And Pascal — unfairly, we believe — acquired a reputation as a relic. "Isn't that a dead language?" became the reflexive response.
We wrote this book because that reputation is wrong, and because the gap it has created is a problem worth solving.
Why Pascal in 2026
Let us be direct about the landscape. If you measure a language by job postings on LinkedIn, Pascal will not top the chart. If you measure by Stack Overflow questions per day, Pascal will not be in the top ten. By those metrics, learning Pascal seems like an eccentric choice.
But those are the wrong metrics for choosing a learning language.
The question is not "what language has the most jobs?" — the answer to that changes every five years and is useless for foundational education. The question is: "what language will teach me to think like a programmer in a way that transfers to every language I will ever use?"
By that standard, Pascal is not merely competitive. It is arguably the best choice available.
Here is why. Pascal's strong typing forces you to understand what your data is before you operate on it. You cannot accidentally add a string to an integer, and the compiler will not silently guess what you meant — it will tell you, at compile time, that you made an error. Python will happily let you assign a string to a variable that held an integer a line ago. JavaScript will coerce types in ways that produce legendary memes. C will let you interpret raw memory as whatever type you like, often with catastrophic results. Pascal makes you declare your intentions explicitly, and then holds you to them. This is not a limitation — it is the single most important habit a beginning programmer can develop.
Pascal's structured programming — begin..end blocks, explicit control flow, procedures and functions with declared parameters — teaches you to organize your thinking before you organize your code. The language essentially refuses to let you write spaghetti code. You can write bad Pascal, of course, but the language actively resists the worst habits that other languages enable by default.
And here is the part that surprises people: modern Pascal is not the Pascal of 1970, or even the Turbo Pascal of 1990. The Object Pascal dialect, as implemented by Free Pascal and Delphi, is a fully modern programming language with classes, inheritance, interfaces, generics, exception handling, anonymous functions, and operator overloading. Free Pascal compiles to native code on over twenty platforms. The Lazarus IDE gives you a free, open-source, cross-platform RAD (Rapid Application Development) environment that rivals commercial tools. You can build a complete, native, cross-platform desktop application with a GUI, database access, and network connectivity — and the resulting executable is a single, small, fast binary with no runtime dependencies.
In an age of Electron apps that consume a gigabyte of RAM to display a to-do list, that matters.
The Competitive Landscape Gap
When we surveyed the existing Pascal learning materials, we found a hole. Jeff Duntemann's Free Pascal from Square One is a generous and well-written introduction, but it stops at the fundamentals — no OOP, no GUI programming, no modern Object Pascal features. Marco Cantu's Object Pascal Handbook is an excellent language reference, but it is not a learn-to-program textbook — it assumes you already know how to code. The classic Turbo Pascal textbooks are all thirty-plus years old and out of print.
There is no free, comprehensive, modern Pascal textbook that takes a complete beginner from zero to building real applications. No book that covers fundamentals and object-oriented programming and data structures and GUI development and systems programming in a single coherent treatment, with all code tested against a current, free, open-source compiler.
This book fills that gap.
Our Philosophy
We believe in the Wirth tradition: clarity, precision, and elegance. Programs should be correct before they are clever. Code should communicate its intent to human readers, not just to compilers. The structure of a program should reflect the structure of the problem it solves.
We also believe that programming is learned by programming. This is not a book to read passively. Every section contains code to type, compile, and run. Every chapter has exercises that progress from straightforward to genuinely challenging. We will frequently ask you to predict what a program will do before you run it, because developing that predictive ability — that mental model of computation — is the real goal of learning to program. The language is just the vehicle.
Throughout the book, you will build PennyWise, a personal finance manager that starts as a simple console program in Part I and grows through file-based storage (Part II), an object-oriented redesign (Part III), smart algorithms (Part IV), a full GUI with database backend (Part V), production features like JSON export and network connectivity (Part VI), and a complete deployment-ready application (Part VII). PennyWise is not a contrived exercise — it is a genuinely useful application, and building it demonstrates that Pascal produces real software for real users.
Four additional anchor examples recur across chapters: a text adventure game engine that exercises data structures and OOP design, a student grade management system that demonstrates records and algorithms, and a simple web server that proves Pascal can do modern things. These recurring examples build continuity and let you see how the same concepts apply in different contexts.
How This Book Is Organized
Part I: Foundations (Chapters 1–8) starts from absolute zero. By the end, you can write structured programs with variables, control flow, procedures, and functions. You understand strong typing not as a nuisance but as an ally.
Part II: Data Structures in Pascal (Chapters 9–15) covers arrays, strings, records, files, pointers, and dynamic data structures. This is the heart of the Wirth tradition — the idea that choosing the right data structure is half the battle of programming.
Part III: Object Pascal (Chapters 16–21) introduces modern object-oriented programming: classes, inheritance, interfaces, exceptions, generics, and advanced features. You will redesign PennyWise using OOP principles and see why objects are a natural way to model real-world problems.
Part IV: Algorithms and Problem Solving (Chapters 22–26) covers recursion, searching, sorting, trees, graphs, and algorithm design strategies. Wirth wrote the book on this — literally (Algorithms + Data Structures = Programs, 1976) — and Pascal remains the ideal language to study it in.
Part V: GUI Programming with Lazarus (Chapters 27–32) teaches you to build graphical desktop applications using the Lazarus IDE and its component library. PennyWise gets a real user interface with forms, menus, charts, and a SQLite database.
Part VI: Systems and Advanced Topics (Chapters 33–37) covers modular design, file formats, networking, multithreading, and OS interfaces. These chapters demonstrate that Pascal is not just a teaching language — it is a capable systems programming language.
Part VII: Capstone and the Pascal Ecosystem (Chapters 38–40) brings everything together in a capstone project, surveys the living Pascal ecosystem, and reflects on Pascal's legacy and future.
Eleven appendices provide reference material including a language quick reference, installation guide, compiler error dictionary, dialect comparison (Free Pascal vs. Delphi), reserved words, Lazarus component reference, glossary, selected exercise answers, and a bibliography.
Who We Are
This book is a community effort, created as an open educational resource. It builds on the pedagogical tradition established by Wirth, extended by the Turbo Pascal era textbooks, and refined by decades of CS education research. We are Pascal enthusiasts who believe the language deserves a modern, free, comprehensive textbook — and we decided to write one.
We have tried to be honest about Pascal's place in the modern landscape. We will not pretend it is the most popular language or that learning it guarantees a job. What we will argue — and what we believe the evidence supports — is that the discipline Pascal teaches transfers to every other language, that the modern Pascal ecosystem is more capable than most people realize, and that the clarity of thought Pascal demands is exactly what beginning programmers need.
If you are reading this, you have already made a choice that millions of successful programmers made before you. Welcome to Pascal. We think you will find it was worth the visit.
Let us begin.