Sunday, July 26, 2026

How Garbage Collection Works — LearningTechBasics

LT LearningTechBasics @amtocbot

How Garbage Collection Works

How your language frees memory you forgot to.

📅 2026-07-26⏱️ ~6 min read🏷️ Systems · Languages

In managed languages you allocate memory but rarely free it. A garbage collector figures out which objects are still reachable and reclaims the rest — automatically, while your program runs.

Legend — how to read this diagram

Activehighlighted cell is currently selected
1 2 3Walkthroughnumbered steps below run in order

Finding what's garbage

  1. Roots. Start from things definitely alive: globals, stack variables, CPU registers.
  2. Mark. Follow every reference from the roots, marking each object you can reach.
  3. Sweep. Anything unmarked is unreachable — free it.
  4. Compact (optional). Slide survivors together to defragment and speed future allocation.

Why generational GC is common

Most objects die young. So collect the young generation often and cheaply.

Promote survivors. Objects that live long move to an old generation collected rarely.

Pauses vs throughput. Concurrent collectors trade a bit of speed for shorter pauses.

One-line mental model:

If nothing can reach an object, the program can never use it again — so it's safe to reclaim.

Saturday, July 25, 2026

How an HTTP Request Works — LearningTechBasics

LT LearningTechBasics @amtocbot

How an HTTP Request Works

What actually happens between typing a URL and seeing a page.

📅 2026-07-25⏱️ ~5 min read🏷️ Networking · WebDev

Loading a web page is a relay of protocols stacked on each other. Peeling them apart shows exactly why a slow site is slow — and where the time actually goes.

Legend — how to read this diagram

1–nStagesthe ordered steps of the process
1 2 3Walkthroughnumbered steps below run in order

The full pipeline

  1. DNS. Resolve the hostname to an IP address.
  2. TCP. Open a reliable connection with the three-way handshake.
  3. TLS. Negotiate encryption if the URL is HTTPS.
  4. Request. Send a method, path, and headers (GET /index.html).
  5. Response. The server returns a status code, headers, and body.
  6. Render. The browser parses HTML, fetches assets, and paints pixels.

Where the time goes

Round trips dominate. Each handshake is a full trip; HTTP/2 and HTTP/3 cut them down.

Status codes tell the story. 2xx success, 3xx redirect, 4xx your fault, 5xx server's fault.

Caching short-circuits it. Cache headers can skip most of the pipeline on repeat visits.

One-line mental model:

A web request is a stack of protocols, each solving one problem — name, connection, encryption, content, pixels.

Friday, July 24, 2026

How Database Indexes Work — LearningTechBasics

LT LearningTechBasics @amtocbot

How Database Indexes Work

Why one line of SQL can turn a 3-second query into 3 milliseconds.

📅 2026-07-25⏱️ ~6 min read🏷️ Databases · Performance

Without an index, finding a row means scanning every row. An index is a sorted, tree-shaped copy of a column that lets the database jump to matches in logarithmic time.

Legend — how to read this diagram

0–nDepthlevels from the root downward
1 2 3Walkthroughnumbered steps below run in order

The B-tree behind most indexes

  1. Sorted structure. Keys are kept in order across a balanced tree of pages.
  2. Log-time search. Each step halves the search space, so millions of rows take only a handful of hops.
  3. Range-friendly. Because keys are sorted, BETWEEN and ORDER BY come nearly free.
  4. Points to rows. Leaves hold pointers (or the row itself) so the engine fetches only what matches.

The cost of indexes

Writes get slower. Every insert/update must also update each index.

They use space. An index is a second copy of the indexed columns.

Order matters. A composite index on (a, b) helps queries on a, or a+b — but not b alone.

One-line mental model:

An index trades some write speed and disk for enormous read speed — a pre-sorted map to your data.

How Load Balancers Work — LearningTechBasics

LT LearningTechBasics @amtocbot

How Load Balancers Work

One address, many servers — and the user never notices.

📅 2026-07-24⏱️ ~5 min read🏷️ Systems · Scalability

A single server has a ceiling. A load balancer sits in front of a pool of servers, spreading incoming requests so no one machine is overwhelmed and any can fail without taking the site down.

Legend — how to read this diagram

A–DComponentsthe parts involved, labelled in the diagram
Requestdata travelling outward
Responsedata returning
1 2 3Walkthroughnumbered steps below run in order

How it decides where to send you

  1. Round robin. Rotate through servers in order — simple and even when requests are similar.
  2. Least connections. Send to whichever server is handling the fewest active requests.
  3. Hashing. Route by a key (like client IP) so a user keeps hitting the same backend.
  4. Health checks. Continuously probe servers; pull unhealthy ones out automatically.

Layer 4 vs Layer 7

L4. Balances by IP and port — fast, protocol-agnostic, no visibility into the request.

L7. Reads HTTP, so it can route by path or header, terminate TLS, and cache.

Sticky sessions. Pin a user to one server when state lives there, at the cost of even spread.

One-line mental model:

Put one smart doorway in front of many workers, and you get scale and fault tolerance for free.

How Public-Key Cryptography Works — LearningTechBasics

LT LearningTechBasics @amtocbot

How Public-Key Cryptography Works

One key locks, a different key unlocks — and that changes everything.

📅 2026-07-24⏱️ ~6 min read🏷️ Security · Cryptography

Symmetric encryption needs both sides to already share a secret. Public-key crypto breaks that chicken-and-egg problem with a mathematically linked key pair — one you publish, one you keep.

Legend — how to read this diagram

A · BPartiesthe two sides of the exchange
1–nOrdereach message, numbered in sequence
1 2 3Walkthroughnumbered steps below run in order

Two superpowers

  1. Encryption. Anyone encrypts a message with your public key; only your private key can open it.
  2. Signatures. You sign with your private key; anyone verifies with your public key that it was really you.
  3. Key exchange. Two parties can derive a shared secret over an open channel (Diffie–Hellman).
  4. Trust. Certificates bind a public key to an identity, vouched for by a signature.

Why it's hard to break

Trapdoor functions. Easy one way (multiplying primes), infeasible the other (factoring the product).

Key size vs. speed. RSA needs big keys; elliptic-curve crypto gets the same strength with far smaller ones.

Slow by design. Used to bootstrap a fast symmetric key, not to encrypt bulk data directly.

One-line mental model:

Separate the ability to lock from the ability to unlock, and strangers can exchange secrets in the open.

Thursday, July 23, 2026

How CPU Caches Work — LearningTechBasics

LT LearningTechBasics @amtocbot

How CPU Caches Work

Why the same loop can run 10× faster depending on memory order.

📅 2026-07-23⏱️ ~6 min read🏷️ Systems · Performance

Your CPU is far faster than your RAM. Caches — small, fast memories close to the core — bridge the gap by keeping recently and soon-to-be-used data nearby.

Legend — how to read this diagram

A–EComponentsthe parts involved, labelled in the diagram
1 2 3Walkthroughnumbered steps below run in order

The memory hierarchy

  1. Registers. A few dozen slots inside the core, accessed in a single cycle.
  2. L1/L2. Per-core caches, kilobytes to a megabyte, a handful of nanoseconds away.
  3. L3. Shared across cores, several megabytes, slower but still far faster than RAM.
  4. RAM. Gigabytes, but ~100× slower than L1 — a cache miss stalls the core.

Writing cache-friendly code

Locality wins. Data fetched in 64-byte cache lines; touching neighbors is nearly free.

Iterate in memory order. Row-major arrays should be traversed row by row, not column by column.

Compact structures. Smaller, contiguous data fits more per line and misses less often.

One-line mental model:

Speed isn't just how many operations you do — it's how far the data had to travel to reach the core.

How Git Stores Your History — LearningTechBasics

LT LearningTechBasics @amtocbot

How Git Stores Your History

Not diffs — a tree of snapshots addressed by their own hash.

📅 2026-07-23⏱️ ~6 min read🏷️ Tools · Version Control

Most people picture Git storing the changes between versions. It actually stores full snapshots, each addressed by a SHA hash, linked into a chain — which is why it's so fast and so hard to corrupt.

Legend — how to read this diagram

0–nDepthlevels from the root downward
1 2 3Walkthroughnumbered steps below run in order

The four objects

  1. Blob. The raw contents of a file. Identical files anywhere share one blob.
  2. Tree. A directory listing: names pointing to blobs and other trees.
  3. Commit. A snapshot: a pointer to one tree, parent commit(s), author, and message.
  4. Tag. A named pointer to a specific object, usually a release.

Why hashing everything matters

Content addressing. An object's name is the hash of its content, so identical content is stored once and corruption is detectable.

Cheap branches. A branch is just a 40-character pointer to a commit — creating one writes a tiny file.

Integrity. Each commit's hash includes its parent's, so history can't be altered without changing every hash after it.

One-line mental model:

Git is a content-addressed filesystem: name everything by its hash, and history becomes a tamper-evident chain of snapshots.

AI as Infrastructure: Value Moves Up-Stack

For a few years the AI conversation was about who had the biggest model. That is the wrong altitude now. Models still matter, the way CPUs s...