Course
BASICModule 1: How Programs Think· 1/3

What Is Code

A program is a list of instructions

Code is text with instructions for a computer. Nothing mystical: a recipe for a worker that runs the instructions in order, top to bottom, absolutely literally.

The key trait of that worker: a computer is dumb and fast. It doesn't guess, it doesn't get "come on, you know what I meant," it doesn't fix obvious mistakes. But it runs billions of instructions per second and never gets tired. The whole point of programming is to state what you want precisely enough that even a dumb-but-fast worker does exactly that.

If you took our AI course, notice the parallel with prompting: there we learned to state a task precisely for a model. Code is the extreme form of the same discipline: a statement with no ambiguity at all.

The two languages of this course

We teach two languages at once — JavaScript and Python. Both are among the three most used in the world, and each has its own territory:

  • JavaScript — the language of the browser: everything alive on any website is written in it. Plus Node.js — running JS outside the browser: servers, scripts, bots.
  • Python — the language of data and automation: analysis, scripts, AI development, science.

The good news: the basics are shared. Variables, conditions, loops, functions — the same ideas with slightly different spelling. Learn a concept once and you get it in both languages — that's why every example in this course is given in both, and the difference is almost always cosmetic.

Your first program

Below is a playground: you can edit and run code right here, without installing anything. The classic first program prints text to the screen:

PLAYGROUND

Hit "Run." Then change the text in the quotes and run again — that's already programming: you changed an instruction, the worker obeyed.

Breakdown: console.log(...) in JavaScript and print(...) in Python are the "print to screen" command. The text in quotes is the data the command works with. Comments (// and #) are notes for people; the computer skips them.

Instructions run in order

A program reads top to bottom, line by line. Order is part of the meaning:

PLAYGROUND

Later in the course you'll meet conditions (skip steps) and loops (repeat steps) — but the base is always this: a sequence of instructions.

Errors are normal

Break the program on purpose: remove a closing quote or bracket and run it. You'll get an error message — the computer refused to run an instruction it couldn't parse and told you where it tripped.

Remember this from the first lesson: an error is not a failure, it's feedback. Professionals see error messages dozens of times a day. Reading them is a skill of its own, and a whole lesson in module 4 is devoted to it.

Key takeaways

  • Code is precise instructions for a dumb-but-fast worker; they run in order, literally.
  • JavaScript is the language of the browser and scripts, Python of data and automation; the basics are shared.
  • console.log / print print to the screen; comments are for people.
  • An error is feedback, not a failure.
CHECK YOURSELF
1. Why is "dumb and fast" the most important trait of a computer for a programmer?
2. What is the fundamental difference between the basics of JavaScript and Python?
3. A program printed an error message. What does that mean?
Variables & Types