Earlier quoted context omitted.
But you can do that with fmtlib/std::format as well when you provide formatting for custom types, that just becomes: fmt::println("Player is at {}", _player_pos);
Should be possible to implement cout more effectively since there is no string parsing. I say “should” because in practice it seems to be the other way around. I don’t know why.
Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
151–160 of 174 posts
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#152Earlier quoted context omitted.
Don't you think it just serves to highlight that Cpp2 is just C++? That it's explicitly not some new language with C++ FFI like Carbon.
Not sure what is meant by this statement. Both cpp2 and Carbon are different languages, neither of them claim to be just C++. Both languages will have bidirectional compatibility with C++ so that code written in C++ can be directly accessed from Carbon and code written in Carbon can be directly accessed from C++. Neither of them use an FFI for compatibility.
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#153Earlier quoted context omitted.
"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.
Yet thousands of people learned C++ well enough to use it in a professional setting, so surely > does not hold in the general case. > 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…
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#154Earlier quoted context omitted.
The main iteration this cycle for the next C++ is contracts. 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 satis…
> The main iteration this cycle for the next C++ is contracts. As ever the C++ train leaves on schedule with or without anything you suppose is "promised" for that standard revision. This has been the practice since 2011 and I don't expect it to stop unless ISO tells them "Enough" or the whole thing comes apart. > Contracts are all about introducing undefined behaviour if you don't satisfy a precondition. Nope. That'…
Now regarding undefined behaviour, it's always been the reason why the proposal isn't moving forward. Some people believe religiously undefined behaviour is evil and will oppose anything tied to it. The kind of clause you mentioned is just to appease them and attain a compromise.
But ultimately, contracts and undefined behaviour (depending on the definition you go for) are intimately linked.
Consider lower_bound. The behaviour is undefined if the input is not sorted. That's just the way it is.
You can't magically make a program well-formed if you breach preconditions even if you say optimizers are not allowed to make additional assumptions.
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#155Earlier quoted context omitted.
> The main iteration this cycle for the next C++ is contracts. As ever the C++ train leaves on schedule with or without anything you suppose is "promised" for that standard revision. This has been the practice since 2011 and I don't expect it to stop unless ISO tells them "Enough" or the whole thing comes apart. > Contracts are all about introducing undefined behaviour if you don't satisfy a precondition. Nope. That'…
I've been involved with the C++ standards committee for 12+ years and my experience is that it is largely political; championing a proposal is more of a demagogic endeavor than anything else. Influential players have been priming contracts (that have been in the works forever) as a core objective this cycle and giving it a lot of momentum for it to happen this time. Of course if people still can't be convinced it's g…
No, it's a classic WG21 choice in that it's pointlessly worse, that's not "the way it is" it's just the way WG21 decided to define it in C++. More reasonable choices would obviously include the choice made over in std::set where lower_bound gives you a past-the-end iterator if there isn't an apparent answer for your inputs.
Undefined Behaviour is the worst choice, which is why in a horrible way it makes sense as WG21's default - a group known for always choosing bad defaults.
> You can't magically make a program well-formed if you breach preconditions
Of course you can, it's not even hard.
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#156Earlier quoted context omitted.
"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.
Yet thousands of people learned C++ well enough to use it in a professional setting, so surely > does not hold in the general case. > 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…
These "material constraints" are clearly completely artificial - since they don't show up in other languages (rust, go, swift, haskell, etc etc). For example, in C++'s std header files:
- Symbols are hand-mangled. (Why? Wasn't that the whole point of C++ namespaces?)
- There are no comments. I'm guessing the reason for this is that C++'s idiotic build process dedicates an insane amount of CPU time to redundantly reparsing the std header files over and over, forever. This has a very real performance impact across the ecosystem. Either that or the authors just don't believe in commenting their code.
- Templating seems to make the code even more unreadable. Which is strange, because rust's standard library also uses generics and yet it is totally readable.
- Different C++ compilers have different implementations of the standard library, with different performance profiles and quality standards. There is no good reason for this.
> 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.
This wasn't the central argument, but you're still kinda right about this!
I don't have much experience with windows, but I can tell you from my personal experience that it is significantly harder to understand Apple's platform APIs because the code is closed source. There are lots of important methods in Apple's APIs with obscure, technical names and next to no documentation. You have no idea what they do, or if they'll solve the problem you're facing. Its crazy frustrating. When working with opensource code (eg rust, javascript, java, etc) I'm constantly reading the source code of library functions I call to understand how they work and what they do. Its like a backstop for documentation. If the docs are missing or not good enough, having the code available means I can still almost always figure out how to solve my problem.
I can't find it now, but there was a comment thread about windows engineers a few decades ago admitting they made some APIs obscure and badly documented on purpose so they could make money writing and selling technical books on the side on "Windows Internals". Because the source code wasn't available and documentation was shoddy, you needed to buy those books in order to understand and use some of the windows APIs correctly.
So yes, library code should be readable. When you can't read the libraries you're using, it causes all sorts of problems.
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#157Earlier quoted context omitted.
I've been involved with the C++ standards committee for 12+ years and my experience is that it is largely political; championing a proposal is more of a demagogic endeavor than anything else. Influential players have been priming contracts (that have been in the works forever) as a core objective this cycle and giving it a lot of momentum for it to happen this time. Of course if people still can't be convinced it's g…
> Consider lower_bound. The behaviour is undefined if the input is not sorted. That's just the way it is. No, it's a classic WG21 choice in that it's pointlessly worse, that's not "the way it is" it's just the way WG21 decided to define it in C++. More reasonable choices would obviously include the choice made over in std::set where lower_bound gives you a past-the-end iterator if there isn't an apparent answer for y…
std::set preserves sorted as an invariant, so there is no such precondition on its lower_bound member.
The important requirement for std::set is that the comparison function satisfies a strict weak ordering. Again, the behaviour is undefined if it does not.
There is no substitute for correctness. You need to satisfy the requirements or stuff doesn't work. Whether the "doesn't work" means an error, a crash, corrupt memory, resource leaks or incorrect results doesn't really make much of a difference: the code is incorrect and should be fixed.
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#158Earlier quoted context omitted.
> Consider lower_bound. The behaviour is undefined if the input is not sorted. That's just the way it is. No, it's a classic WG21 choice in that it's pointlessly worse, that's not "the way it is" it's just the way WG21 decided to define it in C++. More reasonable choices would obviously include the choice made over in std::set where lower_bound gives you a past-the-end iterator if there isn't an apparent answer for y…
Ignoring the fact that WG21 is not a single person or entity, but 200 people with disjoint interests, your whole argument doesn't make sense. std::set preserves sorted as an invariant, so there is no such precondition on its lower_bound member. The important requirement for std::set is that the comparison function satisfies a strict weak ordering. Again, the behaviour is undefined if it does not. There is no substitu…
How did you get the idea that I mistakenly believed WG21 is a "single person or entity"?
> There is no substitute for correctness. You need to satisfy the requirements or stuff doesn't work. Whether the "doesn't work" means an error, a crash, corrupt memory, resource leaks or incorrect results doesn't really make much of a difference: the code is incorrect and should be fixed.
This is how WG21 ended up here. Programmers who believe that it just "doesn't really make much of a difference". Except, it turns out that everybody else can tell the difference
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#159Earlier quoted context omitted.
Yeah... its shocking to me how difficult it is to read the C++ standard library. Surely, the standard library is written by the authors of the language. It should be a positive example of how they hope their language is used, right? Here's the source of C++'s vector class: https://gcc.gnu.org/onlinedocs/gcc-4.6.2/libstdc++/api/a0111... In comparison, vec in rust. (Note you need to scroll down a few pages to start see…
> 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 )
Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?
#160Earlier quoted context omitted.
Don't you think it just serves to highlight that Cpp2 is just C++? That it's explicitly not some new language with C++ FFI like Carbon.
Not sure what is meant by this statement. Both cpp2 and Carbon are different languages, neither of them claim to be just C++. Both languages will have bidirectional compatibility with C++ so that code written in C++ can be directly accessed from Carbon and code written in Carbon can be directly accessed from C++. Neither of them use an FFI for compatibility.
Whereas while Kotlin used the Java ecosystem to bootstrap itself, it is clear that by now JetBrains rather wants to build their own Kotlin ecosystem, just like C++ and Objective-C took their own path after being plain translators into C.