‹ BackHN Continuity

Thread

German Rheinmetall open-sources its Battlesuite connected weapon system protcol

284 points · 109 comments · summarity

  1. jjmarr · · focus · HN ↗
    Open the C++ example up and the first thing I see:

    ```cpp std::cout << "Received ReportCoordinateFrameSettings" << std::endl; ```

    Generally, I've heard `std::endl` instead of \n has bad performance because it forces the statement to print immediately. And because cout is guaranteed to flush anyways when the program ends, you're adding a delay for no reason.

    I wonder if there's something I'm not seeing that led to them adopting this rule. e.g. "abnormal program termination" caused by the weapon blowing itself up circumventing a buffer flush?

    1. aftbit · · focus · HN ↗
      This seems like an incredibly unimportant quibble... I would imagine they just used std::endl b/c that's what most random tutorials used in the 2000s and that's how the engineer learned. If you are printing a debug string, you probably don't care that much about perf in the first place.
      1. jjmarr · · focus · HN ↗
        I was wondering if it's a hard real-time constraint or something to ensure consistent timing.
      2. MiroslavPokorny · · focus · HN ↗
        Ask yourself, would a newbie make that mistake ?
    2. __d · · focus · HN ↗
      For a long time, std::endl demonstrated that you were a proper C++ programmer, not some neckbeard C apologist. It wasn’t until C++ had „won“ that it became acceptable to use \n again.
    3. gavinray · · focus · HN ↗
      The modern C++ idiom is std::println() anyways...

      <a href="https:&#x2F;&#x2F;en.cppreference.com&#x2F;cpp&#x2F;io&#x2F;println" rel="nofollow">https:&#x2F;&#x2F;en.cppreference.com&#x2F;cpp&#x2F;io&#x2F;println

    4. niemandhier · · focus · HN ↗
      Cool I did not know that.

      Your comment is a bit salty, but I learned something from it, so I don’t think you deserve the downvotes

    5. rsynnott · · focus · HN ↗
      &gt; And because cout is guaranteed to flush anyways when the program ends, you&#x27;re adding a delay for no reason.

      I mean... If your command line utility doesn&#x27;t print anything til it&#x27;s done, that is going to be, _at best_, an annoying user experience.

    6. harrouet · · focus · HN ↗
      &gt; cout is guaranteed to flush anyways when the program ends

      This is not always true in the case the program crashes. I&#x27;ve had case where `std::endl` was necessary.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.