A program needs precise steps
A person may guess what “tidy my list” means. A computer needs rules: which tasks, what order, and what to do in each situation. Source code expresses those rules in a programming language.
AI can help write code, but it may also guess the information you leave out. Breaking a goal into inputs, processing, and outputs is a useful way to think before choosing a language.
Input: product prices. Process: keep products within a budget. Output: a list of qualifying products.
Take this with you · Start with concrete inputs and expected results.
Why are there different languages?
JavaScript is common for webpage interactions, Python for scripts and data processing, and SQL for database queries. Their ecosystems and runtimes differ, but many uses overlap.
Choosing a language means considering where the result will run, what the existing project uses, and which tools are available. Ask AI to inspect an existing project before deciding how to change it.
Changing a webpage button starts with understanding the existing frontend, not automatically creating an unrelated Python project.
Take this with you · Define the goal and environment before selecting an implementation language.
Variables, conditions, and loops
A variable names a value, such as budget. A condition selects a branch, such as price <= budget. A loop applies work repeatedly, such as checking every price in a list.
These often work together: read each price, compare it to the budget, and keep it if it qualifies. Even before understanding every symbol, look for the data, decisions, and repeated steps.
With budget 30 and prices 12, 35, and 20, keep 12 and 20. Change the budget to 40 and the output changes.
Take this with you · Trace code with a concrete input instead of guessing its behavior.
Step through a small program
Predict the output, then check the prices one by one. Change the budget to see how a variable affects conditions and results.
budget = 25 prices = [12, 35, 20, 48, 8] for each price in prices: if price <= budget: keep(price)
Output: []
This runs a fixed filtering algorithm with real calculated results, not arbitrary user code.
Functions and data structures
A function gives a name to a reusable operation. It can take inputs and return a result. Arrays hold ordered collections; objects or dictionaries map names to values; trees represent hierarchies.
The structure you choose affects later operations. A list can be an array of task objects, each with an id, title, and completion status. Stable IDs identify which item to update.
A task might be { id: 7, title: 'Practice adding', done: false }. Completing it finds id 7, changes done, then updates the interface.
Take this with you · Ask how the data is organized before asking for a line-by-line syntax lesson.
How does source code run?
Source code needs suitable execution tools. Compiling transforms code into another form; interpreters and runtimes execute it. Real implementations often combine approaches rather than belonging to two rigid categories.
A terminal accepts text commands. Commands run in a working directory, so location matters. Keep the full error and command location when asking for help.
Running npm run dev in this project's web folder starts the configured development server. The same command outside the project may not work.
Take this with you · For a startup problem, report the system, project directory, command, and full error.
Combine existing tools and keep versions
Libraries provide reusable functionality. Dependencies are the libraries and tools a project requires. Installing them makes them available; version differences can change behavior, so projects record their dependencies and versions.
Git records changes so you can compare and restore versions. Ask AI for small, checkable changes and keep working checkpoints rather than losing track of what changed.
Before adding deletion: inspect the project, preserve the working version, change the feature, and check that adding and completing still work.
Take this with you · Writing code is only part of the job. Running it, inspecting changes, and checking behavior matter too.
The rule keeps prices no greater than a budget of 20. Which of 12, 35, and 20 remain?
Choose an answer before reading the explanation.
Ask AI to add task completion and restoration. Describe the whole interaction.
Think first, then uncover help as needed. Later chapters expect more complete descriptions and clearer checks.
Bring this chapter's context to your AI. Going deeper is optional; you can keep reading without it.
Explain variables, conditions, loops, and functions using packing a bag, one idea at a time.
One approach you can make your own
I'm learning computers and AI-assisted programming from scratch. In this chapter I learned: Programming:Recognize variables, conditions, loops, functions, and data structures;Distinguish languages, runtimes, and dependencies;Translate a vague idea into actions and expected results Explain variables, conditions, loops, and functions using packing a bag, one idea at a time. Check my understanding first. Explain one small question at a time with a concrete example and the limits of any analogy. Ask a scenario question, then adapt to my answer. Distinguish facts, guesses, and uncertainty; suggest hands-on ways to check. Confirm the version before giving tool-specific advice, and don't invent features or references.
Complete this chapter
Mark the sections as read, finish the experiment, and pass the scenario check to record completion. You can visit the next chapter at any time.
Read the original references
This is an introduction. These official resources help you check details and explore further.
MDN · JavaScript GuideOne machine can follow your steps. Next, let's make two machines communicate.