Software / Building Blocks
How a Computer Follows Instructions
A program gives a computer instructions. It works with the values you supply and the rules you write, so a small mismatch between your intention and your rule can change the result.
- Values are the material: a cue name, a duration, or whether a prop is available.
- Variables give values names so later instructions can use them.
- Control flow chooses what runs next through conditions and loops.
- Functions package a task behind a name. A function that checks a cue can be called for every prop and tested with several examples.
Trace a cue decision to see those ideas work together.
Programs Essentials
A guided first language
MDN's JavaScript guide, from values to functions, runnable in any browser.
mdn: JavaScript guideA complete first course
Harvard's CS50, free, with problem sets that build real habits.
cs50The analyst's first language
The official Python tutorial, the usual starting point for data work.
python: tutorialTurn the quiet-room rule into a decision
Bring the rule from Logic: a cue must be available and known to be silent. Here is that decision in JavaScript. You can trace it on paper; the code is also ready to run in a JavaScript console.
function canPlay(cue) {
return cue.available === true && cue.sound === false;
}
const lantern = { available: true, sound: false };
canPlay(lantern); // true
=== checks an exact value; && requires both checks to pass. The lantern returns true. That result approves a cue; it does not switch on a lamp or run a show.
- Change
availabletofalse. Predict the result before checking it. - Restore availability and change
soundtotrue. You have made the bell's case. - Remove the
soundfield. Decide whether incomplete information should count as permission.
Compare the three results
All three return false. The last case matters: a missing field is not exactly false, so the rule refuses a cue whose sound status is unknown. These examples assume the input is a cue object; accepting other input types would need a separate contract.
Keep: the function and an input/output pair for each change. Give the whole cue collection a shape, or turn your predictions into repeatable checks.