Learn to program: animated explainer videos

Knowledge Videos

Short animated explainers, organised by subject.

Learn to program

52 videos

A step-by-step path for complete beginners: how computers and the web work, then HTML, CSS, JavaScript, Go and a full-stack app of your own.

Start here: Inside a computer →

Part 3 · Think like a programmer

1:27

8What is a program?

A program is a list of exact instructions the computer follows in order. Algorithm, sequence and bug, explained with a robot that makes a sandwich.

programalgorithmsequencebugbeginner
1:07

9Events: when something happens

An event is something that happens, like a click or a key press, and an event handler is the script that runs when it does. Shown with Scratch blocks.

eventevent handlerScratchbeginner
0:58

10Loops: repeat instead of copy

A loop repeats blocks so you do not copy and paste them. Repeat, forever, and drawing shapes with a loop, shown with Scratch blocks.

looprepeatforeverScratchbeginner
1:08

11Variables: a named box for a value

A variable holds a value under a name, and the value can change. Score, set and change, and what score = score + 1 means.

variablevaluescoreScratchbeginner
1:01

12Conditions: if and else

A condition is a true or false question. If runs blocks when it is true, else runs when it is false. A fork in the road, with an umbrella or a hat.

conditionifelsebooleanScratchbeginner
1:10

13Functions: name a group of blocks

A function is a named group of blocks you define once and call many times. Define, call and parameter, with a draw-a-square function.

functioncallparameterMy BlockScratchbeginner
1:13

14Bugs and debugging

A bug is a mistake in a program. Debugging is finding it and fixing it: predict, run, compare, fix, shown on a square that does not close.

bugdebuggingpredictScratchbeginner
1:38

15From Scratch to JavaScript

The same six ideas in blocks and in text: sequence, variable, condition, loop, function and event, plus what syntax and the console are.

JavaScriptsyntaxconsoleScratchbeginner

Part 4 · HTML and CSS

1:21

16What is HTML?

HTML describes the content of a web page with elements: an opening tag, content and a closing tag. The page skeleton, head and body, and nesting.

HTMLtagelementheadbodybeginner
1:35

17Links, images and lists

Attributes add information to a tag: href for links, src and alt for images. How a relative path finds a file, and how ul, ol and li make lists.

attributehrefsrcpathHTMLbeginner
1:22

18What is CSS?

CSS styles a web page. A rule is a selector, a property and a value, and a link tag joins the style.css file to the HTML page.

CSSselectorpropertyvaluerulebeginner
1:13

19The box model

Every element is a box with four layers: content, padding, border and margin. How each one is set with CSS, and what changes when you change a number.

box modelpaddingbordermarginCSSbeginner
1:22

20DevTools: inspect and fix

Right click and Inspect: the Elements tab, the Styles panel, live edits that vanish on refresh, and the Console for finding errors.

DevToolsinspectconsoledebuggingbeginner
1:16

21Classes and ids

A class is a name many elements can share, an id belongs to one element. The dot and hash selectors, and div and span as plain containers.

classidselectordivspanCSSbeginner
1:16

22Flexbox

Line up elements with display: flex. Flex container and flex items, justify-content, align-items, gap, flex-wrap and flex-direction.

flexboxflex containerjustify-contentalign-itemsCSSbeginner
1:18

23Responsive design

Make a page fit any screen: the viewport meta tag, flexible sizes with percentages and max-width, and a media query that stacks the cards on narrow screens.

responsivemedia queryviewportCSSbeginner

Part 5 · JavaScript in the browser

1:26

24What is Git?

Git remembers every saved version of a folder. Repository, commit, and the four first commands: git status, add, commit and log.

Gitrepositorycommitversion controlbeginner
1:24

25The DOM

The DOM is the tree of nodes the browser builds from your HTML. Find a node with document.querySelector and change it with textContent.

DOMquerySelectortextContentJavaScriptbeginner
1:19

26Events in the browser

An event is something that happens on the page. addEventListener waits for it and runs a handler function, shown next to the same idea in Scratch.

eventaddEventListenerhandlerJavaScriptbeginner
1:18

27Changing the page

Toggle a class with classList so CSS restyles an element, and build new elements with createElement and append, like a to-do list adding tasks.

classListcreateElementappendDOMJavaScriptbeginner
1:15

28Arrays and objects

An array is a numbered list, an object is a set of labelled values. An array of objects and a loop turn data into cards.

arrayobjectpropertyloopJavaScriptbeginner
1:24

29Local storage and JSON

localStorage is the browser's notebook for your site. JSON.stringify turns an array or object into text to save, and JSON.parse turns it back.

localStorageJSONstringifyparseJavaScriptbeginner
1:26

30Fetch and JSON

The browser is the client and fetch sends the request. The server answers with JSON, async and await wait for it, and the Network tab shows what happened.

fetchJSONasyncawaitAPIbeginner
1:16

31Debugging JavaScript

Find bugs in JavaScript: console.log to look, reading an error message and its line, and a breakpoint to pause and step through code in DevTools.

debuggingconsole.logbreakpointerrorDevToolsbeginner

Part 6 · Go basics

1:38

32What is Go?

Go is a compiled language: the compiler turns main.go into a program and checks it before it runs. go run, go build, and the three parts of a first program.

Gocompilergo rungo buildbeginner
1:26

33Variables and types

In Go every variable has a fixed type: int, float64, string or bool. var and :=, why the compiler rejects the wrong type, and zero values.

Govariabletypeintstringbeginner
1:19

34If, for and switch

Decisions and loops in Go: if and else without brackets, the three shapes of for (counted, condition, forever), and switch, next to the same ideas in Scratch.

Goifforswitchloopbeginner
1:20

35Slices and maps

A slice is a growing list of one type (append, len, range) and a map connects keys to values (delete, and the comma ok check).

Goslicemaprangeappendbeginner
1:17

36Structs and methods

A struct groups named, typed fields into your own type, a method is a function that belongs to a type, and a pointer receiver changes the real value instead of a copy.

Gostructmethodpointertypebeginner
1:16

37Errors in Go

A function that can fail returns an error as a second value. nil means success, and you check it with if err != nil, instead of an error jumping out like in JavaScript.

Goerrornilstrconvbeginner
1:18

38Testing in Go

A test is a small program that checks your code. _test.go files, Test functions, go test with PASS and FAIL, and table tests with many cases.

Gotestgo testtable testdebuggingbeginner
1:21

39Packages and modules

A package is a folder of Go files, a module is the whole project (go mod init, go.mod), how import works, and why a capital letter makes a name visible.

Gopackagemoduleimportgo modbeginner

Part 7 · Go backend

1:23

40How a web server works

A web server waits on a port for requests and sends responses. Handlers, http.HandleFunc and ListenAndServe, and seeing the request in the browser.

Goserverporthandlerhttpbeginner
1:30

41Routes, methods and status codes

A route connects a path and a method to a handler. GET, POST and DELETE, the status codes 200, 201, 400, 404 and 500, and how Go answers 404.

GorouteGETPOSTstatus code404beginner
1:19

42A JSON API in Go

An API returns data instead of pages. A Go struct becomes JSON with struct tags, a handler writes it with json.NewEncoder, and the page loads it with fetch.

GoAPIJSONstruct tagfetchbeginner
1:21

43POST and saving data

A POST request carries data in its body. Decode the JSON into a struct, keep it in a slice (lost on restart), and protect the shared slice with a mutex.

GoPOSTrequest bodymutexJSONbeginner
1:17

44What is a database?

A database keeps data in tables of rows and columns, like a strict spreadsheet. Primary keys, why data in a file survives a restart, and asking questions with SQL.

databasetablerowprimary keySQLbeginner
1:01

45SQL basics

SQL is the language for asking a database: CREATE TABLE, INSERT INTO, SELECT with WHERE and ORDER BY, then UPDATE and DELETE (always with WHERE).

SQLSELECTINSERTWHEREdatabasebeginner
1:14

46Go and databases

Go talks to a SQLite database with database/sql and a driver. Exec changes data, Query reads rows into structs, and ? placeholders pass values safely.

Godatabase/sqlSQLiteQueryExecplaceholderbeginner
1:20

47Input, validation and safety

Never trust a request: validate empty and too-long values and answer 400, why ? placeholders stop SQL injection, and keep secrets and database files out of Git.

GovalidationSQL injectionsafetygitignorebeginner