News for hackers. Stuff that matters.
Re:Will Carbon Replace C++? by LaLaLand122 on Monday February 27, 2023 @11:12PM (#34965527)
It's good that you can solve this with 100% of the team following 100% of the time the rules/guides.

It's even better if your language has a way to express "the return value points to data from the input argument, so it's a compile error to pass a rvalue string to this function". The second we got a language able to do that, usable everywhere where C++ is, (yes, that one) the incapacity of C++ to express this became "a problem with C++". Our expectations have just increased.

Surely it can be catched via static analysis if you suppose the common case that the return value is a function of the argument, and not pointing to some static global data. But you will get false positives when somebody does the uncommon case. There is a lack of expressiveness in C++ here.

Re:Will Carbon Replace C++? by hot_gril on Tuesday February 28, 2023 @12:20AM (#34965927)
The "oh shit" moment when we found that our database's indexes got mysteriously corrupted and we had no idea from where. What do we do, fire the entire team to get rid of whoever made the bug?
Re:Will Carbon Replace C++? by account42 on Tuesday February 28, 2023 @06:09AM (#34968029)
But C++ can express that, with compiler extensions:

https://godbolt.org/z/ohxaGzsEM

Re:Will Carbon Replace C++? by LaLaLand122 on Tuesday February 28, 2023 @08:18AM (#34968934)
That's cool.

Last I remember, the lifetime profile stuff was there, but there was still no way to add your own annotations. For some reason, I didn't hear too much about any of this, it was

- clang is working on it

- clang is working on it

- clang is working on it

- Visual Studio has it

- clang is working on it

- Silence

gcc still has nothing, right?

Re:Will Carbon Replace C++? by LaLaLand122 on Tuesday February 28, 2023 @08:38AM (#34969145)
I have just taken a look... https://wg21.link/p1179 is actually still not there, right? I see some interesting stuff in https://discourse.llvm.org/t/rfc-lifetime-annotations-for-c/... from last year. But, in general... once Herb started the whole Lifetime safety profile thing, there seemed to be a lot of interest, but for the last few years things seems to have died? I think things are better with Visual Studio, but being on Linux... I may need to start developing for Linux from Visual Studio with WSL2 :-(
Re:Will Carbon Replace C++? by pjmlp on Tuesday February 28, 2023 @12:01PM (#34971701)
Only VC++ is working on it, the clang tidy developer looking into lifetime has moved on.
Re:Will Carbon Replace C++? by LaLaLand122 on Wednesday March 01, 2023 @04:29PM (#34988605)
That's just sad.