<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>cpp &amp;mdash; musicmatzes blog</title>
    <link>https://beyermatthias.de/tag:cpp</link>
    <description></description>
    <pubDate>Wed, 06 May 2026 13:04:12 +0200</pubDate>
    <item>
      <title>Rust is one of the best C replacements we currently have</title>
      <link>https://beyermatthias.de/rust-is-one-of-the-best-c-replacements-we-currently-have</link>
      <description>&lt;![CDATA[This is a reply to the article&#xA;published by Drew DeVault called&#xA;&#34;Rust is not a good C replacement&#34;.&#xA;&#xA;---&#xA;&#xA;First of all, let me say that Drew is one of the people out there on the&#xA;internet whose opinions I highly value. Indeed he is one of the people I try&#xA;to read and listen to regardless of topic, because I think he is one of the&#xA;people that deserve unconditional attention.&#xA;&#xA;Needless to say that I&#39;ve also read his latest piece&#xA;&#34;Rust is not a good C replacement&#34;.&#xA;I have to admit I was shocked at first, but after a bit of cooling down (and&#xA;doing the dishes), I can see where this comes from.&#xA;&#xA;And I have to disagree.&#xA;&#xA;But let me start with my background - because that might be important for you,&#xA;dear reader, to classify this article.&#xA;&#xA;My background is mostly hobbyist programming. I did a few years of C, probably&#xA;a few 100kloc, not more. I also do rust since about&#xA;Rust 1.5.0 (2015-12).&#xA;I started a job where I expect to write C and C++ professionally about 1 month&#xA;ago.&#xA;&#xA;So, I do not have a background like Drew with probably millions of lines of&#xA;C, but I guess that I have a bit more experience with Rust - I wouldn&#39;t say&#xA;that I&#39;m a Rust professional, but I would consider myself a &#34;Advanced Rust&#xA;Hobbyist&#34;.&#xA;&#xA;I&#39;m also not as skilled in writing blog articles or even with the english&#xA;language, so keep that in mind when reading this.&#xA;&#xA;---&#xA;&#xA;I am not a big fan of statement-by-statement replying to an article, but&#xA;I guess for this type of article it is good enough.&#xA;&#xA;First of all, Drews initial statement that Rust was designed by C++&#xA;programmers: Yes, I absolutely see that this is true. Nevertheless I have to&#xA;say that these C++ programmers started developing Rust because C++ was too&#xA;complex and too error-prone in what it did and how it did it.&#xA;Rust is far away from the complexity C++ gives us in terms of language&#xA;features!&#xA;From the top of my head, we have&#xA;&#xA;A full-blown OOP programming paradigm, including&#xA;  Overloading&#xA;  &#34;friends&#34;&#xA;  (multi-)inheritance&#xA;  abstract classes&#xA;  partly and fully virtual functions&#xA;  pointers and references&#xA;  implicit conversions&#xA;  Copy/Move constructors&#xA;  Dynamic and static polymorphism&#xA;Manual memory management&#xA;Template Metaprogramming / Generic programming&#xA;operator overloading&#xA;Lambda expressions&#xA;Exceptions&#xA;&#xA;in C++, whereas in Rust we only get&#xA;&#xA;Dynamic and static polymorphism&#xA;operator overloading&#xA;Lambda expressions&#xA;Generic programming&#xA;&#xA;()&#xA;&#xA;You might consider this list cheated as Rust is not an object oriented&#xA;language like C++, but an imperative one like C. That is very true.&#xA;Nevertheless it is one reason why the cognitive load a C++-Program requires&#xA;one to handle is much higher than an equivalent (as in features of the&#xA;program) Rust program!&#xA;&#xA;Drew claims that the values of C and C++ programmers are incompatible and I&#xA;would agree with that. But that does not (have to) mean that a C-programmer&#xA;and a Rust programmer do not have the same values.&#xA;It is true, though, that Rust can excel at a lot of topics that C++ covers,&#xA;but it also empower programmers that do not feel comfortable writing good C&#xA;code to write their software. And that in a safe and at the same time&#xA;performant language while not being overly blown up.&#xA;&#xA;Further Drew compares C, C++, Go and Rust by their complexity, measured with&#xA;features introduced in the language over the years.&#xA;I am really sorry to say this here, Drew, but we are used to much better from&#xA;you! You say that this approach (bullet points/features listed on wikipedia&#xA;vs. bullet points in articles and release notes) is not very scientific, yes.&#xA;But not even to mention the years these languages were released! For the&#xA;record:&#xA;&#xA;C was released in 1972; 47 years ago)&#xA;C++ was released in 1985; 35 years ago&#xA;Go was released in 2009; 9 years ago)&#xA;Rust was released in 2010; 8 years ago)&#xA;&#xA;I am not saying that this disproves your statement - it even supports it! But&#xA;I do say that comparing based on features per year/release/whatever must&#xA;include a statement about how old these languages are, even if it is just for&#xA;showing the reader about what timeframe we are talking.&#xA;&#xA;So, Rust is a relatively young language and yes, it has added a lot of&#xA;features and therefore can be compared to C++ much better than it can be to C.&#xA;But saying that a 10-year-old C programm might even compile today and&#xA;everything might be okay but not so much with Rust is just ignorant of the&#xA;fact that Rust is not even that old.&#xA;Having a Rust program that is one year old still compiles fine today (assuming&#xA;it didn&#39;t use a compiler bug) and does not &#34;look old&#34; at all!&#xA;Rust has a big infrastructure for doing regression tests and for being&#xA;compatible with older programs.&#xA;&#xA;As you say, out of the way with the philosophical stuff and lets get down to&#xA;the facts.&#xA;&#xA;C is more portable.&#xA;But as mentioned before, C is almost six times as old as Rust. We&#39;ll get there!&#xA;&#xA;C has a spec. Yes, and I completely hear you on this one. Rust does not&#xA;(yet?) have a spec and it really is a pain-point. I want one, too! Maybe we&#39;ll&#xA;get there at some point.&#xA;By the way: Does Go have a spec? It&#xA;seems like it, but that rather looks like a&#xA;language definition and I doubt that this is what Drew meant when talking&#xA;about &#34;a spec&#34;, is it?&#xA;&#xA;C has many implementations. Yes and how much trouble has it been because&#xA;different compilers do different things on undefined behaviour?&#xA;Too many. This is where Rust tries to solve a problem: Get a language where&#xA;undefined behaviour is not allowed or at least as minimal as possible, then we&#xA;can have a spec for that language and then we can have different&#xA;implementations.&#xA;Time will tell whether we can get there.&#xA;&#xA;C has a consistent &amp; stable ABI. Point taken. I do not argue about that.&#xA;&#xA;Cargo is mandatory. Yes, another point taken. I again do not argue.&#xA;&#xA;Concurrency is generally a bad thing.&#xA;This statement gives me the impression that you did not yet try Rust,&#xA;actually. Like in a big (and possibly&#xA;multithreaded/concurrent/parallel/whateveryoucallit) environment.&#xA;You say that most software does not have to be parallel and I fully agree on&#xA;that - but if you need to be parallel, I&#39;d rather chose Rust over Go, C or&#xA;C++. Having the safety guarantees Rust gives me allows normal people (and not&#xA;Rockstar-programmers) to write software that can be massively parallel without&#xA;having to fear about deadlocks and other ugly things you get with other&#xA;languages.&#xA;&#xA;It is still true that bad design decisions are possible and might result in&#xA;bad software - but that is true for every language, isn&#39;t it? And I&#39;d rather&#xA;like to have a bad program that gets the job done because it can be statically&#xA;verified that it does than a program that crashes because I ran into a bug&#xA;that was introduced by bad design decisions.&#xA;&#xA;The next paragraph Drew writes makes me really, really sad. Fullquote:&#xA;&#xA;  Safety. Yes, Rust is more safe. I don’t really care. In light of all of&#xA;  these problems, I’ll take my segfaults and buffer overflows. I especially&#xA;  refuse to “rewrite it in Rust” - because no matter what, rewriting an entire&#xA;  program from scratch is always going to introduce more bugs than maintaining&#xA;  the C program ever would. I don’t care what language you rewrite it in.&#xA;&#xA;This gives me the impression that Drew was hit with &#34;Just rewrite it&#34; too many&#xA;times. And I completely agree with you, Drew, that you should indeed not&#xA;rewrite it in Rust just for the sake. Nobody should ever rewrite anything&#xA;in any other language than what &#34;it&#34; currently is written in.&#xA;I hate these people that actually say things like that (if it isn&#39;t for&#xA;trolling, but I have the uneasy feeling that Drew was hit with real &#34;Just&#xA;rewrite it&#34;ers and not just trolling).&#xA;&#xA;I do not say that the points Drew shows are false.&#xA;&#xA;What I do say is that the initial assumption that Rust is there to replace C&#xA;or C++ is, in my opinion, false.&#xA;It is certainly meant to get things right that C++ got wrong - and it is&#xA;certainly there to replace the C++-Monster that we call Gecko, because Mozilla&#xA;is exactly trying to do that!&#xA;But it is not there to replace all C or C++ code ever written because of&#xA;some stupid &#34;Hey we can do X better than your language&#34; bullshit!&#xA;&#xA;Also, the statement that Rust might end up as Kitchen-Sink like C++ and die&#xA;with feature-bloat is one that concerns me because I do not want Rust to end&#xA;up like C++. It certainly is not as complex as C++ and we (as in &#34;the Rust&#xA;community&#34;) have a lot of work to do to not end up with feature-creep - but&#xA;we are also certainly not there yet.&#xA;But I definitively see where this statement is coming from.&#xA;&#xA;The title of this article is&#xA;&#34;Rust is one of the best C replacements we currently have&#34; - and I stand by&#xA;this. But I also think that it is false to say that anyone has to replace C&#xA;or that Rust is necessarily there to do so.&#xA;&#xA;There are domains where you might want to rewrite C code, if you have the time&#xA;and resources. But I&#39;d rather advice against it.&#xA;Improving existing code is always easier than a rewrite of a program and&#xA;rewriting software does not improve the value of the software or even make&#xA;customers more happy. Rewriting software is IMHO only legit in two cases:&#xA;&#xA;It makes you happy because you&#39;re doing it for fun&#xA;It makes your boss happy because he ordered you to do so (for whatever&#xA;  reasons, may it be speed, resource usage, customer request or whatever)&#xA;&#xA;But just for the sake of it? Nah.&#xA;&#xA;I see where Drews article comes from and I see why he thinks like he does. I&#xA;greatly value his opinion and thoughts, and that&#39;s why I took the time to&#xA;write this article.&#xA;&#xA;I see that we (as in &#34;the Rust community&#34;) have a lot to&#xA;do to make more people happy. Not as in making them Rust programmers, because&#xA;that&#39;s not our goal, but as in showing them that we do not want everything&#xA;to be written in Rust and that it is just trolls that request a &#34;rewrite in&#xA;Rust&#34;.&#xA;&#xA;We do value friendlyness and kindness - let me state explicitely that this&#xA;does also include other programming-language-communities (and all other&#xA;communities as well)!&#xA;&#xA;Trolling does not help with that.&#xA;&#xA;: Yes we have generic programming in Rust. I&#39;m not a professional regarding C++, so I cannot say whether they are comparable in this regard.&#xA;: Some might say that we have manual memory management in Rust as well. That might be true by definition, but not the way I meant it: In C++ we can allocate something on the heap and then forget it. We have to try really hard to do that in Rust, though!&#xA;: In fact I might get into the situation where I have to rewrite an application in my job, but I&#39;d rather rewrite it in the same language than switching languages just for the sake of it!&#xA;&#xA;tags: #open-source #programming #rust #c #c++ #cpp&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>This is a reply to the article
published by Drew DeVault called
<a href="https://drewdevault.com/2019/03/25/Rust-is-not-a-good-C-replacement.html">“Rust is not a good C replacement”</a>.</p>

<hr>

<p>First of all, let me say that Drew is one of the people out there on the
internet whose opinions I highly value. Indeed he is one of the people I try
to read and listen to regardless of topic, because I think he is one of the
people that deserve unconditional attention.</p>

<p>Needless to say that I&#39;ve also read his latest piece
<a href="https://drewdevault.com/2019/03/25/Rust-is-not-a-good-C-replacement.html">“Rust is not a good C replacement”</a>.
I have to admit I was shocked at first, but after a bit of cooling down (and
doing the dishes), I can see where this comes from.</p>

<p>And I have to disagree.</p>

<p>But let me start with my background – because that might be important for you,
dear reader, to classify this article.</p>

<p>My background is mostly hobbyist programming. I did a few years of C, probably
a few 100kloc, not more. I also do rust since about
<a href="https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-150-2015-12-10">Rust 1.5.0 (2015-12)</a>.
I started a job where I expect to write C and C++ professionally about 1 month
ago.</p>

<p>So, I do <em>not</em> have a background like Drew with probably millions of lines of
C, but I <em>guess</em> that I have a bit more experience with Rust – I wouldn&#39;t say
that I&#39;m a Rust professional, but I would consider myself a “Advanced Rust
Hobbyist”.</p>

<p>I&#39;m also not as skilled in writing blog articles or even with the english
language, so keep that in mind when reading this.</p>

<hr>

<p>I am not a big fan of statement-by-statement replying to an article, but
I guess for this type of article it is good enough.</p>

<p>First of all, Drews initial statement that Rust was designed by C++
programmers: Yes, I absolutely see that this is true. Nevertheless I have to
say that these C++ programmers started developing Rust <em>because</em> C++ was too
complex and too error-prone in what it did and how it did it.
Rust is <em>far</em> away from the complexity C++ gives us in terms of language
features!
From the top of my head, we have</p>
<ul><li>A full-blown OOP programming paradigm, including
<ul><li>Overloading</li>
<li>“friends”</li>
<li>(multi-)inheritance</li>
<li>abstract classes</li>
<li>partly and fully virtual functions</li>
<li>pointers and references</li>
<li>implicit conversions</li>
<li>Copy/Move constructors</li>
<li>Dynamic and static polymorphism</li></ul></li>
<li>Manual memory management</li>
<li>Template Metaprogramming / Generic programming</li>
<li>operator overloading</li>
<li>Lambda expressions</li>
<li>Exceptions</li></ul>

<p>in C++, whereas in Rust we only get</p>
<ul><li>Dynamic and static polymorphism</li>
<li>operator overloading</li>
<li>Lambda expressions</li>
<li>Generic programming[^1]</li></ul>

<p>([^2])</p>

<p>You might consider this list cheated as Rust is not an object oriented
language like C++, but an imperative one like C. That is very true.
Nevertheless it is one reason why the cognitive load a C++-Program requires
one to handle is <em>much</em> higher than an equivalent (as in features of the
program) Rust program!</p>

<p>Drew claims that the values of C and C++ programmers are incompatible and I
would agree with that. But that does not (have to) mean that a C-programmer
and a Rust programmer do not have the same values.
It <em>is</em> true, though, that Rust can excel at a lot of topics that C++ covers,
but it also empower programmers that do not feel comfortable writing good C
code to write their software. And that in a safe and at the same time
performant language while not being overly blown up.</p>

<p>Further Drew compares C, C++, Go and Rust by their complexity, measured with
features introduced in the language over the years.
I am really sorry to say this here, Drew, but we are used to much better from
you! You say that this approach (bullet points/features listed on wikipedia
vs. bullet points in articles and release notes) is not very scientific, yes.
But not even to mention the years these languages were released! For the
record:</p>
<ul><li>C was released <a href="https://en.wikipedia.org/wiki/C_(programming_language)">in 1972; 47 years ago</a></li>
<li>C++ was released <a href="https://en.wikipedia.org/wiki/C%2B%2B">in 1985; 35 years ago</a></li>
<li>Go was released <a href="https://en.wikipedia.org/wiki/Go_(programming_language)">in 2009; 9 years ago</a></li>
<li>Rust was released <a href="https://en.wikipedia.org/wiki/Rust_(programming_language)">in 2010; 8 years ago</a></li></ul>

<p>I am not saying that this disproves your statement – it even supports it! But
I do say that comparing based on features per year/release/whatever <em>must</em>
include a statement about how old these languages are, even if it is just for
showing the reader about what timeframe we are talking.</p>

<p>So, Rust is a relatively young language and yes, it has added a lot of
features and therefore can be compared to C++ much better than it can be to C.
But saying that a 10-year-old C programm might even compile today and
everything might be okay but not so much with Rust is just ignorant of the
fact that Rust is not even that old.
Having a Rust program that is one year old still compiles fine today (assuming
it didn&#39;t use a compiler bug) and does not “look old” at all!
Rust has a big infrastructure for doing regression tests and for being
compatible with older programs.</p>

<p>As you say, out of the way with the philosophical stuff and lets get down to
the facts.</p>

<p><strong>C is more portable.</strong>
But as mentioned before, C is almost six times as old as Rust. We&#39;ll get there!</p>

<p><strong>C has a spec.</strong> Yes, and I completely hear you on this one. Rust does not
(yet?) have a spec and it really is a pain-point. I want one, too! Maybe we&#39;ll
get there at some point.
By the way: Does Go have a spec? It
<a href="https://golang.org/ref/spec">seems like it</a>, but that rather looks like a
language definition and I doubt that this is what Drew meant when talking
about “a spec”, is it?</p>

<p><strong>C has many implementations.</strong> Yes and how much trouble has it been because
different compilers do different things on undefined behaviour?
Too many. This is where Rust tries to solve a problem: Get a language where
undefined behaviour is not allowed or at least as minimal as possible, then we
can have a spec for that language and then we can have different
implementations.
Time will tell whether we can get there.</p>

<p><strong>C has a consistent &amp; stable ABI.</strong> Point taken. I do not argue about that.</p>

<p><strong>Cargo is mandatory.</strong> Yes, another point taken. I again do not argue.</p>

<p><strong>Concurrency is generally a bad thing.</strong>
This statement gives me the impression that you did not yet try Rust,
actually. Like in a big (and possibly
multithreaded/concurrent/parallel/whateveryoucallit) environment.
You say that most software does not have to be parallel and I fully agree on
that – but <em>if</em> you need to be parallel, I&#39;d rather chose Rust over Go, C or
C++. Having the safety guarantees Rust gives me allows normal people (and not
Rockstar-programmers) to write software that can be massively parallel without
having to fear about deadlocks and other ugly things you get with other
languages.</p>

<p>It is still true that bad design decisions are possible and might result in
bad software – but that is true for every language, isn&#39;t it? And I&#39;d rather
like to have a bad program that gets the job done because it can be statically
verified that it does than a program that crashes because I ran into a bug
that was introduced by bad design decisions.</p>

<p>The next paragraph Drew writes makes me really, really sad. Fullquote:</p>

<blockquote><p>Safety. Yes, Rust is more safe. I don’t really care. In light of all of
these problems, I’ll take my segfaults and buffer overflows. I especially
refuse to “rewrite it in Rust” – because no matter what, rewriting an entire
program from scratch is always going to introduce more bugs than maintaining
the C program ever would. I don’t care what language you rewrite it in.</p></blockquote>

<p>This gives me the impression that Drew was hit with “Just rewrite it” too many
times. And I completely agree with you, Drew, that you should indeed <em>not</em>
rewrite it in Rust just for the sake. Nobody should <em>ever</em> rewrite <em>anything</em>
in <em>any</em> other language than what “it” currently is written in.
I hate these people that actually say things like that (if it isn&#39;t for
trolling, but I have the uneasy feeling that Drew was hit with real “Just
rewrite it”ers and not just trolling).</p>

<p>I do not say that the points Drew shows are false.</p>

<p>What I do say is that the initial assumption that Rust is there to replace C
or C++ is, in my opinion, false.
It is certainly meant to get things right that C++ got wrong – and it is
certainly there to replace the C++-Monster that we call Gecko, because Mozilla
is exactly trying to do that!
But it is not there to replace <em>all</em> C or C++ code ever written because of
some stupid “Hey we can do X better than your language” bullshit!</p>

<p>Also, the statement that Rust might end up as Kitchen-Sink like C++ and die
with feature-bloat is one that concerns me because I do not want Rust to end
up like C++. It certainly is not as complex as C++ and we (as in “the Rust
community”) have a lot of work to do to <em>not</em> end up with feature-creep – but
we are also certainly not there yet.
But I definitively see where this statement is coming from.</p>

<p>The title of this article is
“Rust is one of the best C replacements we currently have” – and I stand by
this. But I also think that it is false to say that anyone <em>has to</em> replace C
or that Rust is necessarily there to do so.</p>

<p>There are domains where you might want to rewrite C code, if you have the time
and resources. But I&#39;d rather advice against it[^3].
Improving existing code is always easier than a rewrite of a program and
rewriting software does not improve the value of the software or even make
customers more happy. Rewriting software is IMHO only legit in two cases:</p>
<ul><li>It makes you happy because you&#39;re doing it for fun</li>
<li>It makes your boss happy because he ordered you to do so (for whatever
reasons, may it be speed, resource usage, customer request or whatever)</li></ul>

<p>But just for the sake of it? Nah.</p>

<p>I see where Drews article comes from and I see why he thinks like he does. I
greatly value his opinion and thoughts, and that&#39;s why I took the time to
write this article.</p>

<p>I see that we (as in “the Rust community”) have a lot to
do to make more people happy. Not as in making them Rust programmers, because
that&#39;s not our goal, but as in showing them that we do <em>not</em> want everything
to be written in Rust and that it is just trolls that request a “rewrite in
Rust”.</p>

<p>We do value friendlyness and kindness – let me state explicitely that this
does <em>also</em> include other programming-language-communities (and all other
communities as well)!</p>

<p>Trolling does not help with that.</p>

<p>[^1]: Yes we have generic programming in Rust. I&#39;m not a professional regarding C++, so I cannot say whether they are comparable in this regard.
[^2]: Some might say that we have manual memory management in Rust as well. That might be true by definition, but not the way I meant it: In C++ we can allocate something on the heap and then forget it. We have to try really hard to do that in Rust, though!
[^3]: In fact I might get into the situation where I have to rewrite an application in my job, but I&#39;d rather rewrite it in the same language than switching languages just for the sake of it!</p>

<p>tags: <a href="https://beyermatthias.de/tag:open" class="hashtag"><span>#</span><span class="p-category">open</span></a>-source <a href="https://beyermatthias.de/tag:programming" class="hashtag"><span>#</span><span class="p-category">programming</span></a> <a href="https://beyermatthias.de/tag:rust" class="hashtag"><span>#</span><span class="p-category">rust</span></a> <a href="https://beyermatthias.de/tag:c" class="hashtag"><span>#</span><span class="p-category">c</span></a> <a href="https://beyermatthias.de/tag:c" class="hashtag"><span>#</span><span class="p-category">c</span></a>++ <a href="https://beyermatthias.de/tag:cpp" class="hashtag"><span>#</span><span class="p-category">cpp</span></a></p>
]]></content:encoded>
      <guid>https://beyermatthias.de/rust-is-one-of-the-best-c-replacements-we-currently-have</guid>
      <pubDate>Tue, 26 Mar 2019 16:40:00 +0100</pubDate>
    </item>
  </channel>
</rss>