News for hackers. Stuff that matters.
Re:Selecting a programming language can be a form of prematu... by capitalsigma on Monday November 15, 2021 @12:01PM (#29229578)
C++ is forcing a style on you that encourages you to avoid a copy. You could, of course, have a library like:

    std::string ToUpper(const std::string& str) {
      std::string as_lower(str);
      absl::c_transform(str, as_lower, std::toupper);
      return as_lower;
    }


to enable:

    int main() {
      std::cout << ToUpper("hello");
      return 0;
    }

but this would be no good! You have chosen an API that forces your users to be gratuitously inefficient. Maybe that is OK for your personal project, but an API like that has no business in the standard library.
Re:Selecting a programming language can be a form of prematu... by WithinReason on Monday November 15, 2021 @12:05PM (#29229627)
You just explained why C++ will never be as productive as Python.
Re:Selecting a programming language can be a form of prematu... by capitalsigma on Monday November 15, 2021 @12:19PM (#29229794)
No one is stopping you from writing your C++ inefficiently if you choose to. I am skeptical that spending a bit of time thinking about ownership/lifetimes is really such a big hit to productivity.