<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Farhad Rahimi Klie</title>
    <description>The latest articles on DEV Community by Farhad Rahimi Klie (@farhadrahimiklie).</description>
    <link>https://dev.to/farhadrahimiklie</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3424859%2Fc13c2c54-3160-4d41-9cdf-9ca26cf28fa8.jpg</url>
      <title>DEV Community: Farhad Rahimi Klie</title>
      <link>https://dev.to/farhadrahimiklie</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/farhadrahimiklie"/>
    <language>en</language>
    <item>
      <title>Why Git Was Created</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Mon, 11 May 2026 05:56:32 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/why-git-was-created-2c04</link>
      <guid>https://dev.to/farhadrahimiklie/why-git-was-created-2c04</guid>
      <description>&lt;p&gt;Before Git, the Linux kernel developers used a version control system called BitKeeper.&lt;/p&gt;

&lt;p&gt;BitKeeper was proprietary software, but Linux developers could use it for free for kernel development.&lt;/p&gt;

&lt;p&gt;Then in 2005:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Licensing conflicts happened&lt;/li&gt;
&lt;li&gt;Access to BitKeeper was removed for Linux developers&lt;/li&gt;
&lt;li&gt;The Linux kernel team suddenly lost the tool managing one of the world’s biggest software projects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was a disaster.&lt;/p&gt;

&lt;p&gt;The Linux kernel already had:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;thousands of files&lt;/li&gt;
&lt;li&gt;many developers&lt;/li&gt;
&lt;li&gt;patches arriving constantly&lt;/li&gt;
&lt;li&gt;changes from all over the world&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Linus Torvalds needed a replacement immediately.&lt;/p&gt;

&lt;p&gt;He did not like existing systems because they were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;slow&lt;/li&gt;
&lt;li&gt;centralized&lt;/li&gt;
&lt;li&gt;hard to merge&lt;/li&gt;
&lt;li&gt;bad at handling large distributed development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So he decided to build his own system.&lt;/p&gt;




&lt;h1&gt;
  
  
  2. How Fast Git Was Built
&lt;/h1&gt;

&lt;p&gt;This is one of the most famous parts of Git history.&lt;/p&gt;

&lt;p&gt;The first version of Git was built in only a few days.&lt;/p&gt;

&lt;p&gt;Core development timeline:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Day 1–2:
Basic object storage and hashing concepts&lt;/li&gt;
&lt;li&gt;Around Day 4:
Could track file snapshots&lt;/li&gt;
&lt;li&gt;Around Day 10:
Basic branching and commits worked&lt;/li&gt;
&lt;li&gt;Within about 2 weeks:
Git became usable for Linux kernel development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That speed sounds impossible today, but several things made it possible:&lt;/p&gt;

&lt;h3&gt;
  
  
  Linus already understood:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;operating systems&lt;/li&gt;
&lt;li&gt;filesystems&lt;/li&gt;
&lt;li&gt;performance engineering&lt;/li&gt;
&lt;li&gt;distributed collaboration&lt;/li&gt;
&lt;li&gt;kernel development workflows&lt;/li&gt;
&lt;li&gt;low-level data structures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;He was not experimenting randomly.&lt;/p&gt;

&lt;p&gt;He already had a very clear mental model before writing code.&lt;/p&gt;




&lt;h1&gt;
  
  
  3. What Language Git Was Written In
&lt;/h1&gt;

&lt;p&gt;Git was primarily written in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;C&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why C?&lt;/p&gt;

&lt;p&gt;Because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;extremely fast&lt;/li&gt;
&lt;li&gt;direct filesystem access&lt;/li&gt;
&lt;li&gt;portable&lt;/li&gt;
&lt;li&gt;already used heavily in Linux&lt;/li&gt;
&lt;li&gt;minimal overhead&lt;/li&gt;
&lt;li&gt;efficient memory control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Git also used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;shell scripting initially&lt;/li&gt;
&lt;li&gt;some Perl scripts in older tooling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But the core engine was C.&lt;/p&gt;

&lt;p&gt;Today Git includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;C&lt;/li&gt;
&lt;li&gt;shell&lt;/li&gt;
&lt;li&gt;Perl&lt;/li&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;Tcl/Tk&lt;/li&gt;
&lt;li&gt;some platform-specific code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But its heart is still mostly C.&lt;/p&gt;




&lt;h1&gt;
  
  
  4. The Mentality Behind Git
&lt;/h1&gt;

&lt;p&gt;This is the most important part.&lt;/p&gt;

&lt;p&gt;Git was not designed like a normal “application.”&lt;/p&gt;

&lt;p&gt;Linus designed Git like a filesystem + cryptographic database.&lt;/p&gt;

&lt;p&gt;His mentality was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Store everything as immutable content objects.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That single idea shaped all Git architecture.&lt;/p&gt;




&lt;h1&gt;
  
  
  5. The Core Philosophy of Git
&lt;/h1&gt;

&lt;p&gt;Most old version control systems stored:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;file differences&lt;/li&gt;
&lt;li&gt;centralized history&lt;/li&gt;
&lt;li&gt;sequential changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Git instead stores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;complete snapshots&lt;/li&gt;
&lt;li&gt;content-addressed objects&lt;/li&gt;
&lt;li&gt;immutable history&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was revolutionary.&lt;/p&gt;

&lt;p&gt;Git thinks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Project State → Hash → Stored Object
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Edit A → Edit B → Edit C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That difference is enormous.&lt;/p&gt;




&lt;h1&gt;
  
  
  6. Git’s Most Important Idea: Hashing
&lt;/h1&gt;

&lt;p&gt;Git uses cryptographic hashes.&lt;/p&gt;

&lt;p&gt;Originally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SHA-1&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every file and object gets a unique hash.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;e83c5163316f89bfbde7d9ab23ca2e25604af290
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That hash identifies content.&lt;/p&gt;

&lt;p&gt;Meaning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if content changes&lt;/li&gt;
&lt;li&gt;hash changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So Git can detect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;modifications&lt;/li&gt;
&lt;li&gt;corruption&lt;/li&gt;
&lt;li&gt;exact history relationships&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This made Git:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reliable&lt;/li&gt;
&lt;li&gt;fast&lt;/li&gt;
&lt;li&gt;distributed&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  7. Git Was Designed Backwards From Performance
&lt;/h1&gt;

&lt;p&gt;Linus cared deeply about performance.&lt;/p&gt;

&lt;p&gt;His priorities were:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Speed&lt;/li&gt;
&lt;li&gt;Data integrity&lt;/li&gt;
&lt;li&gt;Distributed workflow&lt;/li&gt;
&lt;li&gt;Branching efficiency&lt;/li&gt;
&lt;li&gt;Merge capability&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Not:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pretty UI&lt;/li&gt;
&lt;li&gt;beginner friendliness&lt;/li&gt;
&lt;li&gt;enterprise features&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is why Git commands can feel difficult.&lt;/p&gt;

&lt;p&gt;It was originally designed for kernel developers.&lt;/p&gt;




&lt;h1&gt;
  
  
  8. The Architecture of Git
&lt;/h1&gt;

&lt;p&gt;Git internally stores objects:&lt;/p&gt;

&lt;h3&gt;
  
  
  Blob
&lt;/h3&gt;

&lt;p&gt;Stores file contents.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tree
&lt;/h3&gt;

&lt;p&gt;Stores directory structures.&lt;/p&gt;

&lt;h3&gt;
  
  
  Commit
&lt;/h3&gt;

&lt;p&gt;Stores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;author&lt;/li&gt;
&lt;li&gt;timestamp&lt;/li&gt;
&lt;li&gt;parent commits&lt;/li&gt;
&lt;li&gt;snapshot reference&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tag
&lt;/h3&gt;

&lt;p&gt;Named references.&lt;/p&gt;

&lt;p&gt;Everything becomes objects.&lt;/p&gt;




&lt;h1&gt;
  
  
  9. Why Git Branching Is So Fast
&lt;/h1&gt;

&lt;p&gt;In many older systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;branches copied files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Git:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;branches are basically lightweight pointers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A branch is almost just:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;branch_name → commit_hash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;branch creation is nearly instant&lt;/li&gt;
&lt;li&gt;switching branches is fast&lt;/li&gt;
&lt;li&gt;merging is easier&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was a huge innovation.&lt;/p&gt;




&lt;h1&gt;
  
  
  10. Git Was Built for Distributed Development
&lt;/h1&gt;

&lt;p&gt;Older systems often relied on a central server.&lt;/p&gt;

&lt;p&gt;Git changed this.&lt;/p&gt;

&lt;p&gt;Every developer gets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;full history&lt;/li&gt;
&lt;li&gt;full commits&lt;/li&gt;
&lt;li&gt;full branches&lt;/li&gt;
&lt;li&gt;complete repository&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Meaning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;work offline&lt;/li&gt;
&lt;li&gt;no single point of failure&lt;/li&gt;
&lt;li&gt;easier collaboration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was revolutionary in 2005.&lt;/p&gt;




&lt;h1&gt;
  
  
  11. How Linus Actually Built It
&lt;/h1&gt;

&lt;p&gt;Linus usually builds software with this mentality:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 — Solve only the core problem
&lt;/h3&gt;

&lt;p&gt;No unnecessary abstractions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2 — Make data structures efficient
&lt;/h3&gt;

&lt;p&gt;Performance first.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3 — Use small composable tools
&lt;/h3&gt;

&lt;p&gt;Git originally had many tiny commands.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4 — Trust powerful primitives
&lt;/h3&gt;

&lt;p&gt;Instead of giant frameworks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5 — Optimize around real workflows
&lt;/h3&gt;

&lt;p&gt;Not theoretical design.&lt;/p&gt;

&lt;p&gt;This is very Unix-like thinking.&lt;/p&gt;




&lt;h1&gt;
  
  
  12. Early Git Was Extremely Rough
&lt;/h1&gt;

&lt;p&gt;The first Git versions were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ugly&lt;/li&gt;
&lt;li&gt;command-line heavy&lt;/li&gt;
&lt;li&gt;poorly documented&lt;/li&gt;
&lt;li&gt;hard to use&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Linus himself said he was not trying to make it pretty.&lt;/p&gt;

&lt;p&gt;He only wanted:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;speed&lt;/li&gt;
&lt;li&gt;correctness&lt;/li&gt;
&lt;li&gt;distributed functionality&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Later developers improved usability.&lt;/p&gt;

&lt;p&gt;One major contributor was:&lt;/p&gt;

&lt;p&gt;Junio Hamano&lt;/p&gt;

&lt;p&gt;He became the long-term maintainer and helped Git mature into a polished tool.&lt;/p&gt;




&lt;h1&gt;
  
  
  13. Why Git Became Dominant
&lt;/h1&gt;

&lt;p&gt;Git became dominant because it solved real engineering pain better than competitors.&lt;/p&gt;

&lt;p&gt;Major advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fast branching&lt;/li&gt;
&lt;li&gt;powerful merging&lt;/li&gt;
&lt;li&gt;offline development&lt;/li&gt;
&lt;li&gt;integrity checking&lt;/li&gt;
&lt;li&gt;scalability&lt;/li&gt;
&lt;li&gt;distributed collaboration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This made it perfect for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;open source&lt;/li&gt;
&lt;li&gt;large engineering teams&lt;/li&gt;
&lt;li&gt;internet-scale collaboration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then platforms like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub&lt;/li&gt;
&lt;li&gt;GitLab&lt;/li&gt;
&lt;li&gt;Bitbucket&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;accelerated adoption massively.&lt;/p&gt;




&lt;h1&gt;
  
  
  14. The Most Important Technical Insight
&lt;/h1&gt;

&lt;p&gt;Git is not really “a source control app.”&lt;/p&gt;

&lt;p&gt;Internally, it is closer to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a content-addressable object database&lt;/li&gt;
&lt;li&gt;plus graph relationships&lt;/li&gt;
&lt;li&gt;plus filesystem snapshots&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That architectural decision is why Git still scales today.&lt;/p&gt;




&lt;h1&gt;
  
  
  15. Why Git Feels Complicated
&lt;/h1&gt;

&lt;p&gt;Because Git exposes internal concepts directly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HEAD&lt;/li&gt;
&lt;li&gt;refs&lt;/li&gt;
&lt;li&gt;index&lt;/li&gt;
&lt;li&gt;detached HEAD&lt;/li&gt;
&lt;li&gt;rebasing&lt;/li&gt;
&lt;li&gt;object store&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Linus optimized for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;power&lt;/li&gt;
&lt;li&gt;flexibility&lt;/li&gt;
&lt;li&gt;speed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;not beginner simplicity.&lt;/p&gt;

&lt;p&gt;That tradeoff is still visible today.&lt;/p&gt;




&lt;h1&gt;
  
  
  16. The Deep Engineering Lesson From Git
&lt;/h1&gt;

&lt;p&gt;Git teaches a major software engineering principle:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Great systems are often built from a few powerful primitives.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Git’s primitives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;hashes&lt;/li&gt;
&lt;li&gt;immutable objects&lt;/li&gt;
&lt;li&gt;pointers&lt;/li&gt;
&lt;li&gt;graphs&lt;/li&gt;
&lt;li&gt;snapshots&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From those few concepts, an entire ecosystem emerged.&lt;/p&gt;




&lt;h1&gt;
  
  
  17. Final Summary
&lt;/h1&gt;

&lt;p&gt;Git was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;created in 2005&lt;/li&gt;
&lt;li&gt;mainly built by Linus Torvalds&lt;/li&gt;
&lt;li&gt;written mostly in C&lt;/li&gt;
&lt;li&gt;initially usable within about 10–14 days&lt;/li&gt;
&lt;li&gt;designed under extreme pressure&lt;/li&gt;
&lt;li&gt;optimized for speed and distributed collaboration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The mentality behind Git was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Simple primitives
+ immutable data
+ hashing
+ distributed architecture
+ performance-first engineering
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That combination changed software development forever.&lt;/p&gt;

</description>
      <category>git</category>
      <category>linustorvalds</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Ken Thompson — The Quiet Genius Who Helped Build Modern Computing</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Sun, 10 May 2026 03:17:37 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/ken-thompson-the-quiet-genius-who-helped-build-modern-computing-131d</link>
      <guid>https://dev.to/farhadrahimiklie/ken-thompson-the-quiet-genius-who-helped-build-modern-computing-131d</guid>
      <description>&lt;p&gt;When people talk about the history of computers, names like Bill Gates, Steve Jobs, or Linus Torvalds usually appear first. But behind many of the technologies those people used or improved, there was another engineer whose influence runs deeper than most people realize:&lt;/p&gt;

&lt;p&gt;Ken Thompson.&lt;/p&gt;

&lt;p&gt;If modern computing were a giant city, Ken Thompson helped design the roads, plumbing, and electricity before anyone else even started building houses.&lt;/p&gt;

&lt;p&gt;He was not loud.&lt;br&gt;
He was not a businessman.&lt;br&gt;
He rarely chased fame.&lt;/p&gt;

&lt;p&gt;But he helped create some of the most important technologies in computer history:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UNIX&lt;/li&gt;
&lt;li&gt;The C programming ecosystem&lt;/li&gt;
&lt;li&gt;The B programming language&lt;/li&gt;
&lt;li&gt;UTF-8&lt;/li&gt;
&lt;li&gt;Early operating system concepts&lt;/li&gt;
&lt;li&gt;Modern software tools&lt;/li&gt;
&lt;li&gt;Influential ideas behind Linux, macOS, Android, and much more&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Almost every programmer today uses systems that were directly or indirectly shaped by his work.&lt;/p&gt;

&lt;p&gt;This article explores who Ken Thompson is, how he thought, what he built, why his ideas mattered, and why computer science students should study him carefully.&lt;/p&gt;


&lt;h1&gt;
  
  
  Who Is Ken Thompson?
&lt;/h1&gt;

&lt;p&gt;Ken Thompson was born on February 4, 1943, in New Orleans.&lt;/p&gt;

&lt;p&gt;He became one of the most influential computer scientists in history and is best known for co-creating:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UNIX operating system&lt;/li&gt;
&lt;li&gt;B programming language&lt;/li&gt;
&lt;li&gt;Early UNIX tools&lt;/li&gt;
&lt;li&gt;UTF-8 encoding&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;He worked mainly at &lt;a href="https://www.bell-labs.com?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Bell Labs&lt;/a&gt;, one of the greatest research laboratories ever created.&lt;/p&gt;

&lt;p&gt;Bell Labs was not an ordinary company office. It was a place where scientists invented technologies that changed the world:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Transistors&lt;/li&gt;
&lt;li&gt;Information theory&lt;/li&gt;
&lt;li&gt;UNIX&lt;/li&gt;
&lt;li&gt;C language&lt;/li&gt;
&lt;li&gt;Laser technology&lt;/li&gt;
&lt;li&gt;Satellite communication innovations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Many legendary computer scientists worked there, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dennis Ritchie&lt;/li&gt;
&lt;li&gt;Brian Kernighan&lt;/li&gt;
&lt;li&gt;Claude Shannon&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ken Thompson became one of the brightest minds among them.&lt;/p&gt;


&lt;h1&gt;
  
  
  Early Interest in Computers
&lt;/h1&gt;

&lt;p&gt;Ken Thompson studied electrical engineering and computer science at the:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;University of California, Berkeley&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;During the 1960s, computers were massive, expensive machines. Programming was difficult, slow, and painful.&lt;/p&gt;

&lt;p&gt;Most systems were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complicated&lt;/li&gt;
&lt;li&gt;Hard to use&lt;/li&gt;
&lt;li&gt;Hard to modify&lt;/li&gt;
&lt;li&gt;Tightly controlled by companies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thompson had a different mindset.&lt;/p&gt;

&lt;p&gt;He believed software should be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simple&lt;/li&gt;
&lt;li&gt;Elegant&lt;/li&gt;
&lt;li&gt;Modular&lt;/li&gt;
&lt;li&gt;Practical&lt;/li&gt;
&lt;li&gt;Easy to combine&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That philosophy later became the foundation of UNIX.&lt;/p&gt;


&lt;h1&gt;
  
  
  The World Before UNIX
&lt;/h1&gt;

&lt;p&gt;To understand Ken Thompson’s importance, you must understand the computing world before UNIX.&lt;/p&gt;

&lt;p&gt;In the 1960s:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operating systems were huge and messy&lt;/li&gt;
&lt;li&gt;Software was often tied to specific hardware&lt;/li&gt;
&lt;li&gt;Portability barely existed&lt;/li&gt;
&lt;li&gt;Developers wasted enormous time managing system complexity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One major project at the time was:&lt;/p&gt;

&lt;p&gt;Multics&lt;/p&gt;

&lt;p&gt;Multics was a collaborative project involving:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;General Electric&lt;/li&gt;
&lt;li&gt;MIT&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.bell-labs.com?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Bell Labs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal was ambitious:&lt;/p&gt;

&lt;p&gt;Build the ultimate operating system.&lt;/p&gt;

&lt;p&gt;But there was a problem.&lt;/p&gt;

&lt;p&gt;The project became extremely complicated.&lt;/p&gt;

&lt;p&gt;Ken Thompson and Dennis Ritchie started feeling frustrated with its complexity.&lt;/p&gt;

&lt;p&gt;This frustration eventually led to one of the greatest breakthroughs in computing history.&lt;/p&gt;


&lt;h1&gt;
  
  
  The Birth of UNIX
&lt;/h1&gt;

&lt;p&gt;In 1969, after Bell Labs left the Multics project, Ken Thompson began building a simpler operating system.&lt;/p&gt;

&lt;p&gt;Initially, he wanted a system where he could run a game called:&lt;/p&gt;

&lt;p&gt;Space Travel&lt;/p&gt;

&lt;p&gt;That small experiment became something much bigger.&lt;/p&gt;

&lt;p&gt;He worked on an old machine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PDP-7 computer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And started building tools and system components from scratch.&lt;/p&gt;

&lt;p&gt;Soon, Dennis Ritchie joined him.&lt;/p&gt;

&lt;p&gt;Together they created:&lt;/p&gt;

&lt;p&gt;UNIX&lt;/p&gt;

&lt;p&gt;The name UNIX was actually a joke inspired by “Multics.”&lt;/p&gt;

&lt;p&gt;Multics was complicated and massive.&lt;/p&gt;

&lt;p&gt;UNIX was supposed to be simpler and cleaner.&lt;/p&gt;


&lt;h1&gt;
  
  
  Why UNIX Was Revolutionary
&lt;/h1&gt;

&lt;p&gt;UNIX changed computing forever because it introduced ideas that were radically different.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Everything Should Be Simple
&lt;/h2&gt;

&lt;p&gt;Instead of giant programs doing everything, UNIX encouraged:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Small tools&lt;/li&gt;
&lt;li&gt;Small commands&lt;/li&gt;
&lt;li&gt;Single-purpose utilities&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each program should do one thing well.&lt;/p&gt;

&lt;p&gt;This idea sounds normal today.&lt;/p&gt;

&lt;p&gt;Back then, it was revolutionary.&lt;/p&gt;


&lt;h2&gt;
  
  
  2. Programs Should Work Together
&lt;/h2&gt;

&lt;p&gt;UNIX introduced pipelines.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;file.txt | &lt;span class="nb"&gt;grep &lt;/span&gt;hello | &lt;span class="nb"&gt;sort&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allowed programs to communicate easily.&lt;/p&gt;

&lt;p&gt;Small tools could be connected together like LEGO blocks.&lt;/p&gt;

&lt;p&gt;This philosophy deeply influenced modern software engineering.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Everything Is a File
&lt;/h2&gt;

&lt;p&gt;In UNIX:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Devices&lt;/li&gt;
&lt;li&gt;Processes&lt;/li&gt;
&lt;li&gt;Hardware communication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;could often be treated like files.&lt;/p&gt;

&lt;p&gt;This simplified system design dramatically.&lt;/p&gt;

&lt;p&gt;Even today, Linux and macOS still follow this idea.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Portability
&lt;/h2&gt;

&lt;p&gt;UNIX became portable across different hardware.&lt;/p&gt;

&lt;p&gt;That was an enormous breakthrough.&lt;/p&gt;

&lt;p&gt;Before UNIX, operating systems were usually trapped on one machine type.&lt;/p&gt;

&lt;p&gt;This portability later inspired:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux&lt;/li&gt;
&lt;li&gt;BSD&lt;/li&gt;
&lt;li&gt;macOS&lt;/li&gt;
&lt;li&gt;Android internals&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  The Creation of the B Language
&lt;/h1&gt;

&lt;p&gt;Before C language existed, Ken Thompson created:&lt;/p&gt;

&lt;p&gt;B programming language&lt;/p&gt;

&lt;p&gt;B was influenced by another language called:&lt;/p&gt;

&lt;p&gt;BCPL&lt;/p&gt;

&lt;p&gt;B was simple and powerful for system programming.&lt;/p&gt;

&lt;p&gt;But computers evolved quickly, and B had limitations.&lt;/p&gt;

&lt;p&gt;Then Dennis Ritchie improved those ideas and created:&lt;/p&gt;

&lt;p&gt;C programming language&lt;/p&gt;

&lt;p&gt;Without Ken Thompson’s B language, C might never have existed in the form we know today.&lt;/p&gt;

&lt;p&gt;And without C:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux may not exist&lt;/li&gt;
&lt;li&gt;Modern operating systems may look very different&lt;/li&gt;
&lt;li&gt;Embedded systems would evolve differently&lt;/li&gt;
&lt;li&gt;Modern compilers would change dramatically&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  UNIX and C Changed the Entire Industry
&lt;/h1&gt;

&lt;p&gt;UNIX and C together became one of the most important combinations in computer history.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because UNIX was rewritten in C.&lt;/p&gt;

&lt;p&gt;That was groundbreaking.&lt;/p&gt;

&lt;p&gt;Before this, operating systems were mostly written in assembly language.&lt;/p&gt;

&lt;p&gt;Assembly is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hardware-specific&lt;/li&gt;
&lt;li&gt;Hard to maintain&lt;/li&gt;
&lt;li&gt;Difficult to port&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;C allowed UNIX to move between different computers much more easily.&lt;/p&gt;

&lt;p&gt;This single decision transformed software engineering forever.&lt;/p&gt;




&lt;h1&gt;
  
  
  Influence on Linux and Modern Systems
&lt;/h1&gt;

&lt;p&gt;Many people think Linux appeared from nowhere.&lt;/p&gt;

&lt;p&gt;It did not.&lt;/p&gt;

&lt;p&gt;Linus Torvalds created Linux heavily inspired by UNIX.&lt;/p&gt;

&lt;p&gt;Modern systems influenced by UNIX include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux&lt;/li&gt;
&lt;li&gt;Android&lt;/li&gt;
&lt;li&gt;macOS&lt;/li&gt;
&lt;li&gt;BSD systems&lt;/li&gt;
&lt;li&gt;iOS internals&lt;/li&gt;
&lt;li&gt;Server infrastructure&lt;/li&gt;
&lt;li&gt;Cloud computing systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even command-line tools today still reflect UNIX philosophy.&lt;/p&gt;

&lt;p&gt;When developers use commands like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls
grep
cat
awk
sed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;they are using ideas that came from Thompson’s era.&lt;/p&gt;




&lt;h1&gt;
  
  
  Ken Thompson and UTF-8
&lt;/h1&gt;

&lt;p&gt;One of Ken Thompson’s lesser-known but extremely important contributions was:&lt;/p&gt;

&lt;p&gt;UTF-8&lt;/p&gt;

&lt;p&gt;He worked with:&lt;/p&gt;

&lt;p&gt;Rob Pike&lt;/p&gt;

&lt;p&gt;to help develop UTF-8.&lt;/p&gt;

&lt;p&gt;UTF-8 became the dominant text encoding standard for the internet.&lt;/p&gt;

&lt;p&gt;Without UTF-8, handling global languages would be much harder.&lt;/p&gt;

&lt;p&gt;Today UTF-8 powers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Websites&lt;/li&gt;
&lt;li&gt;Databases&lt;/li&gt;
&lt;li&gt;APIs&lt;/li&gt;
&lt;li&gt;Operating systems&lt;/li&gt;
&lt;li&gt;Programming languages&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Almost every developer uses UTF-8 daily, often without realizing it.&lt;/p&gt;




&lt;h1&gt;
  
  
  The UNIX Philosophy
&lt;/h1&gt;

&lt;p&gt;The “UNIX Philosophy” became one of the most influential engineering mindsets ever created.&lt;/p&gt;

&lt;p&gt;Core principles include:&lt;/p&gt;

&lt;h2&gt;
  
  
  Build Small Tools
&lt;/h2&gt;

&lt;p&gt;Avoid giant complicated systems when possible.&lt;/p&gt;




&lt;h2&gt;
  
  
  Make Programs Composable
&lt;/h2&gt;

&lt;p&gt;Programs should connect together easily.&lt;/p&gt;




&lt;h2&gt;
  
  
  Prefer Simplicity
&lt;/h2&gt;

&lt;p&gt;Simple systems survive longer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Write Clear Code
&lt;/h2&gt;

&lt;p&gt;Readable systems are maintainable systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  Avoid Unnecessary Complexity
&lt;/h2&gt;

&lt;p&gt;Complexity is expensive.&lt;/p&gt;

&lt;p&gt;This philosophy strongly influenced:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open-source culture&lt;/li&gt;
&lt;li&gt;Linux development&lt;/li&gt;
&lt;li&gt;DevOps tools&lt;/li&gt;
&lt;li&gt;Modern backend engineering&lt;/li&gt;
&lt;li&gt;Cloud infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even modern container systems like:&lt;/p&gt;

&lt;p&gt;Docker&lt;/p&gt;

&lt;p&gt;inherit UNIX-style thinking.&lt;/p&gt;




&lt;h1&gt;
  
  
  Ken Thompson’s Programming Style
&lt;/h1&gt;

&lt;p&gt;Many legendary programmers admired Thompson because of his coding style.&lt;/p&gt;

&lt;p&gt;His code was often described as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Minimal&lt;/li&gt;
&lt;li&gt;Elegant&lt;/li&gt;
&lt;li&gt;Efficient&lt;/li&gt;
&lt;li&gt;Clever without being messy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;He avoided unnecessary abstraction.&lt;/p&gt;

&lt;p&gt;He focused on practical engineering.&lt;/p&gt;

&lt;p&gt;This is important because modern software sometimes becomes overly complicated.&lt;/p&gt;

&lt;p&gt;Thompson believed good engineering often means removing complexity, not adding more features.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Famous “Trusting Trust” Lecture
&lt;/h1&gt;

&lt;p&gt;One of Ken Thompson’s most famous contributions to computer security was his lecture:&lt;/p&gt;

&lt;p&gt;“Reflections on Trusting Trust.”&lt;/p&gt;

&lt;p&gt;This lecture explained a terrifying idea.&lt;/p&gt;

&lt;p&gt;A compiler could secretly inject malicious code into software automatically.&lt;/p&gt;

&lt;p&gt;Even if developers inspect the source code, the malicious behavior could remain hidden.&lt;/p&gt;

&lt;p&gt;This concept became one of the foundational ideas in software supply chain security.&lt;/p&gt;

&lt;p&gt;Today, discussions about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compiler trust&lt;/li&gt;
&lt;li&gt;Build security&lt;/li&gt;
&lt;li&gt;Supply chain attacks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;still reference Thompson’s ideas.&lt;/p&gt;

&lt;p&gt;Modern cybersecurity experts continue studying this work.&lt;/p&gt;




&lt;h1&gt;
  
  
  Awards and Recognition
&lt;/h1&gt;

&lt;p&gt;Ken Thompson received many major awards, including:&lt;/p&gt;

&lt;h2&gt;
  
  
  Turing Award
&lt;/h2&gt;

&lt;p&gt;Often called:&lt;/p&gt;

&lt;p&gt;“The Nobel Prize of Computing.”&lt;/p&gt;

&lt;p&gt;He received it together with:&lt;/p&gt;

&lt;p&gt;Dennis Ritchie&lt;/p&gt;

&lt;p&gt;for UNIX development.&lt;/p&gt;




&lt;h2&gt;
  
  
  National Medal of Technology
&lt;/h2&gt;

&lt;p&gt;Awarded by the United States government.&lt;/p&gt;




&lt;h2&gt;
  
  
  Japan Prize
&lt;/h2&gt;

&lt;p&gt;Another major international scientific award.&lt;/p&gt;

&lt;p&gt;Despite all these achievements, Thompson remained relatively humble and quiet.&lt;/p&gt;




&lt;h1&gt;
  
  
  Working at Google
&lt;/h1&gt;

&lt;p&gt;Later in his career, Ken Thompson worked at:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.google.com?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Google&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;He contributed to various systems and engineering projects.&lt;/p&gt;

&lt;p&gt;Even in modern computing eras, his expertise remained extremely valuable.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Ken Thompson Matters to Programmers
&lt;/h1&gt;

&lt;p&gt;Many beginner programmers focus only on modern frameworks.&lt;/p&gt;

&lt;p&gt;But understanding pioneers like Ken Thompson teaches deeper lessons.&lt;/p&gt;

&lt;p&gt;He teaches us:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Simplicity Is Powerful
&lt;/h2&gt;

&lt;p&gt;Complexity is not intelligence.&lt;/p&gt;

&lt;p&gt;Clear systems often outperform complicated ones.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Good Tools Matter
&lt;/h2&gt;

&lt;p&gt;Developer productivity depends heavily on tools.&lt;/p&gt;

&lt;p&gt;UNIX tools changed how programmers work.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Software Design Matters
&lt;/h2&gt;

&lt;p&gt;Architecture decisions can influence decades of technology.&lt;/p&gt;

&lt;p&gt;UNIX ideas survived for over 50 years.&lt;/p&gt;

&lt;p&gt;That is extraordinary.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Elegant Thinking Beats Hype
&lt;/h2&gt;

&lt;p&gt;Ken Thompson was not known for marketing.&lt;/p&gt;

&lt;p&gt;He was known for solving problems well.&lt;/p&gt;




&lt;h1&gt;
  
  
  Ken Thompson’s Lasting Legacy
&lt;/h1&gt;

&lt;p&gt;Today, millions of developers unknowingly use his ideas every day.&lt;/p&gt;

&lt;p&gt;When you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open a Linux terminal&lt;/li&gt;
&lt;li&gt;Use macOS&lt;/li&gt;
&lt;li&gt;Run cloud servers&lt;/li&gt;
&lt;li&gt;Write UTF-8 text&lt;/li&gt;
&lt;li&gt;Use command-line pipelines&lt;/li&gt;
&lt;li&gt;Study operating systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;you are interacting with Thompson’s legacy.&lt;/p&gt;

&lt;p&gt;Very few individuals have shaped computing this deeply.&lt;/p&gt;

&lt;p&gt;His influence exists beneath the surface of modern technology.&lt;/p&gt;

&lt;p&gt;Invisible. Foundational. Permanent.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Ken Thompson is one of the true architects of modern computing.&lt;/p&gt;

&lt;p&gt;He helped create systems and philosophies that transformed software engineering forever.&lt;/p&gt;

&lt;p&gt;What makes his story especially important is this:&lt;/p&gt;

&lt;p&gt;He did not chase complexity.&lt;br&gt;
He chased clarity.&lt;/p&gt;

&lt;p&gt;He did not build technology just to impress people.&lt;br&gt;
He built systems that worked beautifully.&lt;/p&gt;

&lt;p&gt;And that mindset is something every programmer should learn.&lt;/p&gt;

&lt;p&gt;Because in the end, the best engineering is often not about adding more.&lt;/p&gt;

&lt;p&gt;It is about understanding what can be removed while keeping the system powerful.&lt;/p&gt;

&lt;p&gt;That was Ken Thompson’s genius.&lt;/p&gt;

</description>
      <category>kenthompson</category>
      <category>farhadrahimiklie</category>
      <category>programming</category>
      <category>c</category>
    </item>
    <item>
      <title>GDB Debugger for C and C++ – Complete Guide</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Mon, 04 May 2026 01:52:31 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/gdb-debugger-for-c-and-c-complete-guide-3jan</link>
      <guid>https://dev.to/farhadrahimiklie/gdb-debugger-for-c-and-c-complete-guide-3jan</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Debugging is a critical skill for any systems programmer working with C or C++. Unlike higher-level languages, C and C++ give you direct access to memory and low-level operations, which makes debugging both powerful and complex. The GNU Debugger (GDB) is one of the most widely used tools for debugging C and C++ programs.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is GDB?
&lt;/h2&gt;

&lt;p&gt;GDB (GNU Debugger) is a command-line debugging tool used to inspect and control the execution of programs. It allows developers to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pause execution (breakpoints)&lt;/li&gt;
&lt;li&gt;Step through code line-by-line&lt;/li&gt;
&lt;li&gt;Inspect variables and memory&lt;/li&gt;
&lt;li&gt;Modify program state at runtime&lt;/li&gt;
&lt;li&gt;Analyze crashes and core dumps&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;GDB works by interfacing with compiled binaries that include debugging symbols.&lt;/p&gt;




&lt;h2&gt;
  
  
  Installing GDB
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Linux (Ubuntu/Debian)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;gdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  macOS (with Homebrew)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;gdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows
&lt;/h3&gt;

&lt;p&gt;Use MinGW or WSL:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install WSL and Ubuntu&lt;/li&gt;
&lt;li&gt;Then install GDB inside WSL&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Compiling with Debug Symbols
&lt;/h2&gt;

&lt;p&gt;To use GDB effectively, you must compile your program with debug information using the &lt;code&gt;-g&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc &lt;span class="nt"&gt;-g&lt;/span&gt; program.c &lt;span class="nt"&gt;-o&lt;/span&gt; program
g++ &lt;span class="nt"&gt;-g&lt;/span&gt; program.cpp &lt;span class="nt"&gt;-o&lt;/span&gt; program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Optional flags:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-O0&lt;/code&gt; → disable optimization (recommended for debugging)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-Wall&lt;/code&gt; → show warnings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc &lt;span class="nt"&gt;-g&lt;/span&gt; &lt;span class="nt"&gt;-O0&lt;/span&gt; &lt;span class="nt"&gt;-Wall&lt;/span&gt; main.c &lt;span class="nt"&gt;-o&lt;/span&gt; main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Starting GDB
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gdb ./program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once inside GDB:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Running the Program
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;run arg1 arg2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Breakpoints
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Set breakpoint at function
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;break &lt;/span&gt;main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Set breakpoint at line
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;break &lt;/span&gt;10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Set breakpoint in file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;break &lt;/span&gt;file.c:25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  List breakpoints
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;info breakpoints
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Delete breakpoint
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;delete 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Stepping Through Code
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step into (enter functions)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;step
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step over (skip function internals)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;next
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Continue execution
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Finish current function
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;finish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Inspecting Variables
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Print variable
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;print x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Print pointer value
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;print &lt;span class="k"&gt;*&lt;/span&gt;ptr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Display automatically
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;display x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Show all local variables
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;info locals
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Working with Memory
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Examine memory
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;x/4x ptr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Format explanation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;4&lt;/code&gt; → number of units&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;x&lt;/code&gt; → hexadecimal format&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;x/10d ptr   &lt;span class="c"&gt;# decimal&lt;/span&gt;
x/5c ptr    &lt;span class="c"&gt;# characters&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Call Stack (Backtrace)
&lt;/h2&gt;

&lt;p&gt;When a crash occurs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;backtrace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shows the function call chain.&lt;/p&gt;

&lt;p&gt;Navigate stack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;frame 0
frame 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Watchpoints
&lt;/h2&gt;

&lt;p&gt;Watchpoints track variable changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;watch x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Breaks when &lt;code&gt;x&lt;/code&gt; changes.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conditional Breakpoints
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;break &lt;/span&gt;20 &lt;span class="k"&gt;if &lt;/span&gt;x &lt;span class="o"&gt;==&lt;/span&gt; 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Modifying Variables
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;set &lt;/span&gt;variable x &lt;span class="o"&gt;=&lt;/span&gt; 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Debugging Segmentation Faults
&lt;/h2&gt;

&lt;p&gt;Compile with &lt;code&gt;-g&lt;/code&gt;, then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gdb ./program
run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When it crashes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;backtrace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;print ptr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Null pointer dereference&lt;/li&gt;
&lt;li&gt;Out-of-bounds array access&lt;/li&gt;
&lt;li&gt;Use-after-free&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Core Dumps
&lt;/h2&gt;

&lt;p&gt;Enable core dumps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ulimit&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; unlimited
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run program → crash generates &lt;code&gt;core&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Analyze:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gdb program core
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Debugging Multi-file Projects
&lt;/h2&gt;

&lt;p&gt;Compile all files with &lt;code&gt;-g&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc &lt;span class="nt"&gt;-g&lt;/span&gt; main.c utils.c &lt;span class="nt"&gt;-o&lt;/span&gt; app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then debug normally.&lt;/p&gt;




&lt;h2&gt;
  
  
  Working with C++ in GDB
&lt;/h2&gt;

&lt;p&gt;GDB supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Classes&lt;/li&gt;
&lt;li&gt;Objects&lt;/li&gt;
&lt;li&gt;Templates&lt;/li&gt;
&lt;li&gt;STL containers (with limitations)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Print object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;print obj
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pretty printing (for STL):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;set &lt;/span&gt;print pretty on
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Advanced Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. TUI Mode (Text UI)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gdb &lt;span class="nt"&gt;-tui&lt;/span&gt; ./program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Layout Commands
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;layout src
layout asm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Disassembly
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;disassemble main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Reverse Debugging (if supported)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;reverse-continue
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Useful GDB Shortcuts
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;r&lt;/td&gt;
&lt;td&gt;run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;c&lt;/td&gt;
&lt;td&gt;continue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;n&lt;/td&gt;
&lt;td&gt;next&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;s&lt;/td&gt;
&lt;td&gt;step&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bt&lt;/td&gt;
&lt;td&gt;backtrace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p&lt;/td&gt;
&lt;td&gt;print&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Example Debugging Session
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Code (buggy)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Steps
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc &lt;span class="nt"&gt;-g&lt;/span&gt; main.c &lt;span class="nt"&gt;-o&lt;/span&gt; main
gdb ./main
&lt;span class="nb"&gt;break &lt;/span&gt;main
run
next
print ptr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see &lt;code&gt;ptr = 0x0&lt;/code&gt; → null pointer → crash.&lt;/p&gt;




&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Always compile with &lt;code&gt;-g&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Disable optimization (&lt;code&gt;-O0&lt;/code&gt;) while debugging&lt;/li&gt;
&lt;li&gt;Use meaningful variable names&lt;/li&gt;
&lt;li&gt;Reproduce bugs consistently&lt;/li&gt;
&lt;li&gt;Use watchpoints for tricky bugs&lt;/li&gt;
&lt;li&gt;Learn keyboard shortcuts&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;GDB is an essential tool for any C/C++ developer. Mastering it allows you to deeply understand program execution, memory behavior, and runtime issues. While it may feel complex initially, consistent practice will make debugging faster and more efficient.&lt;/p&gt;

&lt;p&gt;If you are serious about systems programming, learning GDB is not optional—it is fundamental.&lt;/p&gt;

</description>
      <category>debugger</category>
      <category>gdb</category>
      <category>systemprogramming</category>
      <category>lowlevelprogramming</category>
    </item>
    <item>
      <title>How We Built Our Own Database Engine 🚀</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Sat, 25 Apr 2026 02:28:50 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/how-we-built-our-own-database-engine-5cah</link>
      <guid>https://dev.to/farhadrahimiklie/how-we-built-our-own-database-engine-5cah</guid>
      <description>&lt;p&gt;Building a database engine from scratch might sound intimidating—but it’s one of the most rewarding ways to truly understand how data systems work under the hood. In this article, I’ll walk you through the journey of creating a simple custom database engine, the challenges we faced, and what we learned along the way.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Why Build a Database Engine?
&lt;/h2&gt;

&lt;p&gt;At first, it might seem unnecessary—after all, we already have powerful databases like MySQL, PostgreSQL, and MongoDB. But building your own gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A deep understanding of data storage and retrieval&lt;/li&gt;
&lt;li&gt;Insight into performance optimization&lt;/li&gt;
&lt;li&gt;Hands-on experience with memory management&lt;/li&gt;
&lt;li&gt;Better problem-solving skills as a developer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This project isn’t about replacing existing databases—it’s about learning how they work.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ Core Concepts We Needed
&lt;/h2&gt;

&lt;p&gt;Before writing any code, we had to understand the fundamentals:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Storage Engine
&lt;/h3&gt;

&lt;p&gt;This is how data is physically stored. We chose a simple file-based system where records are written directly to disk.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Data Serialization
&lt;/h3&gt;

&lt;p&gt;We needed a way to convert structured data into a format that can be stored and retrieved efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Indexing
&lt;/h3&gt;

&lt;p&gt;Without indexing, searching would be painfully slow. We implemented a basic indexing mechanism to speed up lookups.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Query Processing
&lt;/h3&gt;

&lt;p&gt;Even a minimal database needs to interpret commands like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;INSERT&lt;/li&gt;
&lt;li&gt;SELECT&lt;/li&gt;
&lt;li&gt;DELETE&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🏗️ Architecture Overview
&lt;/h2&gt;

&lt;p&gt;Our database engine consists of several key components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+---------------------+
|   Query Interface   |
+---------------------+
           |
+---------------------+
|   Query Parser      |
+---------------------+
           |
+---------------------+
| Execution Engine    |
+---------------------+
           |
+---------------------+
| Storage Manager     |
+---------------------+
           |
+---------------------+
| File System         |
+---------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each layer has a specific responsibility, making the system modular and easier to debug.&lt;/p&gt;




&lt;h2&gt;
  
  
  💾 Step 1: Designing the Storage Layer
&lt;/h2&gt;

&lt;p&gt;We started by implementing a simple storage mechanism:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data is stored in binary files&lt;/li&gt;
&lt;li&gt;Each record has a fixed size&lt;/li&gt;
&lt;li&gt;File offsets are used for quick access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example idea in C:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;Record&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We used file operations like &lt;code&gt;fopen&lt;/code&gt;, &lt;code&gt;fwrite&lt;/code&gt;, and &lt;code&gt;fread&lt;/code&gt; to manage data.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 Step 2: Implementing Indexing
&lt;/h2&gt;

&lt;p&gt;To avoid scanning the entire file every time, we added a basic index:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Key → File offset mapping&lt;/li&gt;
&lt;li&gt;Stored in memory for fast lookup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allowed us to jump directly to the record location instead of reading everything.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧾 Step 3: Query Parser
&lt;/h2&gt;

&lt;p&gt;We created a simple parser that understands commands like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;Farhad&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parser splits input into tokens and maps them to operations.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ Step 4: Execution Engine
&lt;/h2&gt;

&lt;p&gt;The execution engine is the brain of the system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Receives parsed queries&lt;/li&gt;
&lt;li&gt;Calls appropriate functions&lt;/li&gt;
&lt;li&gt;Interacts with storage and index&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;INSERT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;insert_record&lt;/span&gt;&lt;span class="p"&gt;(...);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧹 Step 5: Memory Management
&lt;/h2&gt;

&lt;p&gt;Since we were working in C, memory handling was critical:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manual allocation (&lt;code&gt;malloc&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Deallocation (&lt;code&gt;free&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Avoiding leaks and fragmentation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We also implemented simple block management to reuse freed space.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚧 Challenges We Faced
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Data Corruption
&lt;/h3&gt;

&lt;p&gt;A small mistake in file handling could corrupt the entire database.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Synchronization
&lt;/h3&gt;

&lt;p&gt;Ensuring data consistency between memory and disk was tricky.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Performance
&lt;/h3&gt;

&lt;p&gt;Naive implementations were slow—indexing made a huge difference.&lt;/p&gt;




&lt;h2&gt;
  
  
  📈 What We Learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How databases manage data internally&lt;/li&gt;
&lt;li&gt;Importance of abstraction and modular design&lt;/li&gt;
&lt;li&gt;Low-level memory and file system operations&lt;/li&gt;
&lt;li&gt;Trade-offs between simplicity and performance&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 Future Improvements
&lt;/h2&gt;

&lt;p&gt;If we were to take this further:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add B-Tree indexing&lt;/li&gt;
&lt;li&gt;Support complex queries (WHERE, JOIN)&lt;/li&gt;
&lt;li&gt;Implement transactions (ACID properties)&lt;/li&gt;
&lt;li&gt;Add concurrency control&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🎯 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Building your own database engine isn’t just a project—it’s an experience that transforms how you think about data systems. Even a simple implementation teaches concepts that are used in real-world databases at scale.&lt;/p&gt;

&lt;p&gt;If you're a developer who enjoys digging deep into systems, this is one of the best projects you can take on.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Bonus Tip
&lt;/h2&gt;

&lt;p&gt;If you’re planning to share your project on GitHub, include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clear documentation&lt;/li&gt;
&lt;li&gt;Example commands&lt;/li&gt;
&lt;li&gt;Screenshots or demos&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It makes your project much more attractive and understandable.&lt;/p&gt;




&lt;p&gt;Happy coding! 🔥&lt;/p&gt;

</description>
      <category>database</category>
      <category>mongodb</category>
      <category>developing</category>
      <category>programming</category>
    </item>
    <item>
      <title>Binary and Hexadecimal Number Systems — A Complete Guide for Low-Level Programming</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Tue, 21 Apr 2026 09:57:31 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/binary-and-hexadecimal-number-systems-a-complete-guide-for-low-level-programming-f8n</link>
      <guid>https://dev.to/farhadrahimiklie/binary-and-hexadecimal-number-systems-a-complete-guide-for-low-level-programming-f8n</guid>
      <description>&lt;p&gt;When you work close to hardware—whether in C, C++, embedded systems, operating systems, or reverse engineering—you must think like the machine. And machines do not understand decimal numbers. They operate using &lt;strong&gt;binary&lt;/strong&gt; (base-2). To make binary manageable for humans, we use &lt;strong&gt;hexadecimal&lt;/strong&gt; (base-16).&lt;/p&gt;

&lt;p&gt;This article gives you a complete, step-by-step understanding of both systems, with practical insight for real programming scenarios.&lt;/p&gt;




&lt;h1&gt;
  
  
  1. Why Number Systems Matter in Low-Level Programming
&lt;/h1&gt;

&lt;p&gt;At the hardware level:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Memory stores &lt;strong&gt;bits (0 and 1)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;CPU processes &lt;strong&gt;binary instructions&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Registers, pointers, addresses → all binary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But binary is long and hard to read. That’s where hexadecimal comes in—it’s a &lt;strong&gt;compact human-friendly representation of binary&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  2. Binary Number System (Base 2)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  2.1 Definition
&lt;/h2&gt;

&lt;p&gt;Binary uses only two digits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 and 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each position represents a power of 2.&lt;/p&gt;




&lt;h2&gt;
  
  
  2.2 Positional Value
&lt;/h2&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1011₂
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Break it down:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1×2³ + 0×2² + 1×2¹ + 1×2⁰
= 8 + 0 + 2 + 1
= 11₁₀
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2.3 Binary Table (Important to Memorize)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Power&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2⁰&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2¹&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2²&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2³&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2⁴&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2⁵&lt;/td&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2⁶&lt;/td&gt;
&lt;td&gt;64&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2⁷&lt;/td&gt;
&lt;td&gt;128&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These are critical for bit manipulation.&lt;/p&gt;




&lt;h2&gt;
  
  
  2.4 Binary in Memory
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;bit&lt;/strong&gt; = 0 or 1&lt;br&gt;
A &lt;strong&gt;byte&lt;/strong&gt; = 8 bits&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;00001010 → 10 in decimal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2.5 Binary Representation of Numbers
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Positive Numbers
&lt;/h3&gt;

&lt;p&gt;Stored directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5 → 00000101
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Negative Numbers (Two’s Complement)
&lt;/h3&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Convert to binary&lt;/li&gt;
&lt;li&gt;Invert bits&lt;/li&gt;
&lt;li&gt;Add 1&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example: -5 (8-bit)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5      = 00000101
Invert = 11111010
+1     = 11111011
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2.6 Binary Operations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  AND (&amp;amp;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 &amp;amp; 1 = 1
1 &amp;amp; 0 = 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  OR (|)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 | 0 = 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  XOR (^)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 ^ 1 = 0
1 ^ 0 = 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  NOT (~)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~00000101 = 11111010
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2.7 Example in C
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// 00000101&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// 00000011&lt;/span&gt;

    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"AND: %d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"OR : %d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 7&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"XOR: %d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 6&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  3. Hexadecimal Number System (Base 16)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  3.1 Definition
&lt;/h2&gt;

&lt;p&gt;Hexadecimal uses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0–9 and A–F
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Hex&lt;/th&gt;
&lt;th&gt;Decimal&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;E&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  3.2 Why Hexadecimal?
&lt;/h2&gt;

&lt;p&gt;Binary is long:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;11111111
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hex makes it short:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 byte = 8 bits = 2 hex digits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3.3 Positional Value
&lt;/h2&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2F₁₆
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2×16¹ + 15×16⁰
= 32 + 15
= 47₁₀
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3.4 Binary ↔ Hex Conversion (CRITICAL SKILL)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Rule:
&lt;/h3&gt;

&lt;p&gt;Group binary into 4 bits&lt;/p&gt;




&lt;h3&gt;
  
  
  Example 1: Binary → Hex
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10101111
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Group:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1010 1111
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Convert:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1010 = A
1111 = F
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AF₁₆
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Example 2: Hex → Binary
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Convert each:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3 = 0011
C = 1100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;00111100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3.5 Hex in Programming
&lt;/h2&gt;

&lt;h3&gt;
  
  
  C Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// 255&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x1A&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// 26&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Memory Address:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nasm"&gt;&lt;code&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="nf"&gt;x7ffeefbff5c8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  4. Binary vs Hexadecimal (Comparison)
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Binary&lt;/th&gt;
&lt;th&gt;Hexadecimal&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Base&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Digits&lt;/td&gt;
&lt;td&gt;0,1&lt;/td&gt;
&lt;td&gt;0–9, A–F&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Length&lt;/td&gt;
&lt;td&gt;Long&lt;/td&gt;
&lt;td&gt;Short&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Usage&lt;/td&gt;
&lt;td&gt;Machine level&lt;/td&gt;
&lt;td&gt;Human-friendly&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  5. Real Use Cases in Low-Level Programming
&lt;/h1&gt;

&lt;h2&gt;
  
  
  5.1 Memory Inspection
&lt;/h2&gt;

&lt;p&gt;Debugger output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nasm"&gt;&lt;code&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="nf"&gt;x7fff&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="nv"&gt;address&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5.2 Bit Masking
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x0F&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 00001111&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5.3 Embedded Systems
&lt;/h2&gt;

&lt;p&gt;Registers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nasm"&gt;&lt;code&gt;&lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="nf"&gt;xFF00&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="nv"&gt;hardware&lt;/span&gt; &lt;span class="nv"&gt;control&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5.4 Networking
&lt;/h2&gt;

&lt;p&gt;IP (hex view):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C0 A8 01 01 → 192.168.1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5.5 Assembly Language
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nasm"&gt;&lt;code&gt;&lt;span class="nf"&gt;MOV&lt;/span&gt; &lt;span class="nb"&gt;AX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x1F&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  6. Conversion Methods (Step-by-Step)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  6.1 Decimal → Binary
&lt;/h2&gt;

&lt;p&gt;Divide by 2 repeatedly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;13 ÷ 2 = 6 r1
6 ÷ 2  = 3 r0
3 ÷ 2  = 1 r1
1 ÷ 2  = 0 r1

Result: 1101
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  6.2 Decimal → Hex
&lt;/h2&gt;

&lt;p&gt;Divide by 16:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;47 ÷ 16 = 2 r15 (F)
2 ÷ 16  = 0 r2

Result: 2F
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  6.3 Binary → Decimal
&lt;/h2&gt;

&lt;p&gt;Multiply powers of 2.&lt;/p&gt;




&lt;h2&gt;
  
  
  6.4 Hex → Decimal
&lt;/h2&gt;

&lt;p&gt;Multiply powers of 16.&lt;/p&gt;




&lt;h1&gt;
  
  
  7. Important Patterns to Master
&lt;/h1&gt;

&lt;h2&gt;
  
  
  7.1 Hex ↔ Binary Table (Must Memorize)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Hex&lt;/th&gt;
&lt;th&gt;Binary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0001&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0010&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;0011&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;0100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;0101&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;0110&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;0111&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;1000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;1001&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;1010&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;1011&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;1100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;1101&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;E&lt;/td&gt;
&lt;td&gt;1110&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;1111&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  8. Common Mistakes
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Mixing base systems (e.g., treating hex as decimal)&lt;/li&gt;
&lt;li&gt;Forgetting grouping in binary → hex&lt;/li&gt;
&lt;li&gt;Ignoring leading zeros&lt;/li&gt;
&lt;li&gt;Confusing ASCII vs numeric values&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  9. How to Master This (Practical Strategy)
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Memorize powers of 2&lt;/li&gt;
&lt;li&gt;Memorize hex ↔ binary table&lt;/li&gt;
&lt;li&gt;Practice conversions daily&lt;/li&gt;
&lt;li&gt;Use C programs to verify results&lt;/li&gt;
&lt;li&gt;Read memory using debuggers (gdb)&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  10. Final Insight
&lt;/h1&gt;

&lt;p&gt;Binary is the &lt;strong&gt;language of machines&lt;/strong&gt;.&lt;br&gt;
Hexadecimal is the &lt;strong&gt;language of programmers working close to machines&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you master both:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bit manipulation becomes easy&lt;/li&gt;
&lt;li&gt;Debugging becomes powerful&lt;/li&gt;
&lt;li&gt;System programming becomes natural&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>bit</category>
      <category>bitmanipulation</category>
      <category>lowlevel</category>
      <category>programming</category>
    </item>
    <item>
      <title>Mental Models for Programmers: Thinking Beyond Code</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Thu, 16 Apr 2026 03:29:17 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/mental-models-for-programmers-thinking-beyond-code-e31</link>
      <guid>https://dev.to/farhadrahimiklie/mental-models-for-programmers-thinking-beyond-code-e31</guid>
      <description>&lt;p&gt;Programming is not just about syntax, frameworks, or algorithms. At its core, it’s about &lt;strong&gt;how you think&lt;/strong&gt;. The difference between an average developer and a great one often lies in the mental models they use to understand problems, design systems, and debug issues.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is a Mental Model?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;mental model&lt;/strong&gt; is a simplified way of understanding how something works in the real world. In programming, mental models help you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Break down complex systems&lt;/li&gt;
&lt;li&gt;Predict behavior before running code&lt;/li&gt;
&lt;li&gt;Debug efficiently&lt;/li&gt;
&lt;li&gt;Design scalable architectures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of mental models as your internal “toolkit for thinking.”&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Divide and Conquer
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Break complex problems into smaller, manageable parts.&lt;/p&gt;

&lt;p&gt;When you face a large problem, don’t try to solve it all at once. Instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Split it into subproblems&lt;/li&gt;
&lt;li&gt;Solve each independently&lt;/li&gt;
&lt;li&gt;Combine results&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
Building a web app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UI (Frontend)&lt;/li&gt;
&lt;li&gt;API (Backend)&lt;/li&gt;
&lt;li&gt;Database (Storage)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each layer can be developed and tested separately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Reduces cognitive load and improves maintainability.&lt;/p&gt;


&lt;h2&gt;
  
  
  2. Abstraction
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Hide complexity, expose only what’s necessary.&lt;/p&gt;

&lt;p&gt;Good programmers don’t deal with every detail all the time. They create layers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functions hide implementation details&lt;/li&gt;
&lt;li&gt;APIs hide system complexity&lt;/li&gt;
&lt;li&gt;Classes encapsulate behavior
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You don’t care how &lt;code&gt;add&lt;/code&gt; works internally — that’s abstraction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Makes systems easier to use, understand, and scale.&lt;/p&gt;


&lt;h2&gt;
  
  
  3. First Principles Thinking
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Break problems down to fundamental truths and build from there.&lt;/p&gt;

&lt;p&gt;Instead of relying on assumptions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ask: &lt;em&gt;What do I know for sure?&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Rebuild the solution from basics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
Instead of memorizing how a database index works, understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data storage&lt;/li&gt;
&lt;li&gt;Searching cost (O(n) vs O(log n))&lt;/li&gt;
&lt;li&gt;Tree structures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Helps you solve new problems, not just repeat known solutions.&lt;/p&gt;


&lt;h2&gt;
  
  
  4. Trade-offs (There is No Perfect Solution)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Every decision has a cost.&lt;/p&gt;

&lt;p&gt;In programming, you constantly balance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Speed vs Memory&lt;/li&gt;
&lt;li&gt;Readability vs Performance&lt;/li&gt;
&lt;li&gt;Simplicity vs Flexibility&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Array → fast access, slow insert&lt;/li&gt;
&lt;li&gt;Linked list → slow access, fast insert&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Prevents overengineering and helps you choose the &lt;em&gt;right&lt;/em&gt; solution, not the perfect one.&lt;/p&gt;


&lt;h2&gt;
  
  
  5. DRY (Don’t Repeat Yourself)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Avoid duplication.&lt;/p&gt;

&lt;p&gt;If you write the same logic multiple times, it becomes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hard to maintain&lt;/li&gt;
&lt;li&gt;Error-prone&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Extract reusable functions&lt;/li&gt;
&lt;li&gt;Use shared modules&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isAdmin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isAdmin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Good:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;isAdmin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;User&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"admin"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Reduces bugs and improves maintainability.&lt;/p&gt;


&lt;h2&gt;
  
  
  6. KISS (Keep It Simple, Stupid)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Simpler solutions are better.&lt;/p&gt;

&lt;p&gt;Avoid unnecessary complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bad mindset:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Let’s use microservices, AI, and blockchain for this small app.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Good mindset:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What is the simplest solution that works?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Simple systems are easier to debug, extend, and scale.&lt;/p&gt;


&lt;h2&gt;
  
  
  7. YAGNI (You Aren’t Gonna Need It)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Don’t build for the future unnecessarily.&lt;/p&gt;

&lt;p&gt;Programmers often over-engineer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adding features “just in case”&lt;/li&gt;
&lt;li&gt;Designing systems for scale they don’t have&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Reality:&lt;/strong&gt;&lt;br&gt;
Most of those features are never used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Saves time and keeps code clean.&lt;/p&gt;


&lt;h2&gt;
  
  
  8. Feedback Loops
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Shorten the cycle between action and result.&lt;/p&gt;

&lt;p&gt;Fast feedback improves learning and debugging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unit tests&lt;/li&gt;
&lt;li&gt;Logging&lt;/li&gt;
&lt;li&gt;REPL environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
The faster you see results, the faster you improve.&lt;/p&gt;


&lt;h2&gt;
  
  
  9. Systems Thinking
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Everything is connected.&lt;/p&gt;

&lt;p&gt;A bug in one part of the system can affect another.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slow database → slow API → bad user experience&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of thinking in isolation, think in &lt;strong&gt;flows&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input → Processing → Output&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Helps in designing scalable and reliable systems.&lt;/p&gt;


&lt;h2&gt;
  
  
  10. Inversion (Think Backwards)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Start from failure and work backward.&lt;/p&gt;

&lt;p&gt;Ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“How can this system fail?”&lt;/li&gt;
&lt;li&gt;“What could go wrong?”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
Instead of only designing login:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What if password is wrong?&lt;/li&gt;
&lt;li&gt;What if server is down?&lt;/li&gt;
&lt;li&gt;What if user is hacked?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Leads to more robust and secure systems.&lt;/p&gt;


&lt;h2&gt;
  
  
  11. Constraints Drive Creativity
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Limitations improve solutions.&lt;/p&gt;

&lt;p&gt;Constraints like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Low memory&lt;/li&gt;
&lt;li&gt;Slow network&lt;/li&gt;
&lt;li&gt;Limited CPU&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Force you to think smarter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Real-world systems always have constraints.&lt;/p&gt;


&lt;h2&gt;
  
  
  12. Readability &amp;gt; Cleverness
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Core Idea:&lt;/strong&gt; Code is read more than it is written.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bad:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=!!&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Good:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
Your future self (and team) will thank you.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Learning programming languages and frameworks is important — but they change constantly.&lt;/p&gt;

&lt;p&gt;Mental models, however, are &lt;strong&gt;timeless&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you master how to think:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You learn faster&lt;/li&gt;
&lt;li&gt;Solve problems better&lt;/li&gt;
&lt;li&gt;Build systems that last&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Great programmers don’t just write code — they think in systems, trade-offs, and abstractions.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>programmers</category>
      <category>code</category>
      <category>productivity</category>
      <category>problemsolving</category>
    </item>
    <item>
      <title>Git Stash — The Complete Guide Every Developer Should Know</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Mon, 13 Apr 2026 02:19:49 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/git-stash-the-complete-guide-every-developer-should-know-ag9</link>
      <guid>https://dev.to/farhadrahimiklie/git-stash-the-complete-guide-every-developer-should-know-ag9</guid>
      <description>&lt;p&gt;When you're working on a project, it’s very common to start coding something and suddenly realize you need to switch branches, fix a bug, or pull new changes. But your current work is incomplete and not ready to commit.&lt;/p&gt;

&lt;p&gt;This is exactly where &lt;strong&gt;Git Stash&lt;/strong&gt; becomes one of the most powerful tools in your workflow.&lt;/p&gt;

&lt;p&gt;In this article, we will explore Git Stash in depth — from basics to advanced usage — with real-world scenarios and clear explanations.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 What is Git Stash?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Git Stash&lt;/strong&gt; temporarily saves your uncommitted changes (both staged and unstaged) so you can work on something else and come back later.&lt;/p&gt;

&lt;p&gt;Think of it as a &lt;strong&gt;temporary storage (clipboard)&lt;/strong&gt; for your code changes.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Why Use Git Stash?
&lt;/h2&gt;

&lt;p&gt;Here are common scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You are in the middle of work but need to switch branches&lt;/li&gt;
&lt;li&gt;You need to quickly fix a bug in production&lt;/li&gt;
&lt;li&gt;You want to pull latest changes but your working directory is dirty&lt;/li&gt;
&lt;li&gt;You want a clean working tree without committing incomplete work&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📦 Basic Usage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Save Changes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Saves your modified tracked files&lt;/li&gt;
&lt;li&gt;Reverts your working directory to the last commit&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. View Stashes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stash@{0}: WIP on main: 123abc Fix login bug
stash@{1}: WIP on feature: 456def Add new API
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Apply Stash
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This restores the latest stash but &lt;strong&gt;keeps it in the stash list&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Apply and Remove (Pop)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash pop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Applies the stash&lt;/li&gt;
&lt;li&gt;Removes it from the stash list&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  5. Drop a Stash
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash drop stash@&lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deletes a specific stash.&lt;/p&gt;




&lt;h3&gt;
  
  
  6. Clear All Stashes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash clear
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚠️ Warning: This deletes all stashes permanently.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 Stashing Specific Changes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Stash Only Staged Changes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash &lt;span class="nt"&gt;--staged&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Stash Including Untracked Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash &lt;span class="nt"&gt;-u&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash &lt;span class="nt"&gt;--include-untracked&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Stash Everything (Including Ignored Files)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🏷️ Naming Your Stash
&lt;/h2&gt;

&lt;p&gt;Instead of default messages, you can name your stash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash push &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"WIP: payment integration"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps a lot when managing multiple stashes.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔄 Applying Specific Stash
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash apply stash@&lt;span class="o"&gt;{&lt;/span&gt;1&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔀 Create Branch from Stash
&lt;/h2&gt;

&lt;p&gt;One of the most useful features:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash branch new-branch-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a new branch&lt;/li&gt;
&lt;li&gt;Applies the stash&lt;/li&gt;
&lt;li&gt;Removes it from stash list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Perfect when your temporary work becomes important.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚠️ Handling Conflicts
&lt;/h2&gt;

&lt;p&gt;When applying a stash, conflicts may occur if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The same lines were changed&lt;/li&gt;
&lt;li&gt;The codebase has evolved&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Git will mark conflicts just like a merge:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;lt; HEAD
Your current code
&lt;span class="o"&gt;=======&lt;/span&gt;
Stashed code
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You must resolve these manually.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Internal Working (Advanced)
&lt;/h2&gt;

&lt;p&gt;When you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git actually creates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A commit for your working directory&lt;/li&gt;
&lt;li&gt;A commit for your index (staged changes)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are stored in a special reference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;refs/stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So stash is not magic — it's structured commits behind the scenes.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔥 Real-World Workflow Example
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Scenario:
&lt;/h3&gt;

&lt;p&gt;You're working on a feature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout feature-auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You modify files but suddenly:&lt;/p&gt;

&lt;p&gt;👉 You must fix a bug in &lt;code&gt;main&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash
git checkout main
&lt;span class="c"&gt;# fix bug&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"hotfix: login issue"&lt;/span&gt;
git checkout feature-auth
git stash pop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’re back exactly where you left off.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use descriptive stash messages&lt;/li&gt;
&lt;li&gt;Avoid keeping too many stashes&lt;/li&gt;
&lt;li&gt;Prefer branches for long-term work&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;git stash pop&lt;/code&gt; carefully (it deletes stash)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ❌ Common Mistakes
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Forgetting stash exists → losing track of work&lt;/li&gt;
&lt;li&gt;Using stash instead of proper commits&lt;/li&gt;
&lt;li&gt;Not naming stashes → confusion later&lt;/li&gt;
&lt;li&gt;Clearing stash accidentally&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🧠 Pro Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;git stash show -p&lt;/code&gt; to see full diff:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash show &lt;span class="nt"&gt;-p&lt;/span&gt; stash@&lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Stash only part of changes (interactive):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Combine with rebase or pull for cleaner workflow&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🎯 Conclusion
&lt;/h2&gt;

&lt;p&gt;Git Stash is a &lt;strong&gt;powerful, flexible tool&lt;/strong&gt; that helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Switch context quickly&lt;/li&gt;
&lt;li&gt;Keep your work safe&lt;/li&gt;
&lt;li&gt;Maintain a clean workflow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But remember:&lt;/p&gt;

&lt;p&gt;👉 It’s a temporary solution, not a replacement for commits or branches.&lt;/p&gt;

&lt;p&gt;Mastering Git Stash will significantly improve your productivity and confidence when working with Git.&lt;/p&gt;

</description>
      <category>git</category>
      <category>gitstash</category>
      <category>productivity</category>
      <category>programmers</category>
    </item>
    <item>
      <title>Git Merge vs Rebase — A Complete Guide for Developers</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Thu, 09 Apr 2026 04:07:43 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/git-merge-vs-rebase-a-complete-guide-for-developers-186l</link>
      <guid>https://dev.to/farhadrahimiklie/git-merge-vs-rebase-a-complete-guide-for-developers-186l</guid>
      <description>&lt;p&gt;When working with version control using Git, one of the most important concepts you must master is how to integrate changes from one branch into another. Two primary strategies exist for this: &lt;strong&gt;merge&lt;/strong&gt; and &lt;strong&gt;rebase&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Although both achieve the same goal—combining changes—they do so in fundamentally different ways. Understanding these differences is critical for maintaining a clean, understandable project history.&lt;/p&gt;




&lt;h1&gt;
  
  
  🔹 What is Git Merge?
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Concept
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Git merge&lt;/strong&gt; combines two branches by creating a new &lt;em&gt;merge commit&lt;/em&gt;. It preserves the complete history of both branches.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it Works
&lt;/h2&gt;

&lt;p&gt;Imagine this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C (main)
     \
      D---E (feature)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout main
git merge feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git creates a new commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C-------M (main)
     \         /
      D---E--- (feature)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 &lt;code&gt;M&lt;/code&gt; is the merge commit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Characteristics
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Preserves full history&lt;/li&gt;
&lt;li&gt;Non-destructive operation&lt;/li&gt;
&lt;li&gt;Creates extra commit (merge commit)&lt;/li&gt;
&lt;li&gt;Shows exact branching structure&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advantages
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Safe and simple&lt;/li&gt;
&lt;li&gt;Keeps context of how features were developed&lt;/li&gt;
&lt;li&gt;Ideal for team collaboration&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Disadvantages
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;History becomes messy with many branches&lt;/li&gt;
&lt;li&gt;Harder to read in large projects&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  🔹 What is Git Rebase?
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Concept
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Git rebase&lt;/strong&gt; moves (or “replays”) commits from one branch on top of another, creating a linear history.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it Works
&lt;/h2&gt;

&lt;p&gt;Starting from:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C (main)
     \
      D---E (feature)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout feature
git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C---D'---E' (feature)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 &lt;code&gt;D'&lt;/code&gt; and &lt;code&gt;E'&lt;/code&gt; are &lt;em&gt;new commits&lt;/em&gt; (rewritten history).&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Characteristics
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Rewrites commit history&lt;/li&gt;
&lt;li&gt;No merge commit&lt;/li&gt;
&lt;li&gt;Creates a linear timeline&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advantages
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Clean, linear history&lt;/li&gt;
&lt;li&gt;Easier to understand logs&lt;/li&gt;
&lt;li&gt;Better for debugging and tracking changes&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Disadvantages
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Can be dangerous if misused&lt;/li&gt;
&lt;li&gt;Rewrites history (problematic for shared branches)&lt;/li&gt;
&lt;li&gt;Requires more understanding&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  🔥 Merge vs Rebase — Side-by-Side
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Merge&lt;/th&gt;
&lt;th&gt;Rebase&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;History&lt;/td&gt;
&lt;td&gt;Preserved (non-linear)&lt;/td&gt;
&lt;td&gt;Rewritten (linear)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Commit creation&lt;/td&gt;
&lt;td&gt;Creates merge commit&lt;/td&gt;
&lt;td&gt;No merge commit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Safety&lt;/td&gt;
&lt;td&gt;Very safe&lt;/td&gt;
&lt;td&gt;Risky if shared&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Readability&lt;/td&gt;
&lt;td&gt;Can be messy&lt;/td&gt;
&lt;td&gt;Clean and linear&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use case&lt;/td&gt;
&lt;td&gt;Team collaboration&lt;/td&gt;
&lt;td&gt;Clean history before merge&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  ⚠️ When to Use Merge
&lt;/h1&gt;

&lt;p&gt;Use &lt;strong&gt;merge&lt;/strong&gt; when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Working on shared/public branches&lt;/li&gt;
&lt;li&gt;Collaborating with a team&lt;/li&gt;
&lt;li&gt;You want to preserve full history&lt;/li&gt;
&lt;li&gt;You want a safe operation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout main
git merge feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  ⚠️ When to Use Rebase
&lt;/h1&gt;

&lt;p&gt;Use &lt;strong&gt;rebase&lt;/strong&gt; when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cleaning up your local commits&lt;/li&gt;
&lt;li&gt;Preparing a feature branch before merging&lt;/li&gt;
&lt;li&gt;You want a linear history&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout feature
git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  🚨 Golden Rule of Rebase
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Never rebase a shared branch&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because rebase rewrites history. If others are working on the same branch, rebasing will cause conflicts and confusion.&lt;/p&gt;




&lt;h1&gt;
  
  
  🔧 Interactive Rebase (Advanced)
&lt;/h1&gt;

&lt;p&gt;One of the most powerful features of rebase is &lt;strong&gt;interactive mode&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase &lt;span class="nt"&gt;-i&lt;/span&gt; HEAD~3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Squash commits&lt;/li&gt;
&lt;li&gt;Rename commit messages&lt;/li&gt;
&lt;li&gt;Reorder commits&lt;/li&gt;
&lt;li&gt;Remove unnecessary commits&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pick 1st commit
squash 2nd commit
reword 3rd commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  🧠 Real-World Workflow
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Typical Professional Workflow:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create feature branch&lt;/li&gt;
&lt;li&gt;Work and commit changes&lt;/li&gt;
&lt;li&gt;Rebase onto latest main&lt;/li&gt;
&lt;li&gt;Merge into main
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout feature
git rebase main
git checkout main
git merge feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  🔄 Visual Comparison
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Merge History (Non-linear)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C-------M
     \         /
      D---E---
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Rebase History (Linear)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C---D'---E'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  🏁 Conclusion
&lt;/h1&gt;

&lt;p&gt;Both &lt;strong&gt;merge&lt;/strong&gt; and &lt;strong&gt;rebase&lt;/strong&gt; are essential tools in Git, and neither is “better” universally—it depends on your workflow.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;merge&lt;/strong&gt; for safety and collaboration&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;rebase&lt;/strong&gt; for clean, readable history&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 The best developers know &lt;strong&gt;when to use each&lt;/strong&gt;, not just how.&lt;/p&gt;




&lt;h1&gt;
  
  
  💬 Final Tip
&lt;/h1&gt;

&lt;p&gt;If you're working in a team, always follow your team's Git strategy. Consistency matters more than preference.&lt;/p&gt;

</description>
      <category>git</category>
      <category>gitmerge</category>
      <category>gitrebase</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Why Git Rebase Will Change How You Use Git Forever</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Tue, 07 Apr 2026 02:35:30 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/why-git-rebase-will-change-how-you-use-git-forever-51ie</link>
      <guid>https://dev.to/farhadrahimiklie/why-git-rebase-will-change-how-you-use-git-forever-51ie</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When working with Git, managing commit history is just as important as writing clean code. One of the most powerful — and sometimes misunderstood — tools for this purpose is &lt;strong&gt;git rebase&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Git Rebase?
&lt;/h2&gt;

&lt;p&gt;At a high level, &lt;strong&gt;git rebase&lt;/strong&gt; is used to move or “replay” commits from one branch onto another.&lt;/p&gt;

&lt;p&gt;Instead of merging branches together (like &lt;code&gt;git merge&lt;/code&gt;), rebase rewrites commit history to make it look like your work was built on top of another branch from the beginning.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Core Idea
&lt;/h2&gt;

&lt;p&gt;Let’s say you have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main:     A --- B --- C
feature:             D --- E
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, new commits are added to &lt;code&gt;main&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main:     A --- B --- C --- F --- G
feature:             D --- E
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git will:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Temporarily remove commits &lt;code&gt;D&lt;/code&gt; and &lt;code&gt;E&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Move your branch to &lt;code&gt;G&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Replay &lt;code&gt;D&lt;/code&gt; and &lt;code&gt;E&lt;/code&gt; on top of &lt;code&gt;G&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main:     A --- B --- C --- F --- G
feature:                         D' --- E'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: &lt;code&gt;D'&lt;/code&gt; and &lt;code&gt;E'&lt;/code&gt; are new commits (rewritten versions)&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Why Use Rebase?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Clean History
&lt;/h3&gt;

&lt;p&gt;Rebase creates a &lt;strong&gt;linear commit history&lt;/strong&gt;, making it easier to read and understand.&lt;/p&gt;

&lt;p&gt;Instead of this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      /--- D --- E
A --- B --- C --- M
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A --- B --- C --- D --- E
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2. Better for Code Reviews
&lt;/h3&gt;

&lt;p&gt;Reviewing a clean, linear history is much easier than dealing with merge commits.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Avoids Unnecessary Merge Commits
&lt;/h3&gt;

&lt;p&gt;Rebase prevents clutter like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Merge branch &lt;span class="s1"&gt;'main'&lt;/span&gt; into feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Rebase vs Merge
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;git merge&lt;/th&gt;
&lt;th&gt;git rebase&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;History&lt;/td&gt;
&lt;td&gt;Non-linear&lt;/td&gt;
&lt;td&gt;Linear&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;New commits&lt;/td&gt;
&lt;td&gt;Adds merge commit&lt;/td&gt;
&lt;td&gt;Rewrites commits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Safety&lt;/td&gt;
&lt;td&gt;Safe (no rewrite)&lt;/td&gt;
&lt;td&gt;Risky if misused&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Collaboration&lt;/td&gt;
&lt;td&gt;Preferred&lt;/td&gt;
&lt;td&gt;Careful usage needed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Basic Commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Rebase current branch onto another
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Interactive Rebase
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase &lt;span class="nt"&gt;-i&lt;/span&gt; HEAD~3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Edit commits&lt;/li&gt;
&lt;li&gt;Squash commits&lt;/li&gt;
&lt;li&gt;Reorder commits&lt;/li&gt;
&lt;li&gt;Remove commits&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;pick&lt;/span&gt; &lt;span class="m"&gt;123&lt;/span&gt;&lt;span class="n"&gt;abc&lt;/span&gt; &lt;span class="n"&gt;Add&lt;/span&gt; &lt;span class="n"&gt;login&lt;/span&gt;
&lt;span class="n"&gt;pick&lt;/span&gt; &lt;span class="m"&gt;456&lt;/span&gt;&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;Fix&lt;/span&gt; &lt;span class="n"&gt;bug&lt;/span&gt;
&lt;span class="n"&gt;pick&lt;/span&gt; &lt;span class="m"&gt;789&lt;/span&gt;&lt;span class="n"&gt;ghi&lt;/span&gt; &lt;span class="n"&gt;Improve&lt;/span&gt; &lt;span class="n"&gt;UI&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can change to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;pick&lt;/span&gt; &lt;span class="m"&gt;123&lt;/span&gt;&lt;span class="n"&gt;abc&lt;/span&gt; &lt;span class="n"&gt;Add&lt;/span&gt; &lt;span class="n"&gt;login&lt;/span&gt;
&lt;span class="n"&gt;squash&lt;/span&gt; &lt;span class="m"&gt;456&lt;/span&gt;&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;Fix&lt;/span&gt; &lt;span class="n"&gt;bug&lt;/span&gt;
&lt;span class="n"&gt;pick&lt;/span&gt; &lt;span class="m"&gt;789&lt;/span&gt;&lt;span class="n"&gt;ghi&lt;/span&gt; &lt;span class="n"&gt;Improve&lt;/span&gt; &lt;span class="n"&gt;UI&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  What Happens Internally?
&lt;/h2&gt;

&lt;p&gt;When you run rebase:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Git finds the common ancestor&lt;/li&gt;
&lt;li&gt;Extracts your commits as patches&lt;/li&gt;
&lt;li&gt;Resets your branch pointer&lt;/li&gt;
&lt;li&gt;Applies patches one by one&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is why commit hashes change — they are &lt;strong&gt;new commits&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Handling Conflicts
&lt;/h2&gt;

&lt;p&gt;During rebase, conflicts may occur.&lt;/p&gt;

&lt;p&gt;Git will pause and show:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONFLICT (content): Merge conflict in file.c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Steps to resolve:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fix the conflict manually&lt;/li&gt;
&lt;li&gt;Stage the file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git add file.c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Continue:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git rebase &lt;span class="nt"&gt;--continue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase &lt;span class="nt"&gt;--abort&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Golden Rule of Rebase
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;❗ Never rebase public/shared branches&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because rebase rewrites history, and this can break other developers’ work.&lt;/p&gt;




&lt;h2&gt;
  
  
  When Should You Use Rebase?
&lt;/h2&gt;

&lt;p&gt;Use rebase when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Working on local feature branches&lt;/li&gt;
&lt;li&gt;Cleaning up commits before pushing&lt;/li&gt;
&lt;li&gt;Keeping history linear&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Avoid rebase when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Working on shared branches&lt;/li&gt;
&lt;li&gt;The branch is already pushed and used by others&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Advanced Example: Squashing Commits
&lt;/h2&gt;

&lt;p&gt;Before:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Add feature
Fix typo
Fix bug
Improve code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After squash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Add feature (clean version)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase &lt;span class="nt"&gt;-i&lt;/span&gt; HEAD~4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Common Mistakes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Rebasing Shared Branches
&lt;/h3&gt;

&lt;p&gt;This can cause major confusion and broken history.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Forgetting Force Push
&lt;/h3&gt;

&lt;p&gt;After rebase, you must push with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(or safer:)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Losing Commits
&lt;/h3&gt;

&lt;p&gt;If something goes wrong:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reflog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can recover lost commits.&lt;/p&gt;




&lt;h2&gt;
  
  
  Mental Model
&lt;/h2&gt;

&lt;p&gt;Think of rebase as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Take my changes and pretend I wrote them after the latest version of the branch.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Git Rebase is a powerful tool that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keeps history clean&lt;/li&gt;
&lt;li&gt;Improves collaboration (when used correctly)&lt;/li&gt;
&lt;li&gt;Helps maintain a professional commit structure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But it must be used with discipline and understanding.&lt;/p&gt;

&lt;p&gt;If you master rebase, you move from just “using Git” to truly &lt;strong&gt;controlling your project history&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Tip
&lt;/h2&gt;

&lt;p&gt;Start using rebase in your &lt;strong&gt;local workflow first&lt;/strong&gt;, then gradually introduce it into team practices with clear guidelines.&lt;/p&gt;




&lt;p&gt;Happy coding 🚀&lt;/p&gt;

</description>
      <category>git</category>
      <category>rebase</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Zig Programming Language — Complete Guide</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Sat, 04 Apr 2026 02:57:47 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/zig-programming-language-complete-guide-38kf</link>
      <guid>https://dev.to/farhadrahimiklie/zig-programming-language-complete-guide-38kf</guid>
      <description>&lt;p&gt;If you're a systems programmer—or want to become one—&lt;strong&gt;Zig&lt;/strong&gt; is a language you cannot ignore. It is designed as a &lt;strong&gt;modern alternative to C&lt;/strong&gt;, focusing on simplicity, performance, and control without hidden behavior.&lt;/p&gt;




&lt;h1&gt;
  
  
  1. What is Zig?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Zig&lt;/strong&gt; is a &lt;strong&gt;low-level, general-purpose programming language&lt;/strong&gt; designed for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Systems programming&lt;/li&gt;
&lt;li&gt;Embedded development&lt;/li&gt;
&lt;li&gt;Performance-critical applications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Created by &lt;strong&gt;Andrew Kelley&lt;/strong&gt;&lt;br&gt;
👉 First released in 2015&lt;/p&gt;


&lt;h1&gt;
  
  
  2. Design Philosophy
&lt;/h1&gt;

&lt;p&gt;Zig is built on a few strong principles:&lt;/p&gt;


&lt;h2&gt;
  
  
  1. No Hidden Control Flow
&lt;/h2&gt;

&lt;p&gt;Unlike many languages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No hidden allocations&lt;/li&gt;
&lt;li&gt;No exceptions&lt;/li&gt;
&lt;li&gt;No implicit behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Everything is explicit.&lt;/p&gt;


&lt;h2&gt;
  
  
  2. Manual Memory Management
&lt;/h2&gt;

&lt;p&gt;Like C:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You control memory&lt;/li&gt;
&lt;li&gt;No garbage collector&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But safer and clearer.&lt;/p&gt;


&lt;h2&gt;
  
  
  3. Simplicity Over Abstraction
&lt;/h2&gt;

&lt;p&gt;Zig avoids:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complex OOP systems&lt;/li&gt;
&lt;li&gt;Heavy abstractions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Focus = clarity + control&lt;/p&gt;


&lt;h2&gt;
  
  
  4. Compile-Time Execution
&lt;/h2&gt;

&lt;p&gt;Zig has powerful &lt;strong&gt;compile-time evaluation&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code can run at compile time&lt;/li&gt;
&lt;li&gt;Enables metaprogramming&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;
  
  
  3. Installing Zig
&lt;/h1&gt;

&lt;p&gt;Download from:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://ziglang.org" rel="noopener noreferrer"&gt;https://ziglang.org&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zig version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  4. Your First Zig Program
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;@import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"std"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, Zig!&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="p"&gt;{});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zig run main.zig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  5. Basic Syntax
&lt;/h1&gt;




&lt;h2&gt;
  
  
  Variables
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c"&gt;// mutable&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;// immutable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Type inference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Primitive Types
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Integers: &lt;code&gt;i32&lt;/code&gt;, &lt;code&gt;u64&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Float: &lt;code&gt;f32&lt;/code&gt;, &lt;code&gt;f64&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Boolean: &lt;code&gt;bool&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Void: &lt;code&gt;void&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Control Flow
&lt;/h2&gt;

&lt;h3&gt;
  
  
  If
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// do something&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// do something else&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  While
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  For
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  6. Functions
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Multiple Return (Error Union)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="n"&gt;divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;DivisionByZero&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  7. Error Handling (Very Important)
&lt;/h1&gt;

&lt;p&gt;Zig does &lt;strong&gt;not use exceptions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead:&lt;/p&gt;




&lt;h2&gt;
  
  
  Error Union
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Try Keyword
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="n"&gt;divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 If error → return immediately&lt;/p&gt;




&lt;h2&gt;
  
  
  Error Sets
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;error&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;OutOfMemory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;InvalidInput&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  8. Pointers
&lt;/h1&gt;

&lt;p&gt;Zig uses pointers like C, but safer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dereference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="n"&gt;ptr&lt;/span&gt;&lt;span class="o"&gt;.*&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Nullable Pointer
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;ptr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;?*&lt;/span&gt;&lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  9. Arrays and Slices
&lt;/h1&gt;




&lt;h2&gt;
  
  
  Array
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Slice (View into array)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;slice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Slices are widely used in Zig&lt;/p&gt;




&lt;h1&gt;
  
  
  10. Structs
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;u8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;u8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Ali"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  11. Enums
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Red&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Green&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Blue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  12. Memory Management
&lt;/h1&gt;

&lt;p&gt;Zig uses &lt;strong&gt;allocators explicitly&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;allocator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;page_allocator&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;memory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="n"&gt;allocator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;alloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;allocator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Key Idea
&lt;/h2&gt;

&lt;p&gt;👉 You always know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where memory comes from&lt;/li&gt;
&lt;li&gt;Who frees it&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  13. Defer Keyword
&lt;/h1&gt;

&lt;p&gt;Runs code when scope ends:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Done&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="p"&gt;{});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  14. Compile-Time Programming (Zig Superpower)
&lt;/h1&gt;




&lt;h2&gt;
  
  
  comptime
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="n"&gt;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;comptime&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Example: Generate Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;inline&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Executed at compile time&lt;/p&gt;




&lt;h1&gt;
  
  
  15. No Preprocessor (Unlike C)
&lt;/h1&gt;

&lt;p&gt;Zig replaces macros with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;comptime&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Cleaner and safer&lt;/p&gt;




&lt;h1&gt;
  
  
  16. Interoperability with C
&lt;/h1&gt;

&lt;p&gt;Zig can directly use C code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Import C
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;@cImport&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nb"&gt;@cInclude&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"stdio.h"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;👉 You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Call C functions&lt;/li&gt;
&lt;li&gt;Use C libraries&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  17. Build System (Built-in)
&lt;/h1&gt;

&lt;p&gt;Zig includes its own build system.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;@import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"std"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;exe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addExecutable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"app"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"main.zig"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;exe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;install&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zig build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  18. Cross Compilation (Very Powerful)
&lt;/h1&gt;

&lt;p&gt;Zig can compile for different platforms easily:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zig build-exe main.zig &lt;span class="nt"&gt;-target&lt;/span&gt; x86_64-linux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 No external toolchains needed&lt;/p&gt;




&lt;h1&gt;
  
  
  19. Testing in Zig
&lt;/h1&gt;

&lt;p&gt;Built-in testing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="k"&gt;test&lt;/span&gt; &lt;span class="s"&gt;"addition works"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;testing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zig &lt;span class="nb"&gt;test &lt;/span&gt;main.zig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  20. Performance
&lt;/h1&gt;

&lt;p&gt;Zig is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Comparable to C&lt;/li&gt;
&lt;li&gt;No runtime overhead&lt;/li&gt;
&lt;li&gt;Zero-cost abstractions&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  21. Zig vs C
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;C&lt;/th&gt;
&lt;th&gt;Zig&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Memory control&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Safety&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Higher&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Build system&lt;/td&gt;
&lt;td&gt;External&lt;/td&gt;
&lt;td&gt;Built-in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Error handling&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;td&gt;Structured&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Compile-time&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;Powerful&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  22. Zig vs Rust
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Zig&lt;/th&gt;
&lt;th&gt;Rust&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Complexity&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Safety model&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;td&gt;Ownership&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Learning curve&lt;/td&gt;
&lt;td&gt;Easier&lt;/td&gt;
&lt;td&gt;Harder&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Control&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  23. When to Use Zig
&lt;/h1&gt;

&lt;p&gt;Use Zig for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OS development&lt;/li&gt;
&lt;li&gt;Game engines&lt;/li&gt;
&lt;li&gt;Embedded systems&lt;/li&gt;
&lt;li&gt;Custom databases&lt;/li&gt;
&lt;li&gt;High-performance tools&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  24. When NOT to Use Zig
&lt;/h1&gt;

&lt;p&gt;Avoid if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need large ecosystem&lt;/li&gt;
&lt;li&gt;You want rapid prototyping&lt;/li&gt;
&lt;li&gt;You prefer high-level abstractions&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  25. Real-World Use Cases
&lt;/h1&gt;

&lt;p&gt;Zig is used in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Game development&lt;/li&gt;
&lt;li&gt;Compilers&lt;/li&gt;
&lt;li&gt;CLI tools&lt;/li&gt;
&lt;li&gt;Replacing C in systems&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  26. Roadmap to Master Zig
&lt;/h1&gt;

&lt;p&gt;If you're serious:&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Basics
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Syntax&lt;/li&gt;
&lt;li&gt;Types&lt;/li&gt;
&lt;li&gt;Control flow&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 2: Core Systems Concepts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Memory management&lt;/li&gt;
&lt;li&gt;Pointers&lt;/li&gt;
&lt;li&gt;Allocators&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 3: Advanced Zig
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;comptime&lt;/li&gt;
&lt;li&gt;Error handling&lt;/li&gt;
&lt;li&gt;Build system&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 4: Real Projects
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;File parser&lt;/li&gt;
&lt;li&gt;HTTP server&lt;/li&gt;
&lt;li&gt;Database engine (perfect for you)&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  27. Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Zig is not trying to replace everything.&lt;/p&gt;

&lt;p&gt;👉 It’s trying to fix what’s broken in C&lt;br&gt;
👉 Without adding unnecessary complexity&lt;/p&gt;




&lt;h2&gt;
  
  
  Core Philosophy:
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;"No hidden control flow. No hidden memory allocations. No surprises."&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;If you're a &lt;strong&gt;C programmer building systems (like databases)&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;👉 Zig is one of the best next steps.&lt;/p&gt;

</description>
      <category>zig</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Mastering B-Trees and B+Trees in C: A Complete Guide from Scratch</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Wed, 01 Apr 2026 05:33:06 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/mastering-b-trees-and-btrees-in-c-a-complete-guide-from-scratch-454i</link>
      <guid>https://dev.to/farhadrahimiklie/mastering-b-trees-and-btrees-in-c-a-complete-guide-from-scratch-454i</guid>
      <description>&lt;p&gt;When it comes to &lt;strong&gt;efficient data storage and retrieval&lt;/strong&gt;, &lt;strong&gt;B-Trees&lt;/strong&gt; and &lt;strong&gt;B+Trees&lt;/strong&gt; are the backbone of databases, file systems, and indexing engines. In this article, we will explore these tree structures in &lt;strong&gt;full detail&lt;/strong&gt;, including all functionalities, C implementation, and practical usage. No shortcuts, no skipped steps—everything explained from the ground up.&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 What is a B-Tree?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;B-Tree&lt;/strong&gt; is a &lt;strong&gt;self-balancing search tree&lt;/strong&gt; in which nodes can have multiple keys and children. It maintains sorted data and allows &lt;strong&gt;logarithmic time search, insertion, and deletion&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key properties of a B-Tree of minimum degree &lt;code&gt;T&lt;/code&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Every node contains at most &lt;code&gt;2*T - 1&lt;/code&gt; keys.&lt;/li&gt;
&lt;li&gt;Every non-leaf node has at most &lt;code&gt;2*T&lt;/code&gt; children.&lt;/li&gt;
&lt;li&gt;Every node (except root) has at least &lt;code&gt;T - 1&lt;/code&gt; keys.&lt;/li&gt;
&lt;li&gt;All leaves appear at the same level.&lt;/li&gt;
&lt;li&gt;Keys in a node are always sorted in ascending order.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;B-Trees are widely used in &lt;strong&gt;databases&lt;/strong&gt; like MySQL, PostgreSQL, and filesystems like &lt;strong&gt;NTFS&lt;/strong&gt; and &lt;strong&gt;FAT&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  📌 What is a B+Tree?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;B+Tree&lt;/strong&gt; is an enhanced variant of a B-Tree. The main differences are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Internal nodes store only keys&lt;/strong&gt;, not actual data (pointers to children only).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leaf nodes contain all data&lt;/strong&gt; and are linked as a &lt;strong&gt;linked list&lt;/strong&gt; for sequential access.&lt;/li&gt;
&lt;li&gt;Search is faster for range queries because &lt;strong&gt;leaves are linked&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Key properties:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maintains &lt;strong&gt;sorted order&lt;/strong&gt; of keys.&lt;/li&gt;
&lt;li&gt;Efficient for both &lt;strong&gt;point lookups&lt;/strong&gt; and &lt;strong&gt;range queries&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Widely used in &lt;strong&gt;database indexing&lt;/strong&gt; and &lt;strong&gt;key-value storage systems&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠️ B-Tree Implementation in C
&lt;/h2&gt;

&lt;p&gt;Here’s a &lt;strong&gt;step-by-step C implementation&lt;/strong&gt; of a B-Tree with all functionalities.&lt;/p&gt;

&lt;h3&gt;
  
  
  1️⃣ Node Structure
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="cp"&gt;#define T 2  // Minimum degree
&lt;/span&gt;
&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;BTreeNode&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;            &lt;span class="c1"&gt;// Max keys = 2*T - 1&lt;/span&gt;
    &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;BTreeNode&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;// Max children = 2*T&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                        &lt;span class="c1"&gt;// Number of keys&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;leaf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                     &lt;span class="c1"&gt;// 1 if leaf, 0 otherwise&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2️⃣ Creating a Node
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;createNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;leaf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;leaf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;leaf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3️⃣ Traversal (In-Order)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;traverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;leaf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;traverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
            &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%d "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;leaf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;traverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4️⃣ Searching for a Key
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;leaf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  5️⃣ Insertion
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Split a full child node&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;splitChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;fullChild&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;newChild&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;createNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fullChild&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;leaf&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;newChild&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Copy last T-1 keys to newChild&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;newChild&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fullChild&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="c1"&gt;// Copy child pointers if not leaf&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;fullChild&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;leaf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;newChild&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fullChild&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="n"&gt;fullChild&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Shift parent's children&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;newChild&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Shift parent's keys&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fullChild&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Insert non-full&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;insertNonFull&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;leaf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
            &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;splitChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
                &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;insertNonFull&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Insert wrapper&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;BTreeNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;newRoot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;createNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;newRoot&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;splitChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newRoot&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;insertNonFull&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newRoot&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;newRoot&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;insertNonFull&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  6️⃣ B+Tree Differences
&lt;/h3&gt;

&lt;p&gt;To implement a &lt;strong&gt;B+Tree&lt;/strong&gt; in C:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Internal nodes &lt;strong&gt;store only keys&lt;/strong&gt;, not actual data.&lt;/li&gt;
&lt;li&gt;Leaf nodes &lt;strong&gt;store actual data&lt;/strong&gt; and &lt;strong&gt;point to the next leaf&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Traversal of leaves allows &lt;strong&gt;fast sequential access&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Leaf Node Structure Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;BPlusNode&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;      &lt;span class="c1"&gt;// store actual values&lt;/span&gt;
    &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;BPlusNode&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;BPlusNode&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// link to next leaf&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;leaf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;BPlusNode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The insertion, split, and search logic are &lt;strong&gt;similar&lt;/strong&gt;, but all data moves to leaves, and internal nodes serve only as &lt;strong&gt;guides&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ Practical Applications
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Database Indexing:&lt;/strong&gt; MySQL, PostgreSQL, Oracle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File Systems:&lt;/strong&gt; NTFS, FAT, and ext4.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key-Value Stores:&lt;/strong&gt; RocksDB, LevelDB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Range Queries:&lt;/strong&gt; B+Trees are preferred for fast sequential access.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔑 Key Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;B-Trees&lt;/strong&gt;: Balanced multi-way search trees; internal and leaf nodes store data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;B+Trees&lt;/strong&gt;: Leaf-linked trees; all data stored in leaves; ideal for sequential access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time Complexity:&lt;/strong&gt; Search, Insert, Delete = O(log n).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;C Implementation:&lt;/strong&gt; Stepwise insertion, split, search, and traversal explained.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-World Impact:&lt;/strong&gt; Foundation of modern database and filesystem performance.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  💻 Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Implement &lt;strong&gt;deletion&lt;/strong&gt; in B-Trees and B+Trees.&lt;/li&gt;
&lt;li&gt;Add &lt;strong&gt;range query&lt;/strong&gt; support for B+Trees.&lt;/li&gt;
&lt;li&gt;Optimize memory usage for large-scale datasets.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;With this, you now have a &lt;strong&gt;complete understanding and code reference&lt;/strong&gt; for B-Trees and B+Trees in C. Whether you are building a database, file system, or an indexing engine, this knowledge is foundational.&lt;/p&gt;

</description>
      <category>btree</category>
      <category>database</category>
      <category>datastructures</category>
      <category>bplustree</category>
    </item>
    <item>
      <title>Dennis Ritchie: The Architect Behind C and UNIX</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Tue, 31 Mar 2026 03:23:17 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/dennis-ritchie-the-architect-behind-c-and-unix-3g61</link>
      <guid>https://dev.to/farhadrahimiklie/dennis-ritchie-the-architect-behind-c-and-unix-3g61</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Modern computing runs on layers of abstraction—but at the foundation of those layers lies a language and a philosophy that shaped everything above it.&lt;/p&gt;

&lt;p&gt;That foundation was built by Dennis Ritchie.&lt;/p&gt;

&lt;p&gt;If you have ever written C, C++, Java, or even worked with operating systems like Linux or macOS, you are indirectly building on Ritchie’s work. He didn’t just create tools—he defined how software interfaces with hardware in a practical, portable, and efficient way.&lt;/p&gt;




&lt;h2&gt;
  
  
  Early Life and Background
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Birth and Education
&lt;/h3&gt;

&lt;p&gt;Dennis Ritchie was born on September 9, 1941, in Bronxville.&lt;/p&gt;

&lt;p&gt;He grew up in an intellectually stimulating environment. His father, Alistair Ritchie, was a Bell Labs scientist who worked on early switching systems—an influence that subtly introduced Dennis to the world of computing.&lt;/p&gt;

&lt;p&gt;Ritchie later attended Harvard University, where he earned degrees in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Physics (Bachelor’s)&lt;/li&gt;
&lt;li&gt;Applied Mathematics (Ph.D.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Although his formal education wasn’t strictly in computer science, his mathematical training gave him a strong foundation in logical thinking and system design.&lt;/p&gt;




&lt;h2&gt;
  
  
  Career Journey
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Bell Labs: Where It All Began
&lt;/h3&gt;

&lt;p&gt;Ritchie joined Bell Labs in the late 1960s—a place that would become the epicenter of some of the most important innovations in computing history.&lt;/p&gt;

&lt;p&gt;At Bell Labs, he collaborated with legendary engineers like Ken Thompson.&lt;/p&gt;

&lt;h3&gt;
  
  
  The UNIX Project
&lt;/h3&gt;

&lt;p&gt;Initially, Ritchie worked on the Multics project, a complex operating system that ultimately failed to meet expectations. However, this failure became a turning point.&lt;/p&gt;

&lt;p&gt;Ken Thompson began developing a simpler operating system, which would later become UNIX. Ritchie joined him, and together they transformed it into something revolutionary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Turning Point: From Assembly to C
&lt;/h3&gt;

&lt;p&gt;Early versions of UNIX were written in assembly language, making them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hard to maintain&lt;/li&gt;
&lt;li&gt;Difficult to port across machines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ritchie recognized a critical problem: software needed a higher-level language that was still close to hardware.&lt;/p&gt;

&lt;p&gt;This insight led to the creation of the C programming language.&lt;/p&gt;




&lt;h2&gt;
  
  
  Major Contributions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. The C Programming Language
&lt;/h3&gt;

&lt;p&gt;Ritchie’s most influential contribution is the C programming language.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why C Was Revolutionary
&lt;/h4&gt;

&lt;p&gt;Before C:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;High-level languages were inefficient for system programming&lt;/li&gt;
&lt;li&gt;Assembly language was powerful but not portable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;C introduced a balance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Low-level control&lt;/strong&gt; (pointers, memory access)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High-level structure&lt;/strong&gt; (functions, control flow)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Key Features
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Direct memory manipulation via pointers&lt;/li&gt;
&lt;li&gt;Lightweight runtime&lt;/li&gt;
&lt;li&gt;Portable compilation across architectures&lt;/li&gt;
&lt;li&gt;Structured programming constructs&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Real-World Impact
&lt;/h4&gt;

&lt;p&gt;C became:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The foundation of modern operating systems&lt;/li&gt;
&lt;li&gt;The base for languages like C++, Java, and C#&lt;/li&gt;
&lt;li&gt;The backbone of embedded systems and performance-critical software&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. UNIX Operating System
&lt;/h3&gt;

&lt;p&gt;Ritchie co-developed the UNIX alongside Ken Thompson.&lt;/p&gt;

&lt;h4&gt;
  
  
  What Made UNIX Different
&lt;/h4&gt;

&lt;p&gt;UNIX introduced several foundational ideas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Everything is treated as a file&lt;/li&gt;
&lt;li&gt;Small, composable tools&lt;/li&gt;
&lt;li&gt;Strong use of text streams&lt;/li&gt;
&lt;li&gt;Process-based multitasking&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Rewriting UNIX in C
&lt;/h4&gt;

&lt;p&gt;One of Ritchie’s most important technical decisions was rewriting UNIX in C instead of assembly.&lt;/p&gt;

&lt;p&gt;This made UNIX:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Portable&lt;/strong&gt; across hardware platforms&lt;/li&gt;
&lt;li&gt;Easier to maintain and extend&lt;/li&gt;
&lt;li&gt;Widely adoptable in academia and industry&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This single decision changed how operating systems are built forever.&lt;/p&gt;




&lt;h2&gt;
  
  
  Famous Works / Projects
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The C Programming Language (Book)
&lt;/h3&gt;

&lt;p&gt;Ritchie co-authored &lt;em&gt;The C Programming Language&lt;/em&gt; with Brian Kernighan.&lt;/p&gt;

&lt;p&gt;Often referred to as “K&amp;amp;R C,” this book:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Defined the standard for C syntax and usage&lt;/li&gt;
&lt;li&gt;Provided practical examples&lt;/li&gt;
&lt;li&gt;Became one of the most influential programming books ever&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  UNIX System
&lt;/h3&gt;

&lt;p&gt;The UNIX ecosystem led to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;BSD (Berkeley Software Distribution)&lt;/li&gt;
&lt;li&gt;Linux (inspired by UNIX design)&lt;/li&gt;
&lt;li&gt;macOS (built on UNIX-based Darwin kernel)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Technical highlights:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hierarchical file system&lt;/li&gt;
&lt;li&gt;Shell scripting environment&lt;/li&gt;
&lt;li&gt;Inter-process communication via pipes&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Impact on the Tech Industry
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Foundation of Modern Programming
&lt;/h3&gt;

&lt;p&gt;Ritchie’s work fundamentally changed software engineering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;C became the “portable assembly language”&lt;/li&gt;
&lt;li&gt;UNIX defined OS design patterns&lt;/li&gt;
&lt;li&gt;Developers gained tools to build scalable systems&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Influence on Modern Technologies
&lt;/h3&gt;

&lt;p&gt;His influence is everywhere:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux kernel (written in C)&lt;/li&gt;
&lt;li&gt;Embedded systems (IoT devices)&lt;/li&gt;
&lt;li&gt;Compilers and interpreters&lt;/li&gt;
&lt;li&gt;Networking infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even modern languages inherit C’s syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// do something&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This structure appears in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Java&lt;/li&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;li&gt;C++&lt;/li&gt;
&lt;li&gt;Go&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Philosophy and Thinking
&lt;/h2&gt;

&lt;p&gt;Ritchie’s philosophy was grounded in simplicity and practicality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Core Ideas
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Build tools that do one thing well&lt;/li&gt;
&lt;li&gt;Favor clarity over complexity&lt;/li&gt;
&lt;li&gt;Stay close to the hardware when necessary&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Notable Quote
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;“UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This reflects his belief that simplicity is powerful—but not always easy to design.&lt;/p&gt;




&lt;h2&gt;
  
  
  Awards and Recognition
&lt;/h2&gt;

&lt;p&gt;Dennis Ritchie received numerous prestigious honors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Turing Award (1983)&lt;/strong&gt; – with Ken Thompson&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;National Medal of Technology (1999)&lt;/strong&gt; – awarded by U.S. President Bill Clinton&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Japan Prize (2011)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These awards recognized contributions that shaped the entire computing landscape.&lt;/p&gt;




&lt;h2&gt;
  
  
  Legacy
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Lessons for Developers
&lt;/h3&gt;

&lt;p&gt;Ritchie’s work teaches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simplicity scales better than complexity&lt;/li&gt;
&lt;li&gt;Abstractions should not hide reality completely&lt;/li&gt;
&lt;li&gt;Performance and control matter&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Enduring Relevance
&lt;/h3&gt;

&lt;p&gt;His contributions remain critical:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;C is still widely used in systems programming&lt;/li&gt;
&lt;li&gt;UNIX principles define modern OS architecture&lt;/li&gt;
&lt;li&gt;Software tools still follow his design philosophy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nearly every modern system—directly or indirectly—runs on ideas Ritchie helped create.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Dennis Ritchie didn’t chase trends or build flashy products. Instead, he focused on solving fundamental problems in computing.&lt;/p&gt;

&lt;p&gt;The result was transformative:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A language that bridges hardware and software&lt;/li&gt;
&lt;li&gt;An operating system that defined modern computing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For developers, his story is a reminder:&lt;/p&gt;

&lt;p&gt;The most impactful work isn’t always visible to users—but it becomes the foundation everything else depends on.&lt;/p&gt;

&lt;p&gt;Write clean code. Understand the machine. Build systems that last.&lt;/p&gt;

</description>
      <category>c</category>
      <category>unix</category>
      <category>programmers</category>
      <category>dennisritche</category>
    </item>
  </channel>
</rss>
