1.3 Rules vs. learning: the two paradigms

Week 1
Pick a depth · ✨ generates it for this lecture

Rules vs. learning: the two paradigms

There are fundamentally two ways to get a computer to do a task.

Paradigm one: write the rules

In rule-based programming, a human decides exactly what the program should do for every case and writes it down as instructions. This is ordinary software, and it is the right tool when the rules are knowable, stable, and few. Calculating tax, sorting a list, validating a form — you would never "train" a model for these; you just write the logic.

Paradigm two: learn the rules from data

In machine learning, the human does not write the task logic. Instead they provide many examples of inputs paired with desired outputs and let an algorithm discover the pattern that connects them. The "program" that results is a set of learned numbers (parameters), not lines of human-written logic. This is the right tool when the rules are unknown, too numerous, or too fuzzy to write down — recognizing a cat in a photo, judging whether a review is positive, predicting the next word.

Why learning won for perception and language

Consider trying to write rules to detect spam email. You start with "block messages containing FREE MONEY." Spammers write "FR€É M0NEY." You add a rule. They adapt again. The rulebook grows endlessly and never catches up. A learned classifier, by contrast, is shown thousands of labeled spam and non-spam messages and discovers the statistical fingerprints of spam on its own — and it can be retrained as spam evolves. Tasks involving messy, high-variety real-world inputs are exactly where rules break down and learning shines.

The honest summary

Neither paradigm is "better." Most real products combine them: learned models wrapped in hand-written rules and safety checks. The skill is knowing which part of a problem is a rules problem and which part is a learning problem.

Tip: highlight any passage above to ask the tutor about it, or to generate practice problems specifically on what you selected.
Ask the tutor for an explanation, a worked example, or a hint. Highlight a passage on the left to ground the question in that text.