4 Climbing the stack
This chapter covers
- Compile-time parsing and processing
- Patterns for debugging comptime code
- Using errors to separate code concerns
- Practical TCP and HTTP, and how to leverage them with the standard library
- Ziggy patterns including iterators and generic interfaces
Word games are one of my favorite ways to relax, although I think I take them too seriously to do much relaxing. They are also a fun programming challenge. Words are messy. It feels like there are more exceptions to the rules than there are words that fit the rules. There is no truly clean definition of word being properly part of a language.
A word ladder is a series of words of the same length that each differ in one letter to the last. We’ll now write a word ladder game that will first provide a randomized starting word and then ask you to create the longest ladder you possibly can!
4.1 Climbing the ladder
To make this game work, we’ll use a dictionary to sample starting words and determine whether a player’s words are valid. We’ll make use of comptime to bake our dictionary into the program. Finally, we’ll use the file skills we developed from our journey with cat to read words in and print out feedback. See how it fits together in figure 4.1.
Figure 4.1 The word ladder game