3 comments

  • jasode1 hour ago
    The submitted title is missing the salient keyword <i>&quot;finally&quot;</i> that motivates the blog post. The actual subtitle Raymond Chen wrote is: <i>&quot;C++ says “We have try…finally at home.”&quot;</i><p>It&#x27;s a snowclone based on the meme, <i>&quot;Mom, can we get &lt;X&gt;? No, we have &lt;X&gt; at home.&quot;</i> : <a href="https:&#x2F;&#x2F;www.google.com&#x2F;search?q=%22we+have+x+at+home%22+meme" rel="nofollow">https:&#x2F;&#x2F;www.google.com&#x2F;search?q=%22we+have+x+at+home%22+meme</a><p>In other words, Raymond is saying... &quot;We already have Java feature of &#x27;finally&#x27; at home in the C++ refrigerator and it&#x27;s called &#x27;destructor&#x27;&quot;<p>To continue the meme analogy, the kid&#x27;s idea of &lt;X&gt; doesn&#x27;t match mom&#x27;s idea of &lt;X&gt; and disagrees that they&#x27;re equivalent. E.g. &quot;Mom, can we order pizza? No, we have leftover casserole in the fridge.&quot;<p>So some kids would complain that C++ destructors RAII philosophy require creating a whole &quot;class X{public:~X()}&quot; which is sometimes inconvenient so it doesn&#x27;t exactly equal &quot;finally&quot;.
    • vidarh10 minutes ago
      I&#x27;m curious about the actual origin now, given that a quick search shows only vague references or claim it is recent, but this meme is present in Eddie Murphys &quot;Raw&quot; from 1987, so it is at least that old.
    • thombles1 hour ago
      HN has some heuristics to reduce hyperbole in submissions which occasionally backfire amusingly.
      • mort9639 minutes ago
        Yeah it&#x27;s a huge mistake IMO. I see it fucking up titles so frequently, and it flies in the face of the &quot;do not editorialise titles&quot; rule:<p><pre><code> [...] please use the original title, unless it is misleading or linkbait; don&#x27;t editorialize. </code></pre> It is <i>much</i> worse, I think, to regularly drastically change the meaning of a title automatically until a moderator happens to notice to change it back, than to allow the occasional somewhat exaggerated original post title.<p>As it stands, the HN title suggests that Raymond thinks the C++ &#x27;try&#x27; keyword is a poor imitation of some other language&#x27;s &#x27;try&#x27;. In reality, the post is about a way to mimic Java&#x27;s &#x27;finally&#x27; in C++, which the original title clearly (if humorously) encapsulates. Raymond&#x27;s words have been misrepresented here for over 4 hours at this point. I do not understand how this is an acceptable trade-off.
      • tux343 minutes ago
        It&#x27;s rare to see the mangling heuristics improve a title these days. There was a specific type of clickbait title that was overused at the time, so a rule was created. And now that the original problem has passed, we&#x27;re stuck with it.
  • tryfinally1 hour ago
    I always wonder whether C++ syntax ever becomes readable when you sink more time into it, and if so - how much brain rewiring we would observe on a functional MRI.
    • deliciousturkey4 minutes ago
      In my opinion, C++ syntax is pretty readable. Of course there are codebases that are difficult to read (heavily abstracted, templated codebases especially), but it&#x27;s not really that different compared to most other languages. But this exists in most languages, even C can be as bad with use of macros.<p>By far the worst in this aspect has been Scala, where every codebase seems to use a completely different dialect of the language, completely different constructs etc. There seems to have very little agreement on how the language should be used. Much, much less than C++.
    • sigmoid1045 minutes ago
      It does... until you switch employers. Or sometimes even just read a coworker&#x27;s code. Or even your own older code. Actually no, I don&#x27;t think anyone achieved full readability enlightenment. People like me just hallucinated it after doing the same things for too long.
      • Yoric13 minutes ago
        Sadly, that is exactly my experience.
      • usrnm31 minutes ago
        And yet, somehow Lisp continues to be everyone&#x27;s sweetheart, even though creating literal new DSLs for every project is one of the features of the language.
    • m-schuetz32 minutes ago
      &quot;using namespace std;&quot; goes a long way to make C++ more readable and I don&#x27;t really care about the potential issues. But yeah, due to a lack of a nice module system, this will quickly cause problems with headers that unload everything into the global namespace, like the windows API.<p>I wish we had something like Javascript&#x27;s &quot;import {vector, string, unordered_map} from std;&quot;. One separate using statement per item is a bit cumbersome.
  • mojuba1 hour ago
    I like how Swift solved this: there&#x27;s a more universal `defer { ... }` block that&#x27;s executed at the end of a given scope no matter what, and after the `return` statement is evaluated if it&#x27;s a function scope. As such it has multiple uses, not just for `try ... finally`.
    • dwattttt47 minutes ago
      I was contemplating what it would look like to provide this with a macro in Rust, and of course someone has already done it. It&#x27;s syntactic sugar for the destructor&#x2F;RAII approach.<p><a href="https:&#x2F;&#x2F;docs.rs&#x2F;defer-rs&#x2F;latest&#x2F;defer_rs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;defer-rs&#x2F;latest&#x2F;defer_rs&#x2F;</a>