logoalt Hacker News

jceleriertoday at 12:02 AM1 replyview on HN

how would you write something like

    #include <print>
    #include <map>
    #include <string>

    int main(int argc, char** argv) 
    {
      using namespace std::literals;

      std::string foo = "foo:";
      foo += argv[0];

      std::map<std::string, int> m{
        {foo, 123}
      , {"count: "s + std::to_string(argc), 456}
      };

      std::println("{}", m);
    }
in C

Replies

hackyhackytoday at 4:33 AM

Sure, there are nice parts of C++. And there are also brain-dead parts that add needless complexity such as:

* rvalue references

* the difference between auto, decltype, typeof

* unreadable template monstrosities

* various different flavors of "smart" pointer

* the continued existence of footguns relating to UB, dangling pointers, unexpected temporary lifetimes, etc

* total absence of a build system or package management

* legacy APIs that still take raw pointers

* concepts, a half-assed attempt at generic constraints