A program is steps in order
You will learn
A program is a list of small steps done in order, and the order is part of what the program means.
A program is a list of small steps that the computer does one after another. Take the number 2. Add 3, then double it: you get 10. Double it, then add 3: you get 7. The same two steps in another order give another answer, so when you describe a program to an agent you describe the order too. A loop is one step written once and repeated: add 3 four times, from 2, gives 14. When a result surprises you, read the steps in order and find the earliest one that does not do what you meant.
Try it
Find the three programs in the spec: add_then_double, double_then_add and add_three_n_times. Change LOOP_RESULT from 14 to 11 and run it: a_loop_is_one_step_repeated fails, because 11 is three steps, not four. Put the 14 back.
The same two steps, add 3 and double, in two orders give two answers, and a loop repeats one step. Lesson 2 of the vibecoding course.
specs/vibecoding/steps_in_order.t27
// SPDX-License-Identifier: Apache-2.0
; Vibecoding lesson 2: a program is steps in order.
; The same two steps in another order give another answer, and a loop repeats one step.
module vc_steps_in_order;
; add 3, then double
pub fn add_then_double(x: u16) -> u16 {
return (x + 3) * 2;
}
; double, then add 3
pub fn double_then_add(x: u16) -> u16 {
return x * 2 + 3;
}
; one step, repeated: add 3, n times
pub fn add_three_n_times(start: u16, n: u8) -> u16 {
var s : u16 = start;
for i in 0..n {
s = s + 3;
}
return s;
}
pub const START : u16 = 2;
pub const TIMES : u8 = 4;
; What each program printed when it ran with START.
pub const ADD_FIRST : u16 = 10;
pub const DOUBLE_FIRST : u16 = 7;
pub const LOOP_RESULT : u16 = 14;
test add_first_then_double {
assert ADD_FIRST == (START + 3) * 2;
}
test double_first_then_add {
assert DOUBLE_FIRST == START * 2 + 3;
}
test the_order_changes_the_answer {
assert ADD_FIRST != DOUBLE_FIRST;
}
test a_loop_is_one_step_repeated {
assert LOOP_RESULT == START + 3 * 4;
assert LOOP_RESULT == START + 3 + 3 + 3 + 3;
}
All lessons
Module 1 · What vibecoding is
You describe, an agent writes, you run it and check. What a program is, and five myths put to a test.
Module 2 · Your desk
An editor with an agent beside it, ten terminal commands, and reading an error message.
Module 3 · Save points with git
A commit is a save point, a branch is a safe try, and a key is a pair of which one stays private.
Module 4 · Prompting
The parts of a prompt, an example in place of an adjective, and one small step at a time.
Module 5 · The working loop
Four phases from idea to ship, the loop of ask, run, read and fix, and what to do when it is stuck.
Module 6 · A test as the judge
A test says yes or no, a planted bug shows the test works, and a diff is read before it is accepted.
Module 7 · The parts of an agent
What an agent answers with, what it can do with tools, and what it keeps between messages.
Module 8 · A first bot
A bot is a message loop, a bot comes from a spec, and a secret stays out of the repository and the prompt.
Module 9 · Your own project
A spec for your own idea, one thing measured after it runs, and an honest plan for the next month.