browse/
40 results
languages/javascript-closures-how-a-function-remembers-a-variable-after-the-func.md
JavaScript closures: how a function remembers a variable after the function that made it has finished
A function in JavaScript can still use a variable long after the function that created it has finished. That is called a closure, and you…
computer-science/coin-change-why-grabbing-the-biggest-coin-first-can-fail-and-how-a-tab.md
Coin change: why grabbing the biggest coin first can fail, and how a table fixes it
A cashier owes 6 cents and has coins worth 1, 3 and 4. Grabbing the biggest coin first uses three coins, but two 3s do it in two. This…
computers/deadlock-how-two-programs-can-wait-for-each-other-forever.md
Deadlock: how two programs can wait for each other forever
Two threads each hold one lock and wait for the other's. Neither can move, and the program just freezes without an error. This is a…
languages/ruby-blocks-how-a-method-borrows-a-piece-of-your-code-and-runs-it-with.md
Ruby blocks: how a method borrows a piece of your code and runs it with yield
Ruby code is full of curly-brace chunks like `list.each { |x| ... }`. Who runs that chunk, and when? This article follows a block from the…
networks/udp-why-a-video-call-skips-a-lost-piece-instead-of-waiting.md
UDP: why a video call skips a lost piece instead of waiting
Why does a video call skip a moment instead of freezing until the missing piece turns up? Because it uses UDP, a protocol that sends…
computers/virtual-memory-why-two-programs-can-use-the-same-address-without-clash.md
Virtual memory: why two programs can use the same address without clashing
Two programs can both use "address 4096" without ever touching each other's data. The trick is that the addresses a program sees are…
languages/reference-counting-how-python-knows-when-to-throw-an-object-away.md
Reference counting: how Python knows when to throw an object away
You never tell Python to free memory, yet unused objects disappear. How does it know when one is finished with? CPython keeps a tally on…
mobile/dropped-frames-why-one-slow-function-freezes-a-phone-screen.md
Dropped frames: why one slow function freezes a phone screen
You tap a button and your phone screen freezes for a moment, even though the app did not crash. The reason is that one thread both listens…
security/cross-site-scripting-how-a-comment-box-can-run-someone-else-s-code.md
Cross-site scripting: how a comment box can run someone else's code
A comment box looks harmless until someone types a tiny program instead of a comment. This article explains cross-site scripting, or XSS…
computers/fetch-decode-execute-the-three-beat-loop-every-cpu-repeats-billions-of.md
Fetch, decode, execute: the three-beat loop every CPU repeats billions of times a second
A processor looks clever, but at its core it repeats one small loop billions of times a second: fetch an instruction, decode what it asks…
languages/generators-how-a-python-function-can-pause-in-the-middle-and-pick-up-w.md
Generators: how a Python function can pause in the middle and pick up where it left off
A generator is a Python function that can pause halfway, hand you a value, and carry on later from the same line with its variables intact…
ai/tokens-how-a-chatbot-cuts-your-text-into-pieces-before-it-reads-a-word.md
Tokens: how a chatbot cuts your text into pieces before it reads a word
A chatbot never sees your letters. Before it reads anything, a small program called a tokenizer cuts the text into pieces and gives each…