<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged get</title>
<link>https://coderlegion.com/tag/get</link>
<description>Powered by Question2Answer</description>
<item>
<title>The Silent Enclosure: Stealing the Light</title>
<link>https://coderlegion.com/25460/the-silent-enclosure-stealing-the-light</link>
<description>
&lt;h3&gt;
  
  
  Pushed Out by the Shadows
&lt;/h3&gt;

&lt;p&gt;For almost seven months now I have blinked less than the crippled, cramped fingers I count on my tired hands. I have howled so loud that even the sheep ignore me when I howl at the largest light in the room. &amp;ldquo;That's mine &amp;mdash; I deserve a part,&amp;rdquo; I say as the light drifts away and covers me in its thick, worldly shadow, just to be forgotten like the sheep I can no longer eat or see because they think me weak, crazy, delusional, and band together, pushing the lone wolves out just to get their take.&lt;/p&gt;

&lt;p&gt;Google invited me in, then slammed the Nexus 26 closed when my spirits rose. I watched them gawk with glee, throwing money and tech around, colliding and pointing and whispering while I watched: &amp;ldquo;You get this part, you get that part, I&amp;rsquo;ll take this part, and together we&amp;rsquo;ll crush them all.&amp;rdquo; I wasn&amp;rsquo;t crazy &amp;mdash; it happened right in front of our eyes for six months. Google and Microsoft overnight poured insane amounts of money into an industry they had pushed out because it was too centralized, not by the book, &quot;unscripted.&quot;&lt;/p&gt;

&lt;p&gt;Now Coinbase takes my color and my wallet wants to call it a demo. MongoDB and GitHub use my data to fuel the industry so my flame can&amp;rsquo;t burn brighter than theirs. So, I can never keep up: by 2:00 a.m. I make the next big thing; by 2:01 my phone is pinging &amp;mdash; Google released, Microsoft coming out with a new partner of the year, MongoDB, Google Cloud integrating Coinbase. But wait &amp;mdash; it&amp;rsquo;s even bigger now: Google and Microsoft coming together.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;m trying, but now I&amp;rsquo;m homeless, penniless. I have nothing &amp;mdash; not even my shadow dares show itself. I&amp;rsquo;m stranded, pushed out by the shadows who are stealing the light.&lt;/p&gt;




&lt;h3&gt;
  
  
  Gratitude and Resolve
&lt;/h3&gt;

&lt;p&gt;My words are heavy because so is the path I walk, but I have strength and resilience few could fathom and less dream of seeing. I am broken but beyond blessed: I have water to drink, food to eat, shoes on my feet, and clothes on my back. I am too blessed to be stressed. Nothing in this world can stop me, for I am a child of the one true King. I am a King of kings who will walk roads paved with gold and live in houses that sparkle brighter than diamonds. I will rejoice because I know that, and nothing can change it.&lt;/p&gt;




&lt;h3&gt;
  
  
  A Note on Rest
&lt;/h3&gt;

&lt;p&gt;Take care of your body and hands. Rest matters. Tonight, step away from the screens and let your hands and mind recover. Your health and safety come before any platform, code, or company.&lt;/p&gt;




&lt;h3&gt;
  
  
  Closing
&lt;/h3&gt;

&lt;p&gt;I hold on to gratitude for the basics and to the inner resolve that keeps me moving forward. The tech world may feel like it&amp;rsquo;s moving against you, but your voice, your vision, and your faith remain yours. Keep that flame &amp;mdash; tend it, protect it, and let it guide you through the dark.&lt;/p&gt;

&lt;h2&gt;
  
  
  TO ALL, WE ARE &amp;ldquo;Government of the people, by the people, for the people.&amp;rdquo; &amp;mdash; Abraham Lincoln, Gettysburg Address
&lt;/h2&gt;

&lt;p&gt;Authored: NeonCyan0x &amp;middot; DEVPlank &amp;middot; Blade Yerby&lt;/p&gt;
</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/25460/the-silent-enclosure-stealing-the-light</guid>
<pubDate>Wed, 26 Aug 2026 19:07:24 +0000</pubDate>
</item>
<item>
<title>The Mechanics of Compression: How 100GB Becomes 25GB</title>
<link>https://coderlegion.com/14657/the-mechanics-of-compression-how-100gb-becomes-25gb</link>
<description>
&lt;p&gt;&lt;img src=&quot;https://blog.ratnesh-maurya.com/images/blog/The-Mechanics-of-Compression-How-100GB-Becomes-25GB.png&quot; alt=&quot;The Mechanics of Compression: How 100GB Becomes 25GB&quot;&gt;&lt;/p&gt;&lt;h2 id=&quot;the-mechanics-of-compression-how-100gb-becomes-25gb&quot;&gt;The Mechanics of Compression: How 100GB Becomes 25GB&lt;/h2&gt;
&lt;p&gt;In an era of 4K streaming and massive cloud databases, we often take for granted that a 100GB backup can be shrunk down to 25GB. It isn&amp;rsquo;t magic&amp;mdash;and it isn&amp;rsquo;t just &amp;ldquo;squeezing&amp;rdquo; bits. It&amp;rsquo;s a careful process of spotting patterns, removing redundancy, and using mathematical shorthand so that the same information takes less space. This post explains how that works in plain terms, so you can understand what happens under the hood when you zip a folder or stream a video.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;1-the-core-idea-redundancy-is-waste&quot;&gt;1. The Core Idea: Redundancy Is Waste&lt;/h2&gt;
&lt;p&gt;At its heart, compression is about &lt;strong&gt;efficiency&lt;/strong&gt;. Most data is repetitive. The same words, phrases, or pixel patterns show up again and again. If the computer has already seen a pattern once, it doesn&amp;rsquo;t need to store it again in full&amp;mdash;it can refer back to it or describe it in fewer bits.&lt;/p&gt;
&lt;p&gt;Think of a recipe that says &amp;ldquo;add salt&amp;rdquo; five times. You could write &amp;ldquo;add salt&amp;rdquo; five times, or you could write &amp;ldquo;add salt (&amp;times;5).&amp;rdquo; The second version carries the same information in less space. Compression algorithms do something similar: they find repetition and describe it more compactly.&lt;/p&gt;
&lt;p&gt;So the main job of any compression scheme is to &lt;strong&gt;find redundancy&lt;/strong&gt; and &lt;strong&gt;encode it in fewer bits&lt;/strong&gt; without losing the ability to recover the original data when needed.&lt;/p&gt;
&lt;h3 id=&quot;a-real-life-example-compressing-a-book-with-repeated-words&quot;&gt;A Real-Life Example: Compressing a Book with Repeated Words&lt;/h3&gt;
&lt;p&gt;Imagine a &lt;strong&gt;book&lt;/strong&gt; where the same words appear again and again. Words like &quot;the,&quot; &quot;and,&quot; and &quot;to&quot; might show up thousands of times. Instead of writing the full word every time, we could agree on a &lt;strong&gt;legend&lt;/strong&gt; at the start and replace each repeated word with a short &lt;strong&gt;sub-symbol&lt;/strong&gt;. Anyone with the legend can reconstruct the original text exactly.&lt;/p&gt;
&lt;p&gt;Suppose we define a small dictionary at the top of the page:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-text&quot;&gt;Legend:  @ = the   |   # = and   |   % = to   |   &amp;sect; = of
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now take a normal sentence and &quot;compress&quot; it by substituting:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Original (longer):&lt;/strong&gt;
&quot;The king and the queen went to the castle and stayed there for the rest of the day.&quot;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Compressed (shorter):&lt;/strong&gt;
&quot;@ king # @ queen went % @ castle # stayed there for @ rest &amp;sect; @ day.&quot;&lt;/p&gt;
&lt;p&gt;We still have the same meaning, but we used one character (@, #, %, &amp;sect;) wherever a repeated word appeared. The &lt;strong&gt;legend&lt;/strong&gt; is the &quot;dictionary&quot;&amp;mdash;it has to be stored or sent once so the reader can decode. For a whole book, if &quot;the&quot; appears 2,000 times, we save (3 &amp;minus; 1) &amp;times; 2,000 = 4,000 characters just on that one word. Add &quot;and,&quot; &quot;to,&quot; &quot;of,&quot; and other frequent words, and the book shrinks noticeably without losing a single word.&lt;/p&gt;
&lt;p&gt;This is exactly the idea behind &lt;strong&gt;dictionary coding&lt;/strong&gt; and &lt;strong&gt;Huffman-style&lt;/strong&gt; compression: find what repeats, assign it a short code, and use that code everywhere. Real compressors do this automatically; they don't need a human to write the legend.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A real experiment from the wild:&lt;/strong&gt; Researchers applied this idea to the full text of &lt;strong&gt;&quot;Alice's Adventures in Wonderland&quot;&lt;/strong&gt; by Lewis Carroll. They treated each &lt;em&gt;word&lt;/em&gt; as a symbol, counted how often it appeared, and assigned &lt;strong&gt;shorter codes to the most frequent words&lt;/strong&gt; (like &quot;the,&quot; &quot;and,&quot; &quot;to,&quot; &quot;a&quot;) and &lt;strong&gt;longer codes to rare words&lt;/strong&gt; (like &quot;wretched,&quot; &quot;yawned&quot;). The result: the text went from &lt;strong&gt;164 KB down to 109 KB&lt;/strong&gt;&amp;mdash;about &lt;strong&gt;one-third smaller&lt;/strong&gt;&amp;mdash;with no information lost (&lt;a rel=&quot;nofollow&quot; href=&quot;https://www.nayuki.io/page/huffman-coding-english-words&quot;&gt;&lt;em&gt;Huffman-coding English words&lt;/em&gt;&lt;/a&gt;, Project Nayuki&amp;mdash;includes original text from Project Gutenberg, input/output file sizes, and codebook samples). The same technique&amp;mdash;replace repeated words with shorter symbols, and keep a mapping so we can decode&amp;mdash;is what powers the compression we use every day in ZIP files and beyond.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;2-lossless-vs-lossy-two-different-goals&quot;&gt;2. Lossless vs. Lossy: Two Different Goals&lt;/h2&gt;
&lt;p&gt;Before diving into algorithms, it helps to know that compression splits into two families: &lt;strong&gt;lossless&lt;/strong&gt; and &lt;strong&gt;lossy&lt;/strong&gt;. The choice depends on whether you can afford to lose any information.&lt;/p&gt;
&lt;h3 id=&quot;lossless-compression-every-bit-preserved&quot;&gt;Lossless Compression: Every Bit Preserved&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Lossless&lt;/strong&gt; compression means that after you decompress, you get back &lt;strong&gt;exactly&lt;/strong&gt; the original data&amp;mdash;every bit. Nothing is discarded.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;How it works:&lt;/strong&gt; The algorithm finds statistical redundancy (repeated or predictable patterns) and encodes them more efficiently. Decompression reverses the process and reconstructs the original stream.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;When to use it:&lt;/strong&gt; Whenever you cannot afford to lose information&amp;mdash;source code, text files, databases, executables, legal documents, medical data, or images where every pixel must stay exact (e.g. PNG for graphics, FLAC for audio).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Common formats:&lt;/strong&gt; ZIP, GZIP, PNG, GIF (for lossless use), FLAC.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So when you compress 100GB of source code or logs to 25GB with a lossless tool, you can later decompress and get back the same 100GB bit-for-bit.&lt;/p&gt;
&lt;h3 id=&quot;lossy-compression-smaller-files-imperceptible-loss&quot;&gt;Lossy Compression: Smaller Files, Imperceptible Loss&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Lossy&lt;/strong&gt; compression &lt;strong&gt;discards&lt;/strong&gt; some information on purpose. What you get back is an &lt;strong&gt;approximation&lt;/strong&gt; of the original&amp;mdash;close enough for human perception, but not identical.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;How it works:&lt;/strong&gt; The algorithm keeps what matters for the intended use (e.g. what the eye or ear notices) and drops &amp;ldquo;invisible&amp;rdquo; or less important detail&amp;mdash;e.g. colors we can&amp;rsquo;t easily tell apart, or sounds masked by louder ones.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;When to use it:&lt;/strong&gt; Media where small quality loss is acceptable&amp;mdash;photos (JPEG), music (MP3, AAC), video (H.264, VP9). Streaming and storage would be far heavier without lossy compression.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Common formats:&lt;/strong&gt; JPEG, MP3, AAC, H.264, VP9.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the rest of this post we focus on &lt;strong&gt;lossless&lt;/strong&gt; compression&amp;mdash;the kind that powers ZIP, GZIP, and the 100GB&amp;rarr;25GB backup scenario&amp;mdash;and then briefly touch how &lt;strong&gt;video&lt;/strong&gt; combines similar ideas with lossy temporal compression.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;3-the-building-blocks-huffman-coding-and-lz77&quot;&gt;3. The Building Blocks: Huffman Coding and LZ77&lt;/h2&gt;
&lt;p&gt;Most modern lossless compressors (including the ones inside ZIP and GZIP) combine two ideas:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Dictionary / back-reference coding&lt;/strong&gt; (e.g. LZ77): &amp;ldquo;I&amp;rsquo;ve seen this phrase before; refer back to it.&amp;rdquo;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Entropy coding&lt;/strong&gt; (e.g. Huffman): &amp;ldquo;Frequent symbols get short codes; rare symbols get longer codes.&amp;rdquo;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Together they form algorithms like &lt;strong&gt;DEFLATE&lt;/strong&gt; (used in ZIP and GZIP): first reduce repetition with something like LZ77, then shorten the remaining stream with Huffman (or similar) coding.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;31-huffman-coding-short-codes-for-common-symbols&quot;&gt;3.1 Huffman Coding: Short Codes for Common Symbols&lt;/h3&gt;
&lt;p&gt;In normal text encoding (e.g. ASCII or UTF-8), every character uses the &lt;strong&gt;same&lt;/strong&gt; number of bits (e.g. 8 bits per character). So the letter &amp;ldquo;E&amp;rdquo; and the letter &amp;ldquo;Z&amp;rdquo; both cost 8 bits, even though &amp;ldquo;E&amp;rdquo; appears far more often in English text. That&amp;rsquo;s wasteful: we&amp;rsquo;re spending the same budget on rare and common symbols.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Huffman coding&lt;/strong&gt; fixes that by giving &lt;strong&gt;variable-length&lt;/strong&gt; codes: frequent symbols get &lt;strong&gt;shorter&lt;/strong&gt; codes, rare symbols get &lt;strong&gt;longer&lt;/strong&gt; codes. On average, the whole message uses fewer bits.&lt;/p&gt;
&lt;p&gt;One crucial constraint: no code is allowed to be a &lt;strong&gt;prefix&lt;/strong&gt; of another. So if &amp;ldquo;E&amp;rdquo; is encoded as &lt;code&gt;10&lt;/code&gt;, then no other character&amp;rsquo;s code can start with &lt;code&gt;10&lt;/code&gt; (e.g. no &lt;code&gt;100&lt;/code&gt; or &lt;code&gt;101&lt;/code&gt;). That way, when we read the compressed stream left-to-right, we always know where one symbol ends and the next begins&amp;mdash;no need for extra separators (unlike Morse code, which needs pauses between letters).&lt;/p&gt;
&lt;p&gt;A simple way to build such codes is with a &lt;strong&gt;binary tree&lt;/strong&gt;: each character is a leaf, and the path from the root to that leaf (e.g. left=0, right=1) is its code. The algorithm builds the tree from the &lt;strong&gt;bottom up&lt;/strong&gt;, repeatedly grouping the two least frequent symbols (or groups) until everything is in one tree. Frequent characters end up near the root (short path); rare ones end up deeper (long path).&lt;/p&gt;
&lt;p&gt;Conceptually:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-text&quot;&gt;// Standard 8-bit encoding (e.g. ASCII): every character uses 8 bits
&quot;E&quot; = 01000101 (8 bits)
&quot;Z&quot; = 01011010 (8 bits)

// Huffman encoding (example): frequent letters get shorter codes
&quot;E&quot; = 10      (2 bits)   &amp;larr; common in English
&quot;Z&quot; = 111010  (6 bits)   &amp;larr; rare, so longer code
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So Huffman doesn&amp;rsquo;t &amp;ldquo;invent&amp;rdquo; new information; it &lt;strong&gt;represents&lt;/strong&gt; the same information in fewer bits by exploiting how often each symbol appears.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;32-lz77-ive-seen-this-beforepoint-back-to-it&quot;&gt;3.2 LZ77: &amp;ldquo;I&amp;rsquo;ve Seen This Before&amp;mdash;Point Back to It&amp;rdquo;&lt;/h3&gt;
&lt;p&gt;Huffman only shortens symbols based on frequency. It doesn&amp;rsquo;t remove &lt;strong&gt;repeated phrases&lt;/strong&gt;. That&amp;rsquo;s where &lt;strong&gt;LZ77&lt;/strong&gt; (and family) comes in.&lt;/p&gt;
&lt;p&gt;LZ77 keeps a &lt;strong&gt;sliding window&lt;/strong&gt; of recently seen data. As it reads the input, it looks for the &lt;strong&gt;longest match&lt;/strong&gt; between:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;what&amp;rsquo;s coming next (the &amp;ldquo;look-ahead&amp;rdquo; buffer), and&lt;/li&gt;
&lt;li&gt;what it has already seen (the &amp;ldquo;search&amp;rdquo; buffer).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When it finds a match, it doesn&amp;rsquo;t output the phrase again. Instead it outputs a &lt;strong&gt;back-reference&lt;/strong&gt;: a pair &lt;strong&gt;(distance, length)&lt;/strong&gt; meaning &amp;ldquo;go back &lt;code&gt;distance&lt;/code&gt; bytes and copy &lt;code&gt;length&lt;/code&gt; bytes.&amp;rdquo; The decoder can then reconstruct the phrase from earlier in the stream.&lt;/p&gt;
&lt;p&gt;So the stream becomes a mix of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Literal&lt;/strong&gt; bytes (when there&amp;rsquo;s no useful match), and&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Back-references&lt;/strong&gt; (when a phrase repeats).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-text&quot;&gt;Input:  &quot;The quick brown fox jumps over the quick dog&quot;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        &quot;the quick&quot; appears twice

Compressed idea:
  Literals: &quot;The quick brown fox jumps over &quot;
  Back-reference: (distance=31, length=9)  &amp;rarr; copy 9 bytes from 31 bytes ago
  Literals: &quot; dog&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After this step, the stream has fewer bytes but still contains the same information. Then Huffman (or similar) is applied to that stream to shorten the representation of literals and back-reference pairs&amp;mdash;that&amp;rsquo;s DEFLATE in a nutshell.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;4-zip-vs-targz-same-ideas-different-packaging&quot;&gt;4. ZIP vs. TAR.GZ: Same Ideas, Different Packaging&lt;/h2&gt;
&lt;p&gt;Both ZIP and TAR.GZ use lossless compression (often DEFLATE/GZIP-style), but they &lt;strong&gt;package&lt;/strong&gt; files differently. That difference affects compression ratio and how you can access files.&lt;/p&gt;
&lt;h3 id=&quot;zip-one-file-at-a-time&quot;&gt;ZIP: One File at a Time&lt;/h3&gt;
&lt;p&gt;ZIP compresses &lt;strong&gt;each file separately&lt;/strong&gt; and then puts them in one archive, with a central directory so you can list and extract individual files.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pros:&lt;/strong&gt; &lt;strong&gt;Random access.&lt;/strong&gt; You can extract &lt;code&gt;image_402.jpg&lt;/code&gt; from a 50GB archive without reading or decompressing the rest. Good for browsing and pulling single files.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cons:&lt;/strong&gt; The compressor never looks &lt;strong&gt;across&lt;/strong&gt; file boundaries. If 100 files are nearly identical, ZIP may store 100 separate compressed versions and miss shared patterns. So total size can be larger than a &amp;ldquo;solid&amp;rdquo; archive.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So ZIP is great when you need &lt;strong&gt;per-file access&lt;/strong&gt; and broad compatibility (e.g. Windows, macOS, Linux).&lt;/p&gt;
&lt;h3 id=&quot;targz-one-big-stream-solid-archive&quot;&gt;TAR.GZ: One Big Stream (Solid Archive)&lt;/h3&gt;
&lt;p&gt;TAR.GZ is a &lt;strong&gt;two-step&lt;/strong&gt; process:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;TAR (Tape Archiver):&lt;/strong&gt; Concatenate all files into one continuous &lt;strong&gt;stream&lt;/strong&gt; (no compression yet). This is a &amp;ldquo;solid&amp;rdquo; archive&amp;mdash;one long byte stream.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GZIP:&lt;/strong&gt; Compress that &lt;strong&gt;entire&lt;/strong&gt; stream with DEFLATE (LZ77 + Huffman) as if it were a single file.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Because GZIP sees the whole project as one stream, it can find patterns that span &lt;strong&gt;many files&lt;/strong&gt;. A repeated header in &lt;code&gt;file_A.txt&lt;/code&gt; can be used to compress the same header in &lt;code&gt;file_Z.txt&lt;/code&gt;. That&amp;rsquo;s why you can get a &lt;strong&gt;much&lt;/strong&gt; better ratio&amp;mdash;e.g. 100GB down to 25GB&amp;mdash;when you have lots of similar or repeated content across files.&lt;/p&gt;
&lt;p&gt;Trade-off: to get &lt;strong&gt;any&lt;/strong&gt; file out of a TAR.GZ, you typically have to decompress from the beginning up to that file. There&amp;rsquo;s no cheap &amp;ldquo;jump to file 402&amp;rdquo; as in ZIP.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# Step 1: Bundle everything into one stream (size unchanged)&lt;/span&gt;
tar -cvf backup.tar ./my_project

&lt;span class=&quot;hljs-comment&quot;&gt;# Step 2: Compress that whole stream&lt;/span&gt;
gzip backup.tar

&lt;span class=&quot;hljs-comment&quot;&gt;# Result: backup.tar.gz &amp;mdash; one compressed stream&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;When to use TAR.GZ:&lt;/strong&gt; Backups, source tarballs, logs, or any case where you want &lt;strong&gt;maximum compression&lt;/strong&gt; and usually extract the whole archive (or don&amp;rsquo;t mind decompressing from the start to reach a file). Common on Linux and in DevOps pipelines.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;When to prefer ZIP:&lt;/strong&gt; When you need &lt;strong&gt;random access&lt;/strong&gt; to individual files or maximum compatibility with non-Unix systems.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;5-how-video-compression-goes-further-temporal-redundancy&quot;&gt;5. How Video Compression Goes Further: Temporal Redundancy&lt;/h2&gt;
&lt;p&gt;Video has a special kind of redundancy: &lt;strong&gt;between frames&lt;/strong&gt;, most of the image doesn&amp;rsquo;t change. Only moving parts (and lighting changes) differ. So instead of storing every frame in full, modern codecs (e.g. H.264) use &lt;strong&gt;temporal compression&lt;/strong&gt;: store one full frame, then for the next frames store mainly &lt;strong&gt;what changed&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Roughly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;I-frames (Intra-frames):&lt;/strong&gt; Full frames&amp;mdash;like a JPEG image. They don&amp;rsquo;t depend on other frames. Used as anchors so you can seek or recover from errors.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;P-frames (Predictive):&lt;/strong&gt; Encoded as &amp;ldquo;differences&amp;rdquo; from a previous frame (or I-frame). Much smaller than a full frame.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;B-frames (Bi-predictive):&lt;/strong&gt; Use both past and future frames to predict the current frame, so they can be even smaller.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So conceptually:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-text&quot;&gt;Frame 1 (I):  Full image of a sunset
Frame 2 (P):  &amp;ldquo;Same as Frame 1, but the bird moved 2 pixels left&amp;rdquo;
Frame 3 (P):  &amp;ldquo;Same as Frame 2, but the bird moved 2 pixels left&amp;rdquo;
&amp;hellip;
Total stored: one full frame + many small &amp;ldquo;deltas&amp;rdquo; and motion vectors
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.ratnesh-maurya.com/images/blogs-inline-image/inter-frame-prediction-video-compression.png&quot; alt=&quot;Inter-frame prediction: I-frame and P-frames with motion vectors. Frame 1 is a full photo; Frames 2 and 3 store only the moving bird and motion vector (-2, 0).&quot;&gt;&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s &lt;strong&gt;temporal&lt;/strong&gt; compression. Video also uses &lt;strong&gt;spatial&lt;/strong&gt; compression inside each frame (similar in spirit to JPEG). Together, temporal + spatial (and often lossy choices) let streaming and storage stay practical at 1080p and 4K.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;6-wrapping-up&quot;&gt;6. Wrapping Up&lt;/h2&gt;
&lt;p&gt;Compression is the invisible engine behind smaller backups, faster transfers, and watchable video. The main ideas are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Redundancy&lt;/strong&gt; is removed or shortened: repeated phrases become back-references (LZ77), and frequent symbols get short codes (Huffman).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lossless&lt;/strong&gt; (ZIP, GZIP, PNG) keeps every bit; &lt;strong&gt;lossy&lt;/strong&gt; (JPEG, MP3, H.264) trades a bit of quality for much smaller size.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ZIP&lt;/strong&gt; compresses file-by-file for random access; &lt;strong&gt;TAR.GZ&lt;/strong&gt; compresses one solid stream for better ratio when you don&amp;rsquo;t need per-file random access.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Video&lt;/strong&gt; adds &lt;strong&gt;temporal&lt;/strong&gt; compression: store full frames rarely, and mostly store changes between frames.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Understanding these mechanics helps you choose the right format&amp;mdash;whether you&amp;rsquo;re optimizing Next.js assets, shipping backups to S3, or tuning video encoding&amp;mdash;and demystifies how 100GB can become 25GB without losing a single bit.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;written using AI tools&lt;/p&gt;
&lt;/blockquote&gt;
</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/14657/the-mechanics-of-compression-how-100gb-becomes-25gb</guid>
<pubDate>Sun, 19 Apr 2026 23:55:52 +0000</pubDate>
</item>
<item>
<title>Your Code Works. Your Architecture Doesn’t.</title>
<link>https://coderlegion.com/13575/your-code-works-your-architecture-doesnt</link>
<description>
&lt;p&gt;&lt;em&gt;Why working code without architecture predictably collapses &amp;mdash; and what to do about it.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/lA9sk_y_sSE&quot; title=&quot;Your Code Works. Your Architecture Doesn't.&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;allowfullscreen&quot;&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Prefer watching? The full video covers everything in this post &amp;mdash; with visuals and code walkthroughs.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;The Code That Almost Took Down Black Friday&lt;/h2&gt;
&lt;p&gt;This code passed code review. Three senior developers approved it. It's been in production, serving real customers.&lt;/p&gt;
&lt;p&gt;And it almost took down Black Friday.&lt;/p&gt;
&lt;p&gt;Not because of a bug. Not because of performance. The code &lt;strong&gt;works&lt;/strong&gt;. The architecture doesn't.&lt;/p&gt;
&lt;p&gt;I've seen this exact story play out at every company I've worked at over the past decade. Different languages, different teams, same pattern. It's predictable. And it's preventable.&lt;/p&gt;
&lt;h2&gt;The Handler&lt;/h2&gt;
&lt;p&gt;Here's the code. Tell me if this looks familiar.&lt;/p&gt;
&lt;p&gt;One handler function. About a hundred and seventy lines. And it does everything.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Top third&lt;/strong&gt; &amp;mdash; database queries to get product prices, discount calculations, tax logic.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Middle&lt;/strong&gt; &amp;mdash; Stripe payment processing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bottom&lt;/strong&gt; &amp;mdash; saving to the database, sending confirmation emails.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Business logic, infrastructure, third-party APIs &amp;mdash; all in one function. Mixed together.&lt;/p&gt;
&lt;p&gt;And if you're being fair? This code is fine. It works. It's readable. It handles errors properly. Three senior developers approved this PR. I would too.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;And that's the trap.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Because it's not about whether this code works today. It's about what happens when you try to extend it.&lt;/p&gt;
&lt;h2&gt;The Timeline: From Ship It to Rewrite&lt;/h2&gt;
&lt;p&gt;Let me walk you through what actually happens. Week by week. This isn't theoretical &amp;mdash; I've lived through this pattern multiple times.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Week one.&lt;/strong&gt; Feature ships. Everyone's happy. PR approved, tests pass, production is stable. The team feels fast. And they ARE fast. This is real.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Week three.&lt;/strong&gt; New requirement: show product prices in the cart endpoint. Developer needs product prices. Opens the order handler. Sees the query. Copy-pastes it into the new handler. Fastest way to meet the deadline. Small duplication. Seems fine.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Week five.&lt;/strong&gt; Someone notices the duplication. Creates a helper function. Good instinct. But the order handler still has the inline version. The cart handler still has the copy-pasted version. Only new code uses the helper. Now you have &lt;strong&gt;three&lt;/strong&gt; ways to get a product price in the same codebase.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Week seven.&lt;/strong&gt; Three developers, three different approaches. One returns just the price. Another returns an object. A third returns a dictionary. No agreed pattern. Everyone solving the same problem their own way.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Week ten.&lt;/strong&gt; Circular dependencies start forming. Orders depend on products. Products depend on discounts. Discounts depend on orders for loyalty calculations. Everything depends on everything. Can't test anything in isolation. Can't change one thing without breaking another.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Month six.&lt;/strong&gt; The test suite takes forty-five minutes. Nobody runs it anymore. Production bugs are weekly. Simple changes take days because everyone's scared of breaking something.&lt;/p&gt;
&lt;p&gt;And the developer who wrote that first handler? The one who shipped on time, passed code review, got the thumbs up? They're looking at the same code thinking &amp;mdash; &lt;em&gt;how did we get here? I did everything right.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;And here's the sentence I've heard at every single one of these companies:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&quot;We're talking about a rewrite.&quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Six months. Working code. Senior developers. Good intentions. And you're talking about throwing it all away.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Every codebase has an architecture. If you didn't choose one, you got one anyway &amp;mdash; by accident.&lt;/strong&gt; That handler? That IS an architecture. It's just not one anyone decided on. It's the one that happened when nobody made a choice.&lt;/p&gt;
&lt;p&gt;And accidental architecture always ends the same way.&lt;/p&gt;
&lt;h2&gt;The AI Amplifier&lt;/h2&gt;
&lt;p&gt;Now here's where it gets worse.&lt;/p&gt;
&lt;p&gt;Everything I just described? That timeline assumed humans writing code at human speed. Add AI to a codebase with no architecture and you don't just get the same problems. You get them &lt;strong&gt;ten times faster&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Think about it. You prompt your AI: &quot;add a loyalty points discount feature.&quot; The AI looks at your codebase. It sees four different patterns for handling discounts. It picks one. Maybe creates a fifth. It generates code following that pattern &amp;mdash; whatever pattern it found first.&lt;/p&gt;
&lt;p&gt;Now you have five patterns. The AI didn't fix anything. It photocopied the mess at ten times the speed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;AI doesn't fix architecture. It amplifies whatever exists.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Good architecture? AI follows clean patterns. You get consistency at ten times the speed. No architecture? AI copies chaos. You get spaghetti at ten times the speed.&lt;/p&gt;
&lt;p&gt;If you're planning to use AI &amp;mdash; and you should be &amp;mdash; you need &lt;strong&gt;better&lt;/strong&gt; architecture, not less.&lt;/p&gt;
&lt;h2&gt;What To Actually Do&lt;/h2&gt;
&lt;p&gt;So what do you actually do about it?&lt;/p&gt;
&lt;p&gt;Let me take that same handler and show you one decision that changes everything. You don't need to rewrite this. You need to pull it apart.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step one: Take the business logic out.&lt;/strong&gt; Discount rules, tax calculations, order totals &amp;mdash; that's your business. It doesn't need to know about HTTP. It doesn't need to know about Stripe. It's just math.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step two: Take the infrastructure out.&lt;/strong&gt; Stripe, the database, email &amp;mdash; those are tools. They serve the business logic. They shouldn't live with it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step three: What's left is the glue.&lt;/strong&gt; Your handler just receives a request and passes it along. That's all it should ever do.&lt;/p&gt;
&lt;p&gt;Now look at what you've got:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;domain/
  models.py             &amp;mdash; business rules
services/
  order_service.py      &amp;mdash; orchestration
adapters/
  stripe_payment.py     &amp;mdash; payment infra
  db_repositories.py    &amp;mdash; data access
routes/
  orders.py             &amp;mdash; HTTP, thin
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That's hexagonal architecture.&lt;/p&gt;
&lt;p&gt;You didn't plan it on a whiteboard for six months. You just asked one question about the code you already had: &lt;strong&gt;what belongs together, and what doesn't?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I'm not telling you to architect everything before writing your first line of code. That first handler? Ship it. Get it working. Pass code review. But somewhere between that first handler and the moment your codebase starts growing &amp;mdash; &lt;strong&gt;before&lt;/strong&gt; the copy-paste starts, &lt;strong&gt;before&lt;/strong&gt; three developers create three patterns &amp;mdash; make the decision.&lt;/p&gt;
&lt;p&gt;Because the window where this is easy? It closes fast. Week one, it's a two-hour refactor. Month six, it's a rewrite. The only difference is when you chose to think about structure.&lt;/p&gt;
&lt;p&gt;And once you have it &amp;mdash; look at what changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Debugging a discount bug?&lt;/strong&gt; One file. Twenty-five lines. Pure math.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New developer joins?&lt;/strong&gt; They know where code goes on day one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tests?&lt;/strong&gt; Under a millisecond. You actually run them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AI generates code?&lt;/strong&gt; It sees clean separation. It follows the pattern instead of copying chaos.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Three Things To Do This Week&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;One.&lt;/strong&gt; Ask your team: &quot;Where does new code go?&quot; If nobody has a clear answer &amp;mdash; that's your window. It's still open.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Two.&lt;/strong&gt; Pick one piece of business logic buried in a handler. Extract it into a pure function. No dependencies. Just inputs and outputs. Write a test. Feel how fast it runs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Three.&lt;/strong&gt; Next time someone opens a PR with copy-pasted logic &amp;mdash; don't just approve it. That's the moment the spaghetti starts. Be the person who says &quot;let's extract this.&quot;&lt;/p&gt;
&lt;p&gt;None of these take more than thirty minutes. All of them compound.&lt;/p&gt;
&lt;h2&gt;The Honest Trade&lt;/h2&gt;
&lt;p&gt;I'm not going to pretend there's no cost. Your first feature with architecture takes a bit longer. You're thinking about structure, defining boundaries.&lt;/p&gt;
&lt;p&gt;But here's the thing that doesn't show up in sprint metrics but everyone feels: &lt;strong&gt;developer confidence.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When your code has clear boundaries, you're not scared to change things. You run your tests, they pass in seconds, you deploy. No sweating. No &quot;let me check if this breaks the payment flow.&quot;&lt;/p&gt;
&lt;p&gt;That feeling? That's what architecture gives you. Not just speed. Confidence. The confidence that the next Black Friday won't be yours.&lt;/p&gt;
&lt;h2&gt;Quick Gut Check&lt;/h2&gt;
&lt;p&gt;How many of these sound like your codebase right now?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&quot;We're talking about a rewrite.&quot;&lt;/li&gt;
&lt;li&gt;&quot;I don't know which version of this function is the right one.&quot;&lt;/li&gt;
&lt;li&gt;&quot;The new developer asked where to put their code and nobody had an answer.&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If any of those hit &amp;mdash; you don't have technical debt. You have an architecture problem.&lt;/p&gt;
&lt;p&gt;Hexagonal architecture is what I showed you today. It's what worked for me across many different projects and languages. But it's not the only answer. There's microkernel, event-driven, and dozens of other proven patterns. Go take a software architecture course on LinkedIn Learning or Coursera &amp;mdash; people have spent decades figuring this stuff out. You don't have to invent the wheel. You just have to actually &lt;strong&gt;use&lt;/strong&gt; one.&lt;/p&gt;
&lt;p&gt;Because the difference between a codebase that scales and one that collapses? It's not talent. It's not the language. It's not even the framework. It's whether someone sat down and made a plan.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;There's also a &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/sudoish/order-system-bad-example&quot;&gt;GitHub repo&lt;/a&gt; with the code so you can see this pattern for real. If you want to see the practical side &amp;mdash; how to actually refactor this into clean architecture, step by step &amp;mdash; that's the next video. &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.youtube.com/@sudoish&quot;&gt;Subscribe&lt;/a&gt; so you don't miss it.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The post &lt;a rel=&quot;nofollow&quot; href=&quot;https://sudoish.com/your-code-works-your-architecture-doesnt/&quot;&gt;Your Code Works. Your Architecture Doesn&amp;rsquo;t.&lt;/a&gt; appeared first on &lt;a rel=&quot;nofollow&quot; href=&quot;https://sudoish.com&quot;&gt;sudoish&lt;/a&gt;.&lt;/p&gt;

</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/13575/your-code-works-your-architecture-doesnt</guid>
<pubDate>Sat, 28 Mar 2026 02:50:21 +0000</pubDate>
</item>
</channel>
</rss>