C vs C++: Key Language Differences, Features, and Development Use Cases in 2026
What is C vs C++: Key Language Differences, Features, and Development Use Cases in 2026? No two languages in computer science share a closer family history—or generate more fierce technical debates—than C and C++.Beginning in 1979 as "C with Classes...
What are the core language differences between C and C++ (Classes, Templates, RAII, STL, Operator Overloading) and when should each be chosen?
Explanation & In-Depth Details
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"> <span class="js-id">PHILOSOPHICAL</span> <span class="js-id">DIVERGENCE</span> ┌─────────────────────────────────────┐ ┌─────────────────────────────────────┐ │ <span class="js-id">THE</span> <span class="js-id">C</span> <span class="js-id">PHILOSOPHY</span> <span class="js-op">(</span><span class="js-id">WG14</span><span class="js-op">)</span> │ │ <span class="js-id">THE</span> <span class="js-id">C</span><span class="js-op">++</span> <span class="js-id">PHILOSOPHY</span> <span class="js-op">(</span><span class="js-id">WG21</span><span class="js-op">)</span> │ ├─────────────────────────────────────┤ ├─────────────────────────────────────┤ │ • <span class="js-id">Trust</span> <span class="js-id">the</span> <span class="js-id">programmer</span><span class="js-op">.</span> │ │ • <span class="js-id">You</span> <span class="js-id">don</span><span class="js-str">'t pay for what you don'</span><span class="js-id">t</span> │ │ • <span class="js-id">Keep</span> <span class="js-id">the</span> <span class="js-id">language</span> <span class="js-id">small</span> <span class="js-op">&</span> <span class="js-id">simple</span><span class="js-op">.</span> │ │ <span class="js-id">use</span> <span class="js-op">(</span><span class="js-id">Zero</span><span class="js-op">-</span><span class="js-id">Overhead</span> <span class="js-id">Principle</span><span class="js-op">).</span> │ │ • <span class="js-id">Transparent</span> <span class="js-id">mapping</span> <span class="js-id">to</span> <span class="js-id">assembly</span><span class="js-op">.</span> │ │ • <span class="js-id">Leave</span> <span class="js-id">no</span> <span class="js-id">room</span> <span class="js-kw">for</span> <span class="js-id">a</span> <span class="js-id">lower</span><span class="js-op">-</span><span class="js-id">level</span> │ │ • <span class="js-id">Explicit</span> <span class="js-id">is</span> <span class="js-id">better</span> <span class="js-id">than</span> <span class="js-id">implicit</span><span class="js-op">:</span> │ │ <span class="js-id">language</span> <span class="js-id">beneath</span> <span class="js-id">C</span><span class="js-op">++</span> <span class="js-op">(</span><span class="js-id">except</span> <span class="js-id">ASM</span><span class="js-op">).</span>│ │ <span class="js-id">no</span> <span class="js-id">hidden</span> <span class="js-id">copy</span> <span class="js-id">constructors</span><span class="js-op">,</span> │ │ • <span class="js-id">Enforce</span> <span class="js-id">invariants</span> <span class="js-id">at</span> <span class="js-id">compile</span><span class="js-op">-</span><span class="js-id">time</span>│ │ <span class="js-id">destructors</span><span class="js-op">,</span> <span class="js-id">or</span> <span class="js-id">heap</span> <span class="js-id">calls</span><span class="js-op">.</span> │ │ <span class="js-id">via</span> <span class="js-id">rich</span><span class="js-op">,</span> <span class="js-id">static</span> <span class="js-id">type</span> <span class="js-id">systems</span><span class="js-op">.</span> │ │ • <span class="js-id">ABI</span> <span class="js-id">stability</span> <span class="js-id">across</span> <span class="js-id">decades</span><span class="js-op">.</span> │ │ • <span class="js-id">Express</span> <span class="js-id">intent</span> <span class="js-id">through</span> <span class="js-id">high</span><span class="js-op">-</span><span class="js-id">level</span> │ │ │ │ <span class="js-id">abstractions</span> <span class="js-op">(</span><span class="js-id">templates</span><span class="js-op">,</span> <span class="js-id">RAII</span><span class="js-op">).</span> │ └─────────────────────────────────────┘ └─────────────────────────────────────┘</code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">The C Paradigm: Direct Hardware Control</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">In C, the code you write is a direct, near-mechanical representation of the assembly instructions the CPU will execute. A function call is just a <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">CALL</code> instruction. A struct is just an aligned block of bytes. If memory is allocated, you explicitly write <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">malloc()</code>. If memory is released, you explicitly write <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">free()</code>. There are no hidden operations, no implicit type construction, and no runtime-generated exception tables.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">The C++ Paradigm: Expressive Zero-Cost Abstraction</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">C++ shifts resource tracking and validation to the <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">compiler</span>. The core axiom of C++ is the <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Zero-Overhead Principle</span>:</p><ol class="list-inside list-decimal whitespace-normal [li_&]:pl-6" data-streamdown="ordered-list" style="border: 0px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); list-style: outside decimal; padding-inline-start: 1.375rem; margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><li class="py-1 [&>p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;">What you don't use, you don’t pay for.</li><li class="py-1 [&>p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;">What you do use, you could not hand-code any better by hand in raw assembly.</li></ol><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">A modern C++ container like <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::vector</code> or a smart pointer like <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::unique_ptr</code> manages dynamic memory automatically using RAII (Resource Acquisition Is Initialization), compiling down to the exact same pointer manipulation instructions an expert would write in C—while preventing memory leaks by design.</p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">2. Is C++ a Superset of C? The Compatibility Myth</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">A common misconception is that valid C code can always be compiled with a C++ compiler. In practice, modern C is <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">not</span> a subset of C++. Valid C code routinely fails to compile under C++:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">VALID</span> <span class="js-id">C</span> <span class="js-id">CONSTRUCTS</span> <span class="js-id">THAT</span> <span class="js-id">FAIL</span> <span class="js-id">TO</span> <span class="js-id">COMPILE</span> <span class="js-id">IN</span> <span class="js-id">C</span><span class="js-op">++</span> ┌──────────────────────────────┬──────────────────┬─────────────────────────────┐ │ <span class="js-id">Code</span> <span class="js-id">Construct</span> │ <span class="js-id">Valid</span> <span class="js-kw">in</span> <span class="js-id">C</span><span class="js-op">?</span> │ <span class="js-id">Status</span> <span class="js-kw">in</span> <span class="js-id">C</span><span class="js-op">++</span> │ ├──────────────────────────────┼──────────────────┼─────────────────────────────┤ │ <span class="js-kw">void</span> <span class="js-op">*</span><span class="js-id">p</span> <span class="js-op">=</span> <span class="js-id">malloc</span><span class="js-op">(</span><span class="js-num">10</span><span class="js-op">);</span> │ <span class="js-id">YES</span> │ <span class="js-id">COMPILE</span> <span class="js-id">ERROR</span><span class="js-op">:</span> <span class="js-id">Cannot</span> │ │ <span class="js-id">int</span> <span class="js-op">*</span><span class="js-id">arr</span> <span class="js-op">=</span> <span class="js-id">p</span><span class="js-op">;</span> │ <span class="js-op">(</span><span class="js-id">Implicit</span> <span class="js-id">cast</span><span class="js-op">)</span> │ <span class="js-id">convert</span> <span class="js-str">'void*'</span> <span class="js-id">to</span> <span class="js-str">'int*'</span> │ ├──────────────────────────────┼──────────────────┼─────────────────────────────┤ │ <span class="js-id">struct</span> <span class="js-id">Point</span> <span class="js-op">{</span>
<span class="js-id">int</span> <span class="js-id">x</span><span class="js-op">,</span> <span class="js-id">y</span><span class="js-op">;</span>
<span class="js-op">}</span>
<span class="js-op">;</span> │ <span class="js-id">YES</span> │ <span class="js-id">COMPILE</span> <span class="js-id">ERROR</span><span class="js-op">:</span> <span class="js-str">'Point'</span> <span class="js-id">type</span> │ │ <span class="js-id">Point</span> <span class="js-id">pt</span><span class="js-op">;</span> │ <span class="js-op">(</span><span class="js-id">struct</span> <span class="js-id">required</span><span class="js-op">)</span>│ <span class="js-id">allowed</span><span class="js-op">,</span> <span class="js-id">but</span> <span class="js-id">rules</span> <span class="js-id">diverge</span> │ ├──────────────────────────────┼──────────────────┼─────────────────────────────┤ │ <span class="js-id">int</span> <span class="js-kw">new</span> <span class="js-op">=</span> <span class="js-num">10</span><span class="js-op">;</span> │ <span class="js-id">YES</span> │ <span class="js-id">COMPILE</span> <span class="js-id">ERROR</span><span class="js-op">:</span> <span class="js-str">'new'</span> <span class="js-id">is</span> <span class="js-id">a</span> │ │ <span class="js-id">int</span> <span class="js-kw">class</span> <span class="js-op">=</span> <span class="js-num">5</span><span class="js-op">;</span> │ │ <span class="js-id">reserved</span> <span class="js-id">C</span><span class="js-op">++</span> <span class="js-id">keyword</span> │ ├──────────────────────────────┼──────────────────┼─────────────────────────────┤ │ <span class="js-id">char</span> <span class="js-op">*</span><span class="js-id">s</span> <span class="js-op">=</span> <span class="js-id">malloc</span><span class="js-op">(</span><span class="js-num">10</span><span class="js-op">);</span> │ <span class="js-id">YES</span> │ <span class="js-id">COMPILE</span> <span class="js-id">ERROR</span><span class="js-op">:</span> <span class="js-id">C</span> <span class="js-id">rejects</span> │ │ <span class="js-id">free</span><span class="js-op">(</span><span class="js-id">s</span><span class="js-op">);</span> │ │ <span class="js-id">malloc</span> <span class="js-id">cast</span> <span class="js-kw">in</span> <span class="js-id">clean</span> <span class="js-id">C</span><span class="js-op">++</span> │ ├──────────────────────────────┼──────────────────┼─────────────────────────────┤ │ <span class="js-kw">const</span> <span class="js-id">int</span> <span class="js-id">N</span> <span class="js-op">=</span> <span class="js-num">5</span><span class="js-op">;</span> │ <span class="js-id">External</span> <span class="js-id">Linkage</span> │ <span class="js-id">Internal</span> <span class="js-id">Linkage</span> │ │ <span class="js-id">int</span> <span class="js-id">array</span>[<span class="js-id">N</span>]<span class="js-op">;</span> <span class="js-op">(</span><span class="js-id">at</span> <span class="js-id">file</span> <span class="js-id">scope</span><span class="js-op">)</span>│ <span class="js-op">(</span><span class="js-id">Not</span> <span class="js-id">a</span> <span class="js-kw">const</span><span class="js-op">-</span><span class="js-id">expr</span>│ <span class="js-op">(</span><span class="js-id">Can</span> <span class="js-id">be</span> <span class="js-id">used</span> <span class="js-id">as</span> <span class="js-id">compile</span><span class="js-op">-</span><span class="js-id">time</span>│ │ │ <span class="js-kw">in</span> <span class="js-id">C99</span><span class="js-op">/</span><span class="js-id">C11</span><span class="js-op">/</span><span class="js-id">C17</span><span class="js-op">)</span> │ <span class="js-id">array</span> <span class="js-id">bound</span><span class="js-op">)</span> │ └──────────────────────────────┴──────────────────┴─────────────────────────────┘</code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">Trap 1: Implicit <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">void*</code> Conversions</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">In C, a <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">void*</code> pointer implicitly converts to and from any other data pointer type. In C++, implicit conversion from <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">void*</code> is strictly forbidden to preserve type safety:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-cm">/* Valid in C (C99, C11, C17, C23) */</span><span class="js-kw">void</span> <span class="js-op">*</span><span class="js-id">raw</span> <span class="js-op">=</span> <span class="js-id">malloc</span><span class="js-op">(</span><span class="js-id">sizeof</span><span class="js-op">(</span><span class="js-id">int</span><span class="js-op">)</span> <span class="js-op">*</span> <span class="js-num">10</span><span class="js-op">);</span><span class="js-id">int</span> <span class="js-op">*</span><span class="js-id">data</span> <span class="js-op">=</span> <span class="js-id">raw</span><span class="js-op">;</span> <span class="js-cm">/* Implicit conversion permitted */</span>
<span class="js-cm">// COMPILE ERROR in C++:// error: invalid conversion from 'void*' to 'int*' [-fpermissive]int *data = raw; </span>
<span class="js-cm">// Required in C++ (or prefer auto data = std::make_unique<int[]>(10)):int *data = static_cast<int*>(raw);</span></code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">Trap 2: Struct Tag Namespacing</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">In C, struct tags exist in a separate namespace from normal identifiers. You must precede the type with the <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">struct</code> keyword unless you define a <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">typedef</code>:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-cm">/* In C: */</span><span class="js-id">struct</span> <span class="js-id">Node</span> <span class="js-op">{</span> <span class="js-id">int</span> <span class="js-id">value</span><span class="js-op">;};</span>
<span class="js-id">Node</span> <span class="js-id">n1</span><span class="js-op">;</span> <span class="js-cm">/* ERROR: Unknown type name 'Node' */</span><span class="js-id">struct</span> <span class="js-id">Node</span> <span class="js-id">n2</span><span class="js-op">;</span> <span class="js-cm">/* OK */</span><span class="js-id">typedef</span> <span class="js-id">struct</span> <span class="js-id">Node</span> <span class="js-id">Node</span><span class="js-op">;</span><span class="js-id">Node</span> <span class="js-id">n3</span><span class="js-op">;</span> <span class="js-cm">/* OK now */</span>
<span class="js-cm">// In C++:struct Node { int value;};Node n1; // AUTOMATICALLY VALID: structs implicitly introduce a type name</span></code></pre></div></div></div><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">3. ABI, Name Mangling, and Interoperability (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">extern "C"</code>)</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Because C does not support function overloading, the C compiler writes function names directly into the object file's symbol table:</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">$$\text{Function: } \texttt{void calculate(int x)} \implies \text{Symbol: } \texttt{calculate}$$</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">In C++, functions can be overloaded with different signatures. To differentiate them at the linker level, C++ compilers use <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">name mangling</span> (symbol decoration):</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">$$\text{Function: } \texttt{void calculate(int x)} \implies \text{Mangled Symbol: } \texttt{_Z9calculatei}$$ $$\text{Function: } \texttt{void calculate(double x, double y)} \implies \text{Mangled Symbol: } \texttt{_Z9calculatedd}$$</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">THE</span> <span class="js-id">LINKER</span> <span class="js-id">MISMATCH</span> <span class="js-id">C</span> <span class="js-id">Header</span> <span class="js-op">(</span><span class="js-id">mylib</span><span class="js-op">.</span><span class="js-id">h</span><span class="js-op">)</span> <span class="js-id">C</span><span class="js-op">++</span> <span class="js-id">Source</span> <span class="js-id">File</span> <span class="js-op">(</span><span class="js-id">app</span><span class="js-op">.</span><span class="js-id">cpp</span><span class="js-op">)</span> ┌───────────────────────┐ ┌──────────────────────────────┐ │ <span class="js-id">int</span> <span class="js-id">add</span><span class="js-op">(</span><span class="js-id">int</span> <span class="js-id">a</span><span class="js-op">,</span> <span class="js-id">int</span> <span class="js-id">b</span><span class="js-op">);</span>│ │ #<span class="js-id">include</span> <span class="js-str">"mylib.h"</span> │ └───────────────────────┘ │ <span class="js-id">int</span> <span class="js-id">val</span> <span class="js-op">=</span> <span class="js-id">add</span><span class="js-op">(</span><span class="js-num">5</span><span class="js-op">,</span> <span class="js-num">10</span><span class="js-op">);</span> │ │ └──────────────────────────────┘ ▼ │ <span class="js-id">Emits</span> <span class="js-id">C</span> <span class="js-id">Symbol</span><span class="js-op">:</span> <span class="js-str">`add`</span> ▼ <span class="js-id">Searches</span> <span class="js-kw">for</span> <span class="js-id">Mangled</span> <span class="js-id">Symbol</span><span class="js-op">:</span> <span class="js-str">`_Z3addii`</span> │ ▼ <span class="js-id">LINKER</span> <span class="js-id">ERROR</span><span class="js-op">:</span> <span class="js-num">undefined</span> <span class="js-id">reference</span> <span class="js-id">to</span> <span class="js-str">`_Z3addii`</span></code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">The Solution: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">extern "C"</code></h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">To allow C and C++ to link together, C++ provides the <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">extern "C"</code> linkage specification. It tells the C++ compiler to inhibit name mangling and emit standard, unmangled C-ABI symbols:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-cm">/* Universal Header: Usable in both pure C and C++ */</span>#<span class="js-id">ifndef</span> <span class="js-id">MATH_LIB_H</span>#<span class="js-id">define</span> <span class="js-id">MATH_LIB_H</span>
#<span class="js-id">ifdef</span> <span class="js-id">__cplusplusextern</span> <span class="js-str">"C"</span> <span class="js-op">{</span>#<span class="js-id">endif</span>
<span class="js-id">int</span> <span class="js-id">add</span><span class="js-op">(</span><span class="js-id">int</span> <span class="js-id">a</span><span class="js-op">,</span> <span class="js-id">int</span> <span class="js-id">b</span><span class="js-op">);</span><span class="js-kw">void</span> <span class="js-id">compute_matrix</span><span class="js-op">(</span><span class="js-id">float</span> <span class="js-op">*</span><span class="js-id">data</span><span class="js-op">,</span> <span class="js-id">int</span> <span class="js-id">rows</span><span class="js-op">,</span> <span class="js-id">int</span> <span class="js-id">cols</span><span class="js-op">);</span>
#<span class="js-id">ifdef</span> <span class="js-id">__cplusplus</span><span class="js-op">}</span>#<span class="js-id">endif</span>
#<span class="js-id">endif</span> <span class="js-cm">/* MATH_LIB_H */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Because of this universal standard C ABI, <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">C is the universal lingua franca of computer software</span>. When Rust, Python, Go, C#, or Java interact with native libraries, they bind via the C ABI, not the unstable, compiler-dependent C++ ABI.</p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">4. Resource Management: C <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">goto cleanup</code> vs. C++ RAII</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Resource leaks (memory buffers, file descriptors, socket handles, mutex locks) are the primary source of bugs in systems engineering. The languages handle cleanup through opposite paradigms.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">The C Approach: Manual Cleanup Ladders</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">C lacks automatic destructors. When a function allocates multiple resources that might fail halfway through, idiomatic C uses the <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">goto cleanup</code></span> ladder to prevent resource leaks:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-cm">/* Idiomatic C Resource Management */</span><span class="js-id">int</span> <span class="js-id">process_transaction</span><span class="js-op">(</span><span class="js-kw">const</span> <span class="js-id">char</span> <span class="js-op">*</span><span class="js-id">filename</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-id">char</span> <span class="js-op">*</span><span class="js-id">buffer</span> <span class="js-op">=</span> <span class="js-id">NULL</span><span class="js-op">;</span> <span class="js-id">FILE</span> <span class="js-op">*</span><span class="js-id">file</span> <span class="js-op">=</span> <span class="js-id">NULL</span><span class="js-op">;</span> <span class="js-id">int</span> <span class="js-id">status</span> <span class="js-op">=</span> <span class="js-op">-</span><span class="js-num">1</span><span class="js-op">;</span>
<span class="js-id">buffer</span> <span class="js-op">=</span> <span class="js-op">(</span><span class="js-id">char</span> <span class="js-op">*)</span><span class="js-id">malloc</span><span class="js-op">(</span><span class="js-num">4096</span><span class="js-op">);</span> <span class="js-kw">if</span> <span class="js-op">(!</span><span class="js-id">buffer</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-id">goto</span> <span class="js-id">cleanup</span><span class="js-op">;</span> <span class="js-cm">/* Fail step 1 */</span> <span class="js-op">}</span>
<span class="js-id">file</span> <span class="js-op">=</span> <span class="js-id">fopen</span><span class="js-op">(</span><span class="js-id">filename</span><span class="js-op">,</span> <span class="js-str">"rb"</span><span class="js-op">);</span> <span class="js-kw">if</span> <span class="js-op">(!</span><span class="js-id">file</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-id">goto</span> <span class="js-id">cleanup</span><span class="js-op">;</span> <span class="js-cm">/* Fail step 2 */</span> <span class="js-op">}</span>
<span class="js-cm">/* Perform work */</span> <span class="js-kw">if</span> <span class="js-op">(</span><span class="js-id">fread</span><span class="js-op">(</span><span class="js-id">buffer</span><span class="js-op">,</span> <span class="js-num">1</span><span class="js-op">,</span> <span class="js-num">4096</span><span class="js-op">,</span> <span class="js-id">file</span><span class="js-op">)</span> <span class="js-op">></span> <span class="js-num">0</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-id">status</span> <span class="js-op">=</span> <span class="js-num">0</span><span class="js-op">;</span> <span class="js-cm">/* Success */</span> <span class="js-op">}</span>
<span class="js-id">cleanup</span><span class="js-op">:</span> <span class="js-cm">/* Explicit cleanup in reverse acquisition order */</span> <span class="js-kw">if</span> <span class="js-op">(</span><span class="js-id">file</span><span class="js-op">)</span> <span class="js-id">fclose</span><span class="js-op">(</span><span class="js-id">file</span><span class="js-op">);</span> <span class="js-kw">if</span> <span class="js-op">(</span><span class="js-id">buffer</span><span class="js-op">)</span> <span class="js-id">free</span><span class="js-op">(</span><span class="js-id">buffer</span><span class="js-op">);</span> <span class="js-kw">return</span> <span class="js-id">status</span><span class="js-op">;}</span></code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">The C++ Approach: RAII and Smart Pointers</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">In C++, resource lifecycles are bound to variable scopes via <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">RAII (Resource Acquisition Is Initialization)</span>. When an object leaves its scope—whether through a normal <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">return</code>, a <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">break</code>, or an exception—its destructor is invoked automatically:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="cpp" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-cpp" data-language="cpp" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-cpp bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-cm">// Idiomatic Modern C++ Resource Management#include <fstream>#include <vector>#include <string></span>
<span class="js-id">bool</span> <span class="js-id">process_transaction</span><span class="js-op">(</span><span class="js-kw">const</span> <span class="js-id">std</span><span class="js-op">::</span><span class="js-id">string</span><span class="js-op">&</span> <span class="js-id">filename</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-cm">// Dynamic buffer allocated via vector (RAII) std::vector<char> buffer(4096);</span>
<span class="js-cm">// File opened via ifstream (RAII) std::ifstream file(filename, std::ios::binary); if (!file.is_open()) { return false; // file and buffer are destroyed automatically! }</span>
<span class="js-id">file</span><span class="js-op">.</span><span class="js-id">read</span><span class="js-op">(</span><span class="js-id">buffer</span><span class="js-op">.</span><span class="js-id">data</span><span class="js-op">(),</span> <span class="js-id">buffer</span><span class="js-op">.</span><span class="js-id">size</span><span class="js-op">());</span> <span class="js-kw">return</span> <span class="js-id">file</span><span class="js-op">.</span><span class="js-id">gcount</span><span class="js-op">()</span> <span class="js-op">></span> <span class="js-num">0</span><span class="js-op">;}</span> <span class="js-cm">// Both file descriptor and heap buffer are guaranteed to be cleaned up here!</span></code></pre></div></div></div><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">5. Performance Case Study: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">qsort()</code> vs. <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">std::sort()</code></h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">A common belief is that C must always be faster than C++ because it has less syntactic abstraction. However, abstraction in C++ often produces <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">faster</span> compiled machine code than C.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Consider sorting an array of 1,000,000 integers:</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">The C Implementation (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">qsort</code>):</h3><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">include</span> <span class="js-op"><</span><span class="js-id">stdlib</span><span class="js-op">.</span><span class="js-id">h</span><span class="js-op">></span>
<span class="js-id">int</span> <span class="js-id">compare_ints</span><span class="js-op">(</span><span class="js-kw">const</span> <span class="js-kw">void</span> <span class="js-op">*</span><span class="js-id">a</span><span class="js-op">,</span> <span class="js-kw">const</span> <span class="js-kw">void</span> <span class="js-op">*</span><span class="js-id">b</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-id">int</span> <span class="js-id">arg1</span> <span class="js-op">=</span> <span class="js-op">*(</span><span class="js-kw">const</span> <span class="js-id">int</span> <span class="js-op">*)</span><span class="js-id">a</span><span class="js-op">;</span> <span class="js-id">int</span> <span class="js-id">arg2</span> <span class="js-op">=</span> <span class="js-op">*(</span><span class="js-kw">const</span> <span class="js-id">int</span> <span class="js-op">*)</span><span class="js-id">b</span><span class="js-op">;</span> <span class="js-kw">return</span> <span class="js-op">(</span><span class="js-id">arg1</span> <span class="js-op">></span> <span class="js-id">arg2</span><span class="js-op">)</span> <span class="js-op">-</span> <span class="js-op">(</span><span class="js-id">arg1</span> <span class="js-op"><</span> <span class="js-id">arg2</span><span class="js-op">);}</span>
<span class="js-kw">void</span> <span class="js-id">run_c_sort</span><span class="js-op">(</span><span class="js-id">int</span> <span class="js-op">*</span><span class="js-id">array</span><span class="js-op">,</span> <span class="js-id">size_t</span> <span class="js-id">n</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-id">qsort</span><span class="js-op">(</span><span class="js-id">array</span><span class="js-op">,</span> <span class="js-id">n</span><span class="js-op">,</span> <span class="js-id">sizeof</span><span class="js-op">(</span><span class="js-id">int</span><span class="js-op">),</span> <span class="js-id">compare_ints</span><span class="js-op">);}</span></code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">The C++ Implementation (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">std::sort</code>):</h3><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="cpp" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-cpp" data-language="cpp" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-cpp bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">include</span> <span class="js-op"><</span><span class="js-id">algorithm</span><span class="js-op">></span>#<span class="js-id">include</span> <span class="js-op"><</span><span class="js-id">vector</span><span class="js-op">></span>
<span class="js-kw">void</span> <span class="js-id">run_cpp_sort</span><span class="js-op">(</span><span class="js-id">std</span><span class="js-op">::</span><span class="js-id">vector</span><span class="js-op"><</span><span class="js-id">int</span><span class="js-op">>&</span> <span class="js-id">vec</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-id">std</span><span class="js-op">::</span><span class="js-id">sort</span><span class="js-op">(</span><span class="js-id">vec</span><span class="js-op">.</span><span class="js-id">begin</span><span class="js-op">(),</span> <span class="js-id">vec</span><span class="js-op">.</span><span class="js-id">end</span><span class="js-op">());}</span></code></pre></div></div></div><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"> <span class="js-id">COMPILATION</span> <span class="js-id">COMPARISON</span> <span class="js-id">C</span> <span class="js-str">`qsort`</span> <span class="js-op">(</span><span class="js-id">Runtime</span> <span class="js-id">Function</span> <span class="js-id">Pointer</span><span class="js-op">)</span> <span class="js-id">C</span><span class="js-op">++</span> <span class="js-str">`std::sort`</span> <span class="js-op">(</span><span class="js-id">Compile</span><span class="js-op">-</span><span class="js-id">Time</span> <span class="js-id">Template</span><span class="js-op">)</span> ┌─────────────────────────────────────┐ ┌─────────────────────────────────────┐ │ • <span class="js-id">qsort</span> <span class="js-id">compiled</span> <span class="js-id">once</span> <span class="js-kw">in</span> <span class="js-id">libc</span><span class="js-op">.</span><span class="js-id">so</span><span class="js-op">.</span> │ │ • <span class="js-id">std</span><span class="js-op">::</span><span class="js-id">sort</span> <span class="js-id">generates</span> <span class="js-id">specialized</span> │ │ • <span class="js-id">Cannot</span> <span class="js-id">inline</span> <span class="js-id">the</span> <span class="js-id">comparator</span><span class="js-op">.</span> │ │ <span class="js-id">code</span> <span class="js-kw">for</span> <span class="js-str">'int'</span> <span class="js-id">during</span> <span class="js-id">compile</span><span class="js-op">.</span> │ │ • <span class="js-id">Must</span> <span class="js-id">execute</span> <span class="js-id">an</span> <span class="js-id">indirect</span> <span class="js-id">branch</span> │ │ • <span class="js-id">Inlines</span> <span class="js-str">'operator<'</span> <span class="js-id">directly</span> <span class="js-id">into</span> │ │ <span class="js-op">(</span><span class="js-id">CALL</span> <span class="js-op">*%</span><span class="js-id">rax</span><span class="js-op">)</span> <span class="js-kw">for</span> <span class="js-id">every</span> <span class="js-id">comparison</span><span class="js-op">!</span>│ │ <span class="js-id">the</span> <span class="js-id">sorting</span> <span class="js-id">loop</span><span class="js-op">.</span> │ │ • <span class="js-op">~</span><span class="js-num">20</span><span class="js-op">,</span><span class="js-num">000</span><span class="js-op">,</span><span class="js-num">000</span> <span class="js-id">indirect</span> <span class="js-kw">function</span> │ │ • <span class="js-id">ZERO</span> <span class="js-id">indirect</span> <span class="js-id">calls</span><span class="js-op">;</span> <span class="js-id">full</span> <span class="js-id">SIMD</span> <span class="js-id">and</span>│ │ <span class="js-id">pointer</span> <span class="js-id">invocations</span> <span class="js-kw">for</span> 1M <span class="js-id">items</span><span class="js-op">!</span> │ │ <span class="js-id">branch</span><span class="js-op">-</span><span class="js-id">prediction</span> <span class="js-id">optimization</span><span class="js-op">.</span> │ └─────────────────────────────────────┘ └─────────────────────────────────────┘</code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Benchmark Result:</span> <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::sort</code> in C++ consistently runs <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">2× to 3× faster</span> than C's <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">qsort</code>.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Because <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">qsort</code> is a precompiled library function accepting <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">void*</code> arguments, the compiler cannot inline the comparison callback across translation units. In C++, templates specialize the algorithm at compile time, eliminating all function call overhead and allowing the compiler's optimizer to emit direct register-to-register comparison instructions.</p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">6. Comprehensive Feature Comparison Matrix</h2><div class="my-4 flex flex-col gap-2 rounded-lg bg-sidebar p-2" data-streamdown="table-wrapper" style="border: 0.8px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 0.5rem; margin-block: 1rem 0.75rem; overflow: hidden; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); gap: 0px; --tw-space-y-reverse: 0; display: flex; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px;"><div class="border-collapse" style="border: 1px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); border-collapse: collapse; border-radius: 5.5px; background-color: rgb(18, 18, 22); max-height: 300px;"><table class="w-full divide-y divide-border" data-streamdown="table" style="border-width: 0px; border-color: inherit; margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); text-indent: 0px; min-width: 100%; width: 951.2px;"><thead class="bg-muted/80" data-streamdown="table-header" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0; background-color: oklab(0.252138 0.000131465 -0.00581433 / 0.8);"><tr class="" data-streamdown="table-row" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Technical Feature</th><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">C (ISO C17 / C23)</th><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">C++ (C++20 / C++23 / C++26)</th></tr></thead><tbody class="divide-y divide-border" data-streamdown="table-body" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Primary Paradigms</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Procedural, imperative, structured</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Multi-paradigm: Procedural, OOP, Functional, Generic</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Polymorphism</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Manual via function pointer tables (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">vtable</code>)</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">First-class virtual functions, CRTP, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::variant</code></td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Memory Allocation</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">malloc()</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">calloc()</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">free()</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">new</code>/<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">delete</code>, RAII, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::unique_ptr</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::shared_ptr</code></td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Templates / Generics</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">C11 <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">_Generic</code> macros (limited)</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Full Turing-complete templates, Concepts (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">requires</code>), Metaprogramming</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Error Handling</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Return codes, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">errno</code>, sentinel pointers</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Exceptions (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">try-catch</code>), <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::expected</code> (monadic), return codes</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Compile-Time Execution</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Constant expressions only</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">constexpr</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">consteval</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">constinit</code> (computes complex data at compile time)</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Standard String Type</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Null-terminated byte arrays (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">char*</code>)</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::string</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::string_view</code> (non-allocating slices)</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Standard Containers</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">None (Must hand-write or use 3rd-party libs)</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::vector</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::map</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::unordered_map</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::span</code></td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Concurrency Support</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">C11 <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;"><threads.h></code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;"><stdatomic.h></code>, OS threads</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::thread</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::jthread</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::atomic</code>, Coroutines (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">co_await</code>)</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Modules System</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> text inclusion only</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">C++20 Modules (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">import std;</code>) + <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> backwards compatibility</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Compilation Speed</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Blazing fast (seconds for massive codebases)</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Slower (template instantiations, header bloat, AST depth)</td></tr><tr class="" data-streamdown="table-row" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600;">Binary Size</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Minimalist (stripped binaries: 10KB–50KB)</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Larger (RTTI, exception unwinding tables, template bloat)</td></tr></tbody></table></div></div><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">7. Production Decision Matrix: When to Choose C vs. C++ in 2026</h2><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"> <span class="js-id">ENGINEERING</span> <span class="js-id">SELECTION</span> <span class="js-id">CRITERIA</span>
<span class="js-id">What</span> <span class="js-id">is</span> <span class="js-id">your</span> <span class="js-id">target</span><span class="js-op">?</span>
│
┌────────────────────────────┴────────────────────────────┐
▼ ▼
<span class="js-id">SYSTEM</span> <span class="js-id">MINIMALISM</span> <span class="js-op">&</span> <span class="js-id">ABI</span> <span class="js-id">EXPRESSION</span> <span class="js-op">&</span> <span class="js-id">SCALE</span>
─────────────────────── ──────────────────
• <span class="js-id">Embedded</span> <span class="js-id">MCUs</span> <span class="js-op">(</span><span class="js-num">8</span><span class="js-op">-</span><span class="js-id">bit</span> <span class="js-op">/</span> <span class="js-num">16</span><span class="js-op">-</span><span class="js-id">bit</span> <span class="js-op">/</span> <span class="js-num">32</span><span class="js-op">-</span><span class="js-id">bit</span><span class="js-op">)</span> • <span class="js-id">AAA</span> <span class="js-id">Game</span> <span class="js-id">Engines</span> <span class="js-op">(</span><span class="js-id">Unreal</span><span class="js-op">,</span> <span class="js-id">Custom</span><span class="js-op">)</span>
• <span class="js-id">OS</span> <span class="js-id">Kernels</span> <span class="js-op">(</span><span class="js-id">Linux</span><span class="js-op">,</span> <span class="js-id">OpenBSD</span><span class="js-op">,</span> <span class="js-id">FreeRTOS</span><span class="js-op">)</span> • <span class="js-id">High</span><span class="js-op">-</span><span class="js-id">Performance</span> <span class="js-id">Browsers</span> <span class="js-op">(</span><span class="js-id">Chromium</span><span class="js-op">,</span> <span class="js-id">V8</span><span class="js-op">)</span>
• <span class="js-id">Universal</span> <span class="js-id">Shared</span> <span class="js-id">Libraries</span> <span class="js-op">(</span><span class="js-id">C</span> <span class="js-id">ABI</span><span class="js-op">)</span> • <span class="js-id">High</span><span class="js-op">-</span><span class="js-id">Frequency</span> <span class="js-id">Trading</span> <span class="js-op">(</span><span class="js-id">HFT</span><span class="js-op">)</span> <span class="js-id">Engines</span>
• <span class="js-id">Compilers</span> <span class="js-op">&</span> <span class="js-id">Runtimes</span> <span class="js-op">(</span><span class="js-id">CPython</span><span class="js-op">,</span> <span class="js-id">Lua</span><span class="js-op">,</span> <span class="js-id">SQLite</span><span class="js-op">)</span> • <span class="js-id">Machine</span> <span class="js-id">Learning</span> <span class="js-id">Backends</span> <span class="js-op">(</span><span class="js-id">PyTorch</span><span class="js-op">,</span> <span class="js-id">LLVM</span><span class="js-op">)</span>
• <span class="js-id">Hardware</span> <span class="js-id">Register</span> <span class="js-id">Drivers</span> <span class="js-op">&</span> <span class="js-id">Bootloaders</span> • <span class="js-id">Large</span><span class="js-op">-</span><span class="js-id">Scale</span> <span class="js-id">Desktop</span> <span class="js-id">Apps</span> <span class="js-op">(</span><span class="js-id">Photoshop</span><span class="js-op">,</span> <span class="js-id">CAD</span><span class="js-op">)</span>
│ │
▼ ▼
<span class="js-id">CHOOSE</span><span class="js-op">:</span> <span class="js-op">**</span><span class="js-id">C</span><span class="js-op">**</span> <span class="js-id">CHOOSE</span><span class="js-op">:</span> <span class="js-op">**</span><span class="js-id">C</span><span class="js-op">++**</span></code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">Choose C When:</h3><ol class="list-inside list-decimal whitespace-normal [li_&]:pl-6" data-streamdown="ordered-list" style="border: 0px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); list-style: outside decimal; padding-inline-start: 1.375rem; margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><li class="py-1 [&>p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Targeting Resource-Constrained Embedded Systems:</span> When working on an 8-bit PIC or 32-bit Cortex-M0 with 16KB of Flash and 2KB of RAM, C++ runtime support (exception unwinding tables, name mangling, and complex runtime libraries) consumes prohibitive overhead.</li><li class="py-1 [&>p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Developing OS Kernels, Drivers, and Hypervisors:</span> The Linux kernel, OpenBSD, and system hypervisors avoid C++ because C's procedural nature prevents hidden memory allocations, unpredictable copy constructors, and non-trivial object construction behind the scenes.</li><li class="py-1 [&>p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Building Universal Foreign Function Interfaces (FFI):</span> When authoring a database engine (like SQLite) or audio codec meant to be embedded across Python, Node.js, C#, Go, and Rust, providing an un-mangled, clean C-ABI interface is mandatory.</li><li class="py-1 [&>p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Build Times and Tooling Portability Matter:</span> Pure C code compiles orders of magnitude faster than template-heavy C++. In industrial embedded environments with proprietary or certified compiler toolchains, standard C conformance is universally guaranteed.</li></ol><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; background-color: rgb(18, 18, 22);">Choose C++ When:</h3><ol class="list-inside list-decimal whitespace-normal [li_&]:pl-6" data-streamdown="ordered-list" style="border: 0px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); list-style: outside decimal; padding-inline-start: 1.375rem; margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: "Inter Variable", sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><li class="py-1 [&>p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Building Massive, Complex Codebases:</span> Large-scale systems (browsers like Chromium, graphics suites like Blender, database backends like MongoDB) require modular encapsulation, namespaces, strong type invariants, and generic collections that would degenerate into untyped <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">void*</code> boilerplate in C.</li><li class="py-1 [&>p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Developing AAA Game Engines:</span> Modern game engines (Unreal Engine 5, CryEngine) rely on C++ for its ability to combine low-level SIMD intrinsics and cache-friendly memory allocators with high-level game-logic hierarchies and polymorphism.</li><li class="py-1 [&>p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Eliminating Callback Overhead in High-Throughput Pipelines:</span> Financial trading systems, audio DSP engines, and linear algebra libraries leverage C++ template metaprogramming, inlined lambdas, and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">constexpr</code> tables to execute calculations without runtime indirection.</li><li class="py-1 [&>p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Enforcing Memory Safety via RAII:</span> In systems where manual resource tracking introduces memory leaks, C++'s <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::unique_ptr</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">std::shared_ptr</code>, and custom destructor wrappers eliminate double-frees and dangling pointers systematically.</li></ol>
Code Example
#include <stdio.h>
int main() {
printf("=== C vs C++ Key Differences ===\
");
printf("C: Clean, lean, procedural, manual resource management\
");
printf("C++: Classes, RAII, Templates, STL containers, Operator Overloading\
");
return 0;
}Interview Question & Tips
A: RAII (Resource Acquisition Is Initialization) ties resource lifetime to variable scope: constructors allocate resources and destructors automatically free them upon leaving scope, eliminating manual `free()` and `fclose()` calls required in C.
Q: Why is the Linux kernel written in C instead of C++?
A: Linus Torvalds chose C for its extreme simplicity, predictable assembly generation, absence of hidden constructor/exception runtime overhead, and clean compiler toolchains.
Best Practices
This study reference for C vs C++: Key Language Differences, Features, and Development Use Cases in 2026 is curated and verified against recognized curriculum benchmarks, peer-reviewed textbooks, and official technical documentation: