# Chapter 13. Programming Fundamentals in the AI Era: TypeScript and Python (/building-ai-workers/programming-fundamentals/overview)

---
type: Document
title: "Chapter 13. Programming Fundamentals in the AI Era: TypeScript and Python"
description: "Read, predict, run, test and change the code a coding agent wrote, in TypeScript and Python: values and types, decisions and loops, functions, lists and dictionaries, text, dates and files, errors, tests first, and judgment."
status: stable
order: 313
ksor:
  owner: team:panaversity
  audience: [ public ]
  approval:
    by: process:panaversity
    at: 2026-11-02T13:55:25Z
chapter: "13"
part: III
expert_status: builder-only
objectives:
  - { id: CCDV-F.D2.S4, label: supporting }
  - { id: CCDV-F.D5.S2, label: supporting }
word_budget: 10000
prerequisites: [ "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" ]
build_step: "A tested due-date calculator in TypeScript and in Python, written tests first and generated by a coding agent, a reconciliation script, then one tests-first change ported to Codex and OpenCode"
artifact: "brightline-ap with tsconfig.json, py/pyproject.toml, src/due-date.ts and py/brightline_ap/due_date.py with their tests, the reconciliation script, NOTES.md and ports/ch13.md, branches weekend-tests, port-codex and port-opencode, tag ch13"
lab_data: "https://github.com/panaversity/agentfactory-v2-resources/releases/latest/download/brightline-lab-ch13.zip"
field_guides: [ "E.code-toolchain" ]
delta_entries: []
concepts: [ "13.1", "13.2", "13.3", "13.4", "13.5", "13.6", "13.7", "13.8", "13.9", "13.10", "13.11" ]
last_verified: 2026-10-30
generated:
  at: 2026-11-02T13:55:25Z
  by: process:panaversity
trust_tier: unverified
build_id: sha256:e1fbcb7d9a8f8b9b7cb96875022325c02c9ba4be94cef13b301cbd39a9edad85
dirty: true
ksor_version: 0.0.60
---

## The point

**If the agent writes all the code, why learn to read it?** Because you answer for what the code does. Code that runs and matches your check can still be wrong, as Renee's script below was. Reading it is how you find out.

**What is left for me to do?** Decide what the code must do, and show that it does it. Before the agent starts, you list the cases, such as an invoice dated January 31 on Net 30 terms, and the answer each must give, like an answer key. The agent turns your list into tests, and writes code until they pass.

**When can I trust the agent's code?** When a run or a test gives the answers you expected, not when the agent says it works. Your check is enough for code that runs once, if a mistake would cost little. For code that handles money, or runs again next week, also read the lines that decide the result.

**The rule for every number.** In this book, every calculation, such as a due date, a total or a weekend rule, is done by tested code that gives the same answer every time. An AI worker never does the arithmetic in its reply ([13.5](functions.md)).

After this chapter you can read a short TypeScript or Python program that a coding agent wrote, and say what it will do before you run it. With the agent, you can run it and its tests, read the error it prints when it breaks, and change it.

TypeScript comes first in each concept, because Brightline's scripts are written in it. Python comes next, because much of the code you will meet later, in data work and evaluation, is Python. Readers who want only Python can follow the Python blocks and skip the TypeScript ones.

## Why it matters

Renee manages the office of a building-supply company in Toledo, Ohio. On Monday she asks a coding agent for a script that lists the invoices past due, largest first. She wants to call the biggest vendors before lunch. The script runs on the first try. Its output looks neat, and the top line is a $618.75 invoice from a cleaning supplier. Renee calls them, apologizes, and calls the next one on the page.

The largest invoice, $12,900.00 from a freight company, is near the bottom. The export gives each amount in whole cents, so $12,900.00 is 1290000. The script read the amounts from the export as text, and it sorted them as text. As text, "1290000" comes before "61875", because the first character "1" comes before "6". In the same way, "apple" comes before "banana". So a largest-first sort of the text put "61875" on top. Nobody at Renee's company read the script, and nobody compared the order with the export. On Thursday the freight company stops working with them until it is paid, so Friday's deliveries do not come.

The agent did not fail at writing. It wrote a program that ran. Now suppose Renee had written a check first: from the export, how many invoices are past due, and their total. The output would have matched it. Every invoice was there, and the total was right. Only the order was wrong, and a count and a total cannot see order. So when the check matches and the tests pass, what can reading the code still catch?
