You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's been a lot of work in C++20/C++23 around text handling, and formatting/printing in particular. From the goals laid out in the readme, the "feels like a new language" should IMO definitely apply to one of the cruftiest (again IMO) corners in common syntax (so common it's in the splash example...) - the overloaded bitshift and std:cout.
In other words, I think a better advertisement for cpp2 could be (using P2093; also matches import std; default):
main: () -> int = {
print("Hello, {}!", "world");
}
In the broader scope, this would also need some decent string manipulation APIs (concatenation, slicing, etc.), which C++ is lacking quite a bit. Xref also #45
The text was updated successfully, but these errors were encountered:
I think part of the reason that this particular example was used is that it is the "classic" hello world from C++98, and shows that you can easily convert it to Cpp2, and also that compiling with import std; is faster than #include <iostreams> for the same program. So it's a good "conversion" story. I agree that your version is a good "next generation" example.
Yes, I absolutely do love C++23 print and I considered showing it.
But:
none of the vendors implement it yet... here is a Godbolt link for std::print Hello world using "trunk/latest" for Gcc, Clang, and MSVC... as of today not one of them compiles it, though I hope this link should gradually show them supporting this in the future)
a major point of using the usual cout << "Hello"; example is to bold-underline-italic-double-underscore that this is C++, you can use the whole standard library and operator overloading etc.
I'm definitely watching it though, and when it's shipping I can start showing it. Also, as soon as the C++ vendors do implement it, it will work seamlessly in Cpp2 via cppfront. :)
There's been a lot of work in C++20/C++23 around text handling, and formatting/printing in particular. From the goals laid out in the readme, the "feels like a new language" should IMO definitely apply to one of the cruftiest (again IMO) corners in common syntax (so common it's in the splash example...) - the overloaded bitshift and
std:cout
.In other words, I think a better advertisement for cpp2 could be (using P2093; also matches
import std;
default):rather than
In the broader scope, this would also need some decent string manipulation APIs (concatenation, slicing, etc.), which C++ is lacking quite a bit. Xref also #45
The text was updated successfully, but these errors were encountered: