The Sport of Programming
"...always being prepared to make a defense to anyone who asks you for a reason for the hope that is in you; yet do it with gentleness and respect." — 1 Peter 3:15
Why This Matters
Watch any professional musician for sixty seconds. Their fingers move without their eyes following. They're not thinking "index finger to the third fret, ring finger to the fifth" — that conversation in their head ended years ago. The instrument is just an extension of what they want to say.
That's where we're going. By the end of this course, you'll sit down at a keyboard with a problem in your head and just type the solution. Not by following a tutorial. Not by copy-pasting from a website. Because the skill lives in your hands.
And the skill — articulating a careful idea clearly enough that something else can follow it — is the same skill that any thoughtful person needs in every other part of life, including the parts where someone asks them, "wait, why do you actually believe that?" The compiler is the most patient and least sympathetic interlocutor you will ever meet. It will not give you partial credit for almost clear thinking.
The Three Pillars
Every interesting program ever written is built out of three core moves. You already use all three, every day, without thinking about them.
Pillar 1: Memory
Humans remember things — names, scores, verses, where we parked. Computers do too. The tool is called a variable: a named box that holds a value. Every language has them.
Pillar 2: Asking Questions
Humans constantly ask "is this true?" and act differently depending on the answer. "Is the light green? Then go." "Is this claim about Jesus' resurrection consistent with the earliest sources we have? Then we have something to deal with." Programs do this with conditionals.
Pillar 3: Repetition
Brushing every tooth. Reading every chapter of a Bible-in-a-year plan. Lifting every rep. Computers are spectacular at repetition — they do it billions of times a second. The tools are loops and functions.
Coach's Note — When new concepts feel weird later in this book — pointers, classes, inheritance, polymorphism — stop and ask: "is this a Memory thing, a Questions thing, or a Repetition thing?" Almost always, it's one of the three dressed in a slightly fancier outfit.
Hello, World — Walked Through
You just typed it. Here it is again so we can dissect every character:
#include <iostream>
using namespace std;
int main() {
cout << "Hello, world." << endl;
return 0;
} Five lines of typing. One line of output. Congratulations — you've written a C++ program.
#include <iostream>
A preprocessor directive: before compiling, the compiler pastes the contents of
iostream into the top of your file. iostream is the toolbox for talking to the
screen and keyboard. Without this line, cout doesn't exist.
int main()
The most important line in any C++ program. When you run your compiled program, the operating system goes
looking for a function named main. That's where execution starts.
cout << "Hello, world." << endl;
cout is "console out." << is the stream insertion operator — read it as "send
this to." endl sends a newline. The ; is the statement terminator. C++ uses
semicolons to mark "this complete instruction ends here." Forget one and the compiler will tell you about
it loudly.
Coach's Note — Programs that work are not interesting. Programs that break in a specific way teach you the most. Open
hello.cppand break it on purpose. Delete the semicolon. Try to compile. Read the error. Put it back. Delete the#include. Try again. You are training your eyes to recognize error messages.
A Note on Vocation
Lutherans have a particular word for the kind of work you're doing in this course: vocation. Luther used it to mean any honest calling — a baker's, a parent's, a student's — through which a person serves the people around them.
The cleaner version of the lesson: do honest work in the room you're in. The neighbor next to you needs you to write code that doesn't crash; the neighbor twenty years from now needs you to write code they can read. That's enough vocation for one chapter.
This Week's Project
You're a few hundred words from being ready for Project 1: Apologist's Card. You'll build
a program that prints a structured "starting line" card — name, where you're from, the question you want
to be able to think about clearly by Week 16. You'll use everything from this chapter:
cout, cin, one or two string variables.
Welcome to the gym.
Let's get to work.
The First Rep — Quick Check
main and starts executing there. Every program needs exactly one. cout << "Hello, world." << endl;, what is the role of the ; at the end?endl, not the semicolon.) ; at the end of the cout line. What happens when you try to compile?