<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Word-Count on Posts about Software Development</title>
    <link>https://siedentop.dev/tags/word-count/</link>
    <description>Recent content in Word-Count on Posts about Software Development</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 21 Oct 2020 01:59:35 -0700</lastBuildDate>
    <atom:link href="https://siedentop.dev/tags/word-count/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Optimizing C&#43;&#43; Word Count</title>
      <link>https://siedentop.dev/posts/cpp-word-count/</link>
      <pubDate>Wed, 21 Oct 2020 01:59:35 -0700</pubDate>
      <guid>https://siedentop.dev/posts/cpp-word-count/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://siedentop.dev/posts/swift-word-count&#34;&gt;Yesterday&amp;rsquo;s post&lt;/a&gt; showed that the original C++ version is around 13 times&#xA;slower than my non-optimized &lt;a href=&#34;https://siedentop.dev/posts/rust-reputation&#34;&gt;Rust version&lt;/a&gt;. Next, I&amp;rsquo;ll show how to get&#xA;easily equivalent performance to Rust.&lt;/p&gt;&#xA;&lt;p&gt;One problem that I immediately made out when first seeing the C++ version is&#xA;that it uses &lt;code&gt;std::regex&lt;/code&gt;. &lt;code&gt;std::regex&lt;/code&gt; is known to be horribly slow &lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Just replacing the checking of the file name extension with the in-built&#xA;&lt;code&gt;e.path().extension() != &amp;quot;.txt&amp;quot;&lt;/code&gt; speeds up from 373 ms to 52ms!&lt;/p&gt;</description>
    </item>
    <item>
      <title>Swift Word Count</title>
      <link>https://siedentop.dev/posts/swift-word-count/</link>
      <pubDate>Wed, 21 Oct 2020 00:30:28 -0700</pubDate>
      <guid>https://siedentop.dev/posts/swift-word-count/</guid>
      <description>&lt;p&gt;Yesterday, I wrote about &lt;a href=&#34;https://siedentop.dev/posts/rust-reputation&#34;&gt;implementing word-count in Rust&lt;/a&gt;. Having never&#xA;written Swift before&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;, I wanted to try my hand at the same problem.&lt;/p&gt;&#xA;&lt;p&gt;This is certainly not comparable to my Rust version or the C++ version &lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;.&#xA;Doing this in Swift just consisted of constant googling and the result is&#xA;certainly not what a proficient Swifter would write.&lt;/p&gt;&#xA;&lt;h2 id=&#34;getting-started&#34;&gt;Getting started&lt;/h2&gt;&#xA;&lt;p&gt;I created a new Swift package, and built it in the command line. All three&#xA;commands need no explanation:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Rust Word Count</title>
      <link>https://siedentop.dev/posts/rust-reputation/</link>
      <pubDate>Mon, 19 Oct 2020 20:27:31 -0700</pubDate>
      <guid>https://siedentop.dev/posts/rust-reputation/</guid>
      <description>&lt;p&gt;Last week there were two posts on the reputation of C++. In a noble effort,&#xA;&lt;a href=&#34;https://twitter.com/jpakkane&#34;&gt;Jussi Pakkanen&lt;/a&gt; showcased &lt;a href=&#34;https://nibblestew.blogspot.com/2020/10/does-c-still-deserve-bad-rap-it-has-had.html&#34;&gt;modern C++&lt;/a&gt;. Nothing fancy, just clean and&#xA;readable code. Unfortunately, around ten years after C++11, the news that simple&#xA;(and safe) C++ code is now the default has not spread everywhere.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://twitter.com/jmoiron&#34;&gt;Jason Moiron&lt;/a&gt; answered with Go code doing the same (&lt;a href=&#34;http://jmoiron.net/blog/cpp-deserves-its-bad-reputation&#34;&gt;article&lt;/a&gt;). Both&#xA;programs find the ten most common words in all &lt;em&gt;txt&lt;/em&gt; files, which can be&#xA;recursively found in the current directory.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
