Earlier quoted context omitted.
I think the c++ version could be more understandable but it’s as if the authors intentionally made it as obtuse as possible.
The authors are required to make it obtuse. They're required to use warts on all of the names because most of the code is in the head files and is generative code compiled by users of the library rather than the vendor. In order to avoid naming conflicts they can only use obscured names in their implementation of any but the defined API (eg. naming any internal functions, macros, or variables with leading underscores…
Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
121–130 of 174 posts
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#122Earlier quoted context omitted.
> Cpp2 isn't trying to be a successor language to C++ Herb is trying to sell it as not a successor because for now that suits him better. Because C++ is a general purpose language Herb can deliver a "not a new feature" that is so elaborate in practice you would never write the equivalent C++ by hand, but Herb can insist that since technically it can still be transpiled to C++ it's not a different language... right up…
The linked article explicitly states > What it isn't. Cpp2 is not a successor or alternate language [...]
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#123Earlier quoted context omitted.
I've always thought that using "<<" in that manner was more of a way to show off the operator overloading feature than anything else.
I think the original point was to make a typesafe printf that's still reasonably efficient without creating a bunch of small temporary strings. Like, if you printf like this: printf("Number %d, String %s", n, s); but the types of n and s aren't int and char*, all hell breaks loose and you have the origin of a million CVEs. But how do you make that function signature typesafe, without the tools of modern templates? Yo…
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#124This is a step in the wrong direction.
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#125I don't want bounds-checking, so lost interest immediately. This is a step in the wrong direction.
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#126Unfortunately the first example already re-uses one of the less good parts of C++, the "<<" operator for std::cout, which always was a bit of a hack (including strange order of operations since << normally is left shift)
std::cout
And get the x/y/z breakdown automatically.Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#127Unfortunately the first example already re-uses one of the less good parts of C++, the "<<" operator for std::cout, which always was a bit of a hack (including strange order of operations since << normally is left shift)
I kinda like it, it's comfortable and pragmatic. I don't have to look at the docs to figure out what's the format specifier for something like a size_t, and you can easily add support for whatever might be needed, so you can comfortably do: std::cout And get the x/y/z breakdown automatically.
fmt::println("Player is at {}", _player_pos);Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#128Unfortunately the first example already re-uses one of the less good parts of C++, the "<<" operator for std::cout, which always was a bit of a hack (including strange order of operations since << normally is left shift)
I kinda like it, it's comfortable and pragmatic. I don't have to look at the docs to figure out what's the format specifier for something like a size_t, and you can easily add support for whatever might be needed, so you can comfortably do: std::cout And get the x/y/z breakdown automatically.
It becomes cumbersome very fast.
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#129I don't want bounds-checking, so lost interest immediately. This is a step in the wrong direction.
There's barely a point in making a better C++ if you're not going to address one of the most obvious footguns.
Contracts are all about introducing undefined behaviour if you don't satisfy a precondition.
In practice this improves software quality on many levels by clearly defining requirements on interface boundaries that would otherwise be implicit or just documented.
Of course you can have special debug modes where you actually check that contracts are being satisfied.
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#130Earlier quoted context omitted.
> It should be a positive example of how they hope their language is used, right? should it though? there's a million ways to learn C++. Reading the std code definitely isn't one - technically the std could be entirely compiler builtins. If you want to read positive examples take A Tour of C++ 3rd edition ( https://www.amazon.ca/Tour-C-Bjarne-Stroustrup/dp/0136816487 )
"Do as I say, not as I do" is known to be poor pedagogy. If you find that expert practitioners don't do the things you think students should be doing, it suggests that something is wrong and needs fixing. In the standard library implementations it's very obvious that something is badly wrong, and yet for decades C++ has resisted the hard work of fixing it.
> If you find that expert practitioners don't do the things you think students should be doing, it suggests that something is wrong and needs fixing
It does not and is a very naïve world view. In any trade expert practitioners' way of working is wildly different from what you would learn in a classroom (and generally makes said student's hair raise on their head when they see. This is not too relevant with C++ though as the std implementation "ugliness" is mainly driven by material constraints.
Besides in general in programming this is not even possible. Like, from your argument one wouldn't be able to learn how to use the Win32 API or Cocoa API since the operating systems using them are closed-source and you cannot see how they are implemented & used by the teams who develop these APIs.