Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Programming Shortcut

You know more than you think.

If you have written programs in one language, any language, you already have most of what every other language is made of. You know how to name a value and change it later. You know how to make a decision, repeat something, and wrap a piece of work in a function so you can call it again. You have probably had a function call itself and watched it work, which still feels a little like magic the first few times.

That knowledge is the shortcut. Not a shortcut in the sense of cutting corners or skipping the hard parts, but the oldest shortcut there is: using what you already know to get somewhere new faster.

Most programming tutorials don’t take it. They start every language from zero, as if you had never seen a loop, and spend the first hour on things you could explain to them. Then, right when the language gets interesting, they run out of room.

This series goes the other way. It skips what you know, and spends its time on the part you don’t.

One language, one idea

Each article in The Programming Shortcut is about one programming concept, taught through one language that happens to be especially good at teaching it. Rust is the best place to learn about ownership, because its compiler won’t let you ignore it. Go is a lovely place to learn about programs that do several things at once. PHP makes it obvious what “request and response” means, because a PHP page lives for one request and then forgets everything.

So the articles aren’t language tutorials. There are excellent complete tutorials for every language here, written by the people who make those languages, and each article points you to them at the end. What you get here is the one idea the language does best, taught as a programming idea, with the language as the vehicle. When you finish an article you should understand the concept well enough to spot it in a language you haven’t met yet.

The articles are short on purpose. Each one is meant to be read in a single sitting, with a terminal or a browser open beside it.

And you can start anywhere. No article depends on another one. Read the one whose concept you’re curious about, skip the ones you’re not, come back later, or never. When an article uses an idea that another article teaches, it explains it in a sentence and links there, so you can keep reading without a detour, or take the detour if you like.

What you already know

Every article assumes you know these, from any language:

IdeaYou might know it as
Variableslet, var, const, int x =, x =
Conditionalsif, else, switch
Loopsfor, while, repeat
Functionsfunc, fn, def, function, methods
Recursiona function that calls itself
Arrayslists, slices, vectors, [1, 2, 3]
Recordsstructs, objects, data class, a bundle of named fields

None of these are taught again. If an article needs one, it names it and moves on. That is not a judgment about how hard these ideas were to learn. They were hard, and you learned them, and now they belong to you in every language you will ever use.

If a row on that list is new to you, that’s fine too. Learn it in the language you already have, then come back. The series will still be here.

The shortcut tables

Near the top of each article is a small table that shows what carries over. It looks something like this:

What you knowluxGo
a structstructstruct
a value that might be missingOptionthe zero value, or nil
errors you expectResulta value, err pair

Read it row by row. The left column is the idea. The other columns show how two languages spell it. When a row looks the same in both columns, you can stop thinking about it. When a row looks different, that’s where the article will slow down.

The lux column is there because this series grew out of lux, a small language made for learning to program (more at anderix.com/lux). If you learned lux first, the column is your shortcut. If you learned Python, or Java, or something else entirely, read the left column and fill in your own language from memory. You won’t need lux for anything in this series. It’s one starting point among many.

The question every language answers

Here is a question that sorts programming languages more cleanly than almost any other, and that most people never think to ask: when are types checked?

A type is the kind of value something is: a number, a piece of text, a true or false. Every language has types. What differs is when the language notices that you used the wrong one. Some notice before your program runs at all. Some notice the moment the wrong line actually runs. And some never notice, and do their best with what you gave them.

The easiest way to see the difference is to make the same mistake in several languages and watch what each one does about it.

Here is the mistake. A function that expects text gets a number instead. And the mistake is hidden inside a branch that doesn’t run, because the score is 75 and the branch only runs above 100:

func shout(text: string) -> string {
    return text + "!"
}

let score = 75
if score > 100 {
    print(shout(42))
}
print(shout("done"))

Run that with lux run and lux refuses. It reads the whole program before running any of it, including the branch that would never run, and it stops at the mistake:

error: `shout` expects `text` to be string, but got int
  --> score.lux:7:17

TypeScript does the same, and its checker, tsc, reports the mistake before anything runs:

function shout(text: string): string {
  return text + "!";
}

const score = 75;
if (score > 100) {
  console.log(shout(42));
}
console.log(shout("done"));
score.ts(7,21): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.

Now the same program in three more languages. Each of these runs happily and prints done!:

<?php
declare(strict_types=1);
function shout(string $text): string {
    return $text . "!";
}

$score = 75;
if ($score > 100) {
    echo shout(42), "\n";
}
echo shout("done"), "\n";
def shout(text: str) -> str:
    return text + "!"

score = 75
if score > 100:
    print(shout(42))
print(shout("done"))
function shout(text) {
  return text + "!";
}

const score = 75;
if (score > 100) {
  console.log(shout(42));
}
console.log(shout("done"));

The mistake is still there in all three. Nobody looked at it yet. So change the score to 150, so that the branch runs, and look again.

PHP stops with a TypeError the moment it reaches the line: shout() was promised a string and got an int. PHP checks the types you declare, but only when the line actually runs. (That declare(strict_types=1) line matters. Without it, PHP quietly turns 42 into “42” and carries on.)

Python stops too, but look at what it complains about: unsupported operand type(s) for +: 'int' and 'str'. It never checked the text: str in the function’s first line. That annotation is a type hint, a note for people and for outside tools, and the language itself doesn’t enforce it. Python failed only because adding a number to a piece of text made no sense.

JavaScript doesn’t stop at all. It prints 42! and then done!, because it was happy to turn the number into text for you. Nothing checked the type, because plain JavaScript has no way to say what type text should be.

LanguageWhen types are checked
luxbefore running, every branch
TypeScriptbefore running, by tsc; then the types are erased and plain JavaScript runs
PHPat runtime, when the line actually runs
Pythonnever by the language; only by outside tools such as mypy
JavaScriptnever

Checking before running is called static checking. Checking while running is dynamic checking. Neither is the right answer. A language that checks everything up front catches mistakes in code you haven’t tested yet, and it asks you to say more about your types in return. A language that checks late or never lets you write less and try things faster, and it trusts you to test every branch. Many of the articles in this series live somewhere on that line, and most of them will tell you where.

Hints that answer back

Every article closes with a hint: one small thing to do, not read, that sends you into the language’s own tools. A compiler that explains its error messages. A shell where you can type one line at a time and see what happens. The manual that came with the language and has been on your disk since you installed it.

The idea is that by the end of an article, the language itself becomes your teacher. The hint gives you your first question to bring it.

Each article also has a small project, and every project file ends with a comment block called “Try this next…”: more hints, going further than the article did. If you open the file, you will find more than the article showed you.

The articles

Each article teaches one concept, through the language that teaches it best.

ArticleThe concept
RustOwnership and borrowing, enforced by the compiler
SwiftProtocols and generics: describing what a type can do
GoConcurrency by message passing: goroutines and channels
DartUI as a function of state, plus async
KotlinStructured concurrency: coroutines, scopes and cancellation
C#Value and reference semantics: what a variable actually holds
JavaNull and exceptions: defensive programming without a safety net
CMemory: how data lives in the machine, and the structures built on it
C++Ownership and resource lifetime, by convention
PythonStanding on libraries: using other people’s code, and duck typing
JavaScriptEvent-driven programming: code that waits for things to happen
TypeScriptStatic checking as a tool you choose
PHPRequest and response: stateless programs on a server

Three more pieces cover working habits rather than language ideas, so they aren’t tied to any one language:

PieceThe concept
TestingWriting code that checks your code
DebuggingFinding out what a program is actually doing
Version controlSaving, comparing and undoing your work

Where each concept lives

When an article uses a concept it doesn’t teach, it links to the article that does. This is the map those links follow.

ConceptTaught inAlso appears in
Ownership and borrowing, enforcedRustC++, C
Ownership and resource lifetime, by conventionC++Rust, C
Memory, pointers and data structuresCC++, Rust
Protocols, interfaces and genericsSwiftGo, Kotlin, Java, C#
Concurrency by message passingGoKotlin
Structured concurrency and cancellationKotlinGo
UI as a function of stateDartSwift, Kotlin
Value and reference semanticsC#Swift, C
Null and exceptionsJavaKotlin, C#, Dart
Standing on libraries, duck typingPythonJavaScript, PHP
Event-driven programmingJavaScriptDart
Static checking as a choice, type erasureTypeScriptPython, PHP
Request and response, stateless serversPHPJavaScript
TestingTestingRust, Go
DebuggingDebuggingC
Version controlVersion control

A few smaller ideas turn up in many articles without being the main subject of any. Each has one home where it gets its fullest explanation:

ConceptHomeAlso appears in
Values that might be missing (Option)RustJava, Kotlin, Swift, Dart
Errors as values (Result)RustJava, Go
Enums that carry data (sum types)RustSwift, Kotlin, TypeScript, C#
Exhaustive matchingRustSwift, TypeScript, C#, Kotlin
async and awaitJavaScriptDart, C#
When types are checkedthis introductionPython, JavaScript, TypeScript, PHP

If you’d like a path

No order is required, but some articles make good neighbors. If one of these themes interests you, here is a route through it:

PathRoute
OwnershipC, then C++, then Rust: no ownership, then ownership by convention, then ownership the compiler enforces
The web“HTML is easy!”, then JavaScript, TypeScript and PHP
ConcurrencyGo and Kotlin, in either order
Values and typesC#, then Swift
AppsDart, Kotlin and Swift

Try it yourself

Take the shout program and write it in the language you know best. Run it with a score of 75, then with 150. Before each run, guess what will happen.

Whatever your language does, you now know where it sits on the line between checking early and checking never. That’s one question you can ask of every language you meet from here on, and you just answered it for your own.

Tested with lux 0.21.2, TypeScript 7.0.2, Node.js 26.13.1, Python 3.13.5 and PHP 8.4.28, November 2026.