<story><title>Does C++ still deserve a bad rap?</title><url>https://nibblestew.blogspot.com/2020/10/does-c-still-deserve-bad-rap-it-has-had.html</url></story><parent_chain><item><author>john_moscow</author><text>Like every programming language out there, C++ is a tool. And like every tool out there it has its uses.&lt;p&gt;There isn&amp;#x27;t any point of using C++ to count words in a text file. Any high-level language like Python will beat you to it. However, there&amp;#x27;s one thing you can do in C++ and not in Python or JavaScript or PHP: fully control the memory layout of your data.&lt;p&gt;While you don&amp;#x27;t need it in most of the cases, it becomes a killer feature when directly dealing with large amounts of data:&lt;p&gt;* Try implementing an on-disk hash table in Python and you&amp;#x27;re stuck manually packing ints and longs in an out of arrays. In C++ it could a simple template used with a memory-mapped file.&lt;p&gt;* Try doing anything non-trivial on a microcontroller with 32KB of RAM. You could theoretically use a higher-level language, but you will end up using &amp;gt;10x amount of RAM.&lt;p&gt;* Try designing an application-specific data structure in any other language. Let&amp;#x27;s say you have an ~8GB in-memory database that slowly adds records one-by-one and then invalidates them in chunks. A C++ implementation will rip anything else to shreds. You just won&amp;#x27;t get the same speed and memory efficiency.&lt;p&gt;What it means in practice, is that unless you have an existing project that uses C++ anyway, you want to partition it: do the memory-critical part in C++, and communicate to it from a higher-level language via a high-level interface. You will get performance where you need it and a peace of mind everywhere else.</text></item></parent_chain><comment><author>josefx</author><text>&amp;gt; There isn&amp;#x27;t any point of using C++ to count words in a text file.  Any high-level language like Python will beat you to it.&lt;p&gt;People using c++ usually care about programs finishing before the heat death of the universe. I had a few Python scripts that spend several seconds parsing larger files, after a rewrite to c++ that changed to almost instant.</text></comment>
<story><title>Does C++ still deserve a bad rap?</title><url>https://nibblestew.blogspot.com/2020/10/does-c-still-deserve-bad-rap-it-has-had.html</url></story><parent_chain><item><author>john_moscow</author><text>Like every programming language out there, C++ is a tool. And like every tool out there it has its uses.&lt;p&gt;There isn&amp;#x27;t any point of using C++ to count words in a text file. Any high-level language like Python will beat you to it. However, there&amp;#x27;s one thing you can do in C++ and not in Python or JavaScript or PHP: fully control the memory layout of your data.&lt;p&gt;While you don&amp;#x27;t need it in most of the cases, it becomes a killer feature when directly dealing with large amounts of data:&lt;p&gt;* Try implementing an on-disk hash table in Python and you&amp;#x27;re stuck manually packing ints and longs in an out of arrays. In C++ it could a simple template used with a memory-mapped file.&lt;p&gt;* Try doing anything non-trivial on a microcontroller with 32KB of RAM. You could theoretically use a higher-level language, but you will end up using &amp;gt;10x amount of RAM.&lt;p&gt;* Try designing an application-specific data structure in any other language. Let&amp;#x27;s say you have an ~8GB in-memory database that slowly adds records one-by-one and then invalidates them in chunks. A C++ implementation will rip anything else to shreds. You just won&amp;#x27;t get the same speed and memory efficiency.&lt;p&gt;What it means in practice, is that unless you have an existing project that uses C++ anyway, you want to partition it: do the memory-critical part in C++, and communicate to it from a higher-level language via a high-level interface. You will get performance where you need it and a peace of mind everywhere else.</text></item></parent_chain><comment><author>stouset</author><text>You list some good use-cases for C++, but the other side of the coin is that there are languages out there nowadays that are &lt;i&gt;better&lt;/i&gt; than C++ for a large majority of the use-cases where it fits best (Rust being the obvious example).&lt;p&gt;Yes, there are surely still a few cases where C++ beats Rust on raw merit. And of course C++ still has the advantage in the number of developers who can competently contribute to your project in short order. But both of these advantages are diminishing rapidly, and—to me at least—the writing is on the wall for C++. Its days are numbered.</text></comment>