Chapter 01 · Week 1

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
1

Try the first rep now

Before you read this chapter, get your fingers moving. Type the Hello World program below — character by character. Then come back up and read.

First Rep — Hello, World

Type the program below into the empty editor — character by character. No copy-paste. (We'll know.) Your hands need the reps as much as your brain does.

Type this:
 
Your editor: 0%
Terminal output:
(waiting for you to finish...)
REP COMPLETE. You've written your first C++ program.
Coach's note: This is the rep that gets your fingers acquainted with #include, int main, semicolons, and braces. You'll type this signature shape a hundred times this semester. Make it now feel familiar.

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.cpp and 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.

Check Your Reps

The First Rep — Quick Check

Question 1 of 4
Which of these is the most important line in any C++ program?
Why: When you run a compiled C++ program, the operating system looks for a function named main and starts executing there. Every program needs exactly one.
Question 2 of 4
In cout << "Hello, world." << endl;, what is the role of the ; at the end?
Why: The semicolon is C++'s statement terminator. Forget it and you get a compile error. (The newline comes from endl, not the semicolon.)
Question 3 of 4
What does this chapter call the three core moves every program is built out of?
Why: Memory (variables), Asking Questions (conditionals), and Repetition (loops and functions). Every nontrivial program ever written is some combination of these three.
Question 4 of 4
You forget the ; at the end of the cout line. What happens when you try to compile?
Why: C++ requires semicolons at the end of every statement. Forgetting one is a compile error — the compiler refuses to produce an executable until you fix it. Train your eyes to recognize this exact error message.
YOU FINISHED. NICE WORK.

← BACK TO SYLLABUS   ·   WEEK 2: MEMORY →