Chapter 40 Exercises: Pascal's Legacy and Future
These are reflective and research exercises. There is no code to write — only thinking to do. These exercises ask you to look backward over everything you have learned and forward to everything you will learn next.
Part A: Historical Reflection
A.1. Niklaus Wirth created a sequence of languages: Euler, Algol W, Pascal, Modula-2, Oberon, and Oberon-2. Research at least three of these languages and answer: what did each language add or remove compared to its predecessor? What does this trajectory tell you about Wirth's design philosophy?
Guidance
The key insight is that each successive language was *simpler*, not more complex. Pascal added structured programming and strong typing to Algol W's foundation. Modula-2 added modules (separate compilation) but also simplified some of Pascal's constructs. Oberon was radically simpler than Modula-2 — it removed features like enumerated types, subrange types, and variant records that Wirth considered unnecessary. This trajectory of simplification is the opposite of what most language designers do, and it reflects Wirth's core belief: complexity is the enemy of reliability.A.2. The chapter mentions that Anders Hejlsberg created Turbo Pascal, then Delphi, then C#. Research Hejlsberg's career and write a 300-word profile. How did his experience with Pascal influence the design of C#? What specific features of C# can you trace back to Pascal or Delphi?
Guidance
Key features of C# that trace to Pascal/Delphi include: properties with get/set accessors (from Delphi properties), delegates and events (from Delphi's event system), the emphasis on strong typing, component-oriented programming (from Delphi's VCL component model), and the general philosophy that code should be safe, readable, and efficient. Hejlsberg himself has acknowledged Pascal's influence in interviews. The journey from Turbo Pascal (1983) to Delphi (1995) to C# (2000) is a single continuous design evolution.A.3. The Turbo Pascal 1.0 compiler fit in 33 kilobytes. Find out the size of a modern compiler (e.g., GCC, LLVM/Clang, or Free Pascal's own compiler binary). Calculate the ratio. What factors explain this enormous difference? Is the modern compiler doing proportionally more work, or is something else going on?
Guidance
A modern Free Pascal compiler binary is typically 20-40 MB (approximately 1,000x larger than Turbo Pascal 1.0). Factors: (1) multiple optimization passes (TP had minimal optimization), (2) support for multiple targets and modes (TP supported only one), (3) generics, OOP, and other modern features, (4) richer standard library linked into the compiler, (5) debug information, (6) broader Unicode support. The modern compiler does far more work per compilation, but the size increase is also due to the accumulated features of forty years of evolution. This is a real-world example of Wirth's Law.A.4. The AP Computer Science exam used Pascal from 1982 to 1999, then switched to C++, then to Java in 2004. Research the reasons for each switch. Do you think the switches were justified? What would have happened if Pascal had remained the AP language?
Guidance
The switch from Pascal to C++ was driven by industry demand — employers wanted graduates who knew C++. The switch from C++ to Java was driven by C++'s complexity and safety issues — too many students were struggling with memory management and undefined behavior. If Pascal had remained: students would have had a stronger foundation in structured programming and types, but less exposure to the language ecosystems used in industry. There is no objectively correct answer — it depends on whether you believe CS education should optimize for foundational understanding or for immediate employability.Part B: Language Comparison
B.1. Choose a language you know (or are interested in learning) other than Pascal. Write a side-by-side comparison of how both languages handle: (a) variable declaration, (b) function definition, (c) conditional logic, (d) loops, (e) error handling. For each feature, identify which language's approach you prefer and why.
Guidance
This exercise is about developing the comparative perspective that comes from knowing more than one language. There is no "right" answer. The goal is to articulate *why* you prefer one approach over another — which requires understanding both approaches deeply. Some students prefer Pascal's explicit variable declarations; others prefer Python's implicit typing. The important thing is that you can explain your preference with technical reasoning, not just familiarity.B.2. The chapter claims that Pascal influenced Java, C#, Ada, Swift, and Rust. Choose one of these languages and identify three specific features that can be traced to Pascal's influence. For each feature, show the Pascal syntax and the other language's syntax side by side.
Guidance
Example for C#: (1) Properties — Pascal:property Name: String read FName write FName; / C#: public string Name { get; set; }. (2) Strong typing — both languages require explicit type declarations and catch type errors at compile time. (3) Structured control flow — both use if/else, for, while, and case/switch without requiring GOTO.
B.3. The chapter states that "Pascal's emphasis on memory safety without garbage collection resonates deeply with Rust's approach." Research Rust's ownership model and compare it to Pascal's manual memory management (New/Dispose, try/finally). What does Rust formalize that Pascal leaves to the programmer's discipline?
Guidance
Rust formalizes ownership (each value has exactly one owner), borrowing (references must be either shared-immutable or exclusive-mutable, never both), and lifetimes (the compiler verifies that references do not outlive the data they point to). Pascal leaves all of this to the programmer — you can create dangling pointers, have multiple owners of the same memory, and access freed memory. Pascal *teaches* you to manage memory correctly; Rust *enforces* it. This is a genuine improvement — but the Pascal programmer who has struggled with dangling pointers understands *why* Rust's rules exist, which is more valuable than simply following rules you do not understand.Part C: Reflection on Your Learning Journey
C.1. Look back at Chapter 1. Reread Section 1.1 ("The Problem with Learning to Program"). Has your perspective on the arguments made there changed after completing the textbook? Do you agree or disagree with the claim that Pascal is the best first language? Write a 500-word response.
C.2. What was the single most important concept you learned in this textbook? Not the most difficult — the most important. Explain why it matters and how you expect it to influence your future programming.
Guidance
Common answers include: strong typing (because it prevents entire categories of bugs), separation of concerns (because it makes large programs manageable), recursion (because it changes how you think about problems), or the distinction between interface and implementation (because it enables collaboration). There is no wrong answer — the goal is to identify what was most transformative for *you*.C.3. Write a letter to yourself six months in the future. Describe: (a) what you have learned, (b) what you plan to build, (c) what language(s) you plan to learn next, and (d) one piece of advice based on your experience with this textbook.
C.4. If you could add one chapter to this textbook — Chapter 41 — what would it cover? Write a one-paragraph chapter summary, including the title, the topic, and how it would extend what you learned.
Guidance
Popular suggestions from past students include: "Chapter 41: Building a Compiler in Pascal" (recursive descent parsing, code generation — extending Wirth's own tradition), "Chapter 41: Game Development with Castle Game Engine" (applying OOP and algorithms to interactive applications), "Chapter 41: Web Development with pas2js" (Pascal in the browser), and "Chapter 41: Contributing to Free Pascal" (reading and modifying the compiler source code). All of these are natural extensions of the skills you have developed.Part D: The Wirth Challenge
D.1. Wirth's most famous book is titled Algorithms + Data Structures = Programs. Over the course of this textbook, you have learned many algorithms and data structures. Create a personal catalog: list every algorithm and every data structure you have learned, the chapter where you learned it, and one real-world application for each.
Guidance
Algorithms include: linear search, binary search, bubble sort, insertion sort, quicksort, merge sort, recursive descent, depth-first search, breadth-first search, Dijkstra's algorithm, dynamic programming (various), and greedy algorithms. Data structures include: arrays, strings, records, sets, linked lists, stacks, queues, binary trees, binary search trees, hash tables (conceptual), and graphs. Each has multiple real-world applications — the exercise is to connect the abstract concept to concrete use cases.D.2. Wirth's principle of simplicity can be applied not just to programming languages but to any design activity. Think of a non-programming domain where simplicity is a virtue (architecture, cooking, writing, sports, music). Write a paragraph explaining how Wirth's philosophy applies to that domain.
Part E: Final Project Proposals
E.1. Propose a project you would like to build in Pascal. It can be anything: a game, a tool, a utility, a library, a web application (via pas2js), or an extension to PennyWise. Write a one-page project proposal that includes: (a) what the project does, (b) who it is for, (c) which chapters from this textbook provide the foundation, (d) what new skills you would need to learn, and (e) a rough timeline.
E.2. Propose a contribution to the Free Pascal or Lazarus project. This could be a bug report, a documentation improvement, a package, or a code patch. Describe: (a) what you would contribute, (b) why it would be valuable to the community, and (c) the steps you would take to make the contribution.