AI → Full-Stack

🌐 This lesson is available in Chinese only for now. English and German translations are planned for Week 46.

Day 3 - Stream and Buffer: The Pipes and Buckets of Backend

📇 Concept Card #1: Buffer — A Standard Transfer Bucket

A fixed-size chunk of memory. Can hold bytes, convert between encodings (UTF-8, Base64). Think of a box that fits exactly 16 items, no more, no less.

📇 Concept Card #2: Stream — An Assembly Line, Not a Dump Truck

Don't load a 2GB file into memory. Stream it: read chunk, process, discard, repeat. Memory stays constant. Readable, Writable, Transform, Duplex.

backpressure: When the Pipe Gets Clogged

write() returns false = "stop sending, I'm full". Pause the source. Resume when drain event fires. Do this wrong and you crash: 2GB file → memory explosion.

pipe() vs pipeline()

pipe() is the classic chaining. pipeline() (since Node 10) handles errors better. Use pipeline() in new code.