<story><title>Transmission torrent client ported to C++</title><url>https://github.com/transmission/transmission/pull/1787</url></story><parent_chain><item><author>yakubin</author><text>STL has a lot of weird pitfalls. There was &lt;i&gt;std::vector&amp;lt;bool&amp;gt;&lt;/i&gt;. Here you can see some pitfalls of &lt;i&gt;std::unordered_map&lt;/i&gt;: &amp;lt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;youtu.be&amp;#x2F;ncHmEUmJZf4?t=2220&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;youtu.be&amp;#x2F;ncHmEUmJZf4?t=2220&lt;/a&gt;&amp;gt;. The whole talk is interesting to watch. In the beginning you can also see the puzzling design of &lt;i&gt;std::unordered_map&lt;/i&gt; (puzzling because of the number of indirections).&lt;p&gt;I&amp;#x27;d reach for abseil first: &amp;lt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;abseil.io&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;abseil.io&amp;#x2F;&lt;/a&gt;&amp;gt;.</text></item><item><author>qalmakka</author><text>I think it&amp;#x27;s a sensible choice. I&amp;#x27;ve seen way too many C codebases rewriting half of the STL or using clunky macro hacks (or worse, half-assed linked lists) when basically every single platform out there has a copy on the STL available which includes containers and algorithms with excellent performances and are well tested.&lt;p&gt;It&amp;#x27;s complicated but it&amp;#x27;s the only reasonable choice. You can then write your code C-style while compiling it as C++ and nobody will bat an eye.</text></item></parent_chain><comment><author>cjfd</author><text>These pitfalls really aren&amp;#x27;t that bad. An extra copy here and there only matters in the tight loops. Some of the examples in the talk are really contrived. Am I going to insert the empty string many times as a string in a hash map? No, in most cases I am going to make sure that almost all of the keys that I generate are different. Sure, google can save on its electricity bill by doing micro-optimizations. For me trying that would be a bad trade.&lt;p&gt;Every language has its pitfalls and I tend to prefer C++ pitfalls to some other pitfalls. Lately I having been doing some python. Turns out a python -m venv is different from a virtualenv. Turns out pytest some&amp;#x2F;specific&amp;#x2F;test&amp;#x2F;file.py is different from python -m pytest some&amp;#x2F;specific&amp;#x2F;test&amp;#x2F;file.py. I am wishing quite hard this code base consisted of all C++. And of course mypying this is still on the TODO list so the type annotations that are there might well lie.</text></comment>
<story><title>Transmission torrent client ported to C++</title><url>https://github.com/transmission/transmission/pull/1787</url></story><parent_chain><item><author>yakubin</author><text>STL has a lot of weird pitfalls. There was &lt;i&gt;std::vector&amp;lt;bool&amp;gt;&lt;/i&gt;. Here you can see some pitfalls of &lt;i&gt;std::unordered_map&lt;/i&gt;: &amp;lt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;youtu.be&amp;#x2F;ncHmEUmJZf4?t=2220&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;youtu.be&amp;#x2F;ncHmEUmJZf4?t=2220&lt;/a&gt;&amp;gt;. The whole talk is interesting to watch. In the beginning you can also see the puzzling design of &lt;i&gt;std::unordered_map&lt;/i&gt; (puzzling because of the number of indirections).&lt;p&gt;I&amp;#x27;d reach for abseil first: &amp;lt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;abseil.io&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;abseil.io&amp;#x2F;&lt;/a&gt;&amp;gt;.</text></item><item><author>qalmakka</author><text>I think it&amp;#x27;s a sensible choice. I&amp;#x27;ve seen way too many C codebases rewriting half of the STL or using clunky macro hacks (or worse, half-assed linked lists) when basically every single platform out there has a copy on the STL available which includes containers and algorithms with excellent performances and are well tested.&lt;p&gt;It&amp;#x27;s complicated but it&amp;#x27;s the only reasonable choice. You can then write your code C-style while compiling it as C++ and nobody will bat an eye.</text></item></parent_chain><comment><author>qalmakka</author><text>&amp;gt; STL has a lot of weird pitfalls&lt;p&gt;everything that&amp;#x27;s old and has legacy is doomed to have several. It&amp;#x27;s just a fact of life.&lt;p&gt;The C++ committee doesn&amp;#x27;t and can&amp;#x27;t just throw away stuff like `std::vector&amp;lt;bool&amp;gt;`, despite it being a whole fractal of bad ideas, because people have already used that piece of dung in uncountable projects. It would be nice to have a way to get a _normal_ vector of booleans (even though vector&amp;lt;char&amp;gt; just suffices most of the time), but that&amp;#x27;s life I guess.</text></comment>