5 ms·
Std: Print is headed for C++23. std:cout is now a code smell
- _prototype_ 5y agoSomeone needs to write a book "C++ The Good Parts", similar to Douglas Crockford's "Javascript the good parts". C++ is insanely bloated and complex. If there is a book distilling the best and cleanest parts of the language, I might give it another look. Haven't considered it in earnest since College.
- astrange 5y agoIt seems rude to call something a code smell the instant (or… two years before the instant?) it gets replaced. Though it is C++, where you're apparently never supposed to use several of the features. Although, I mean, iostreams is pretty bad.
- BenFrantzDale 5y agoIt’s easy to pick on C++, but you can’t have backward compatibility and foreword progress and also not have features that are considered out-of-date.
- astrange 5y agoWell that's fine, but it would be nice to have more official guidance, like editions/profiles/versions that turn things off as well as on. There are some standards, but mostly you just get self-proclaimed C++ experts telling you you suck if you write a `new` statement and don't use whatever kind of smart pointer is the right one now.
- jdsully 5y agoThere already is such a thing and its called the C++ Core Guidelines: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
- colejohnson66 5y agoUsing shift operators for reading and writing to streams never made sense to me
- eklitzke 5y agoWhat operator would you have used?
- colejohnson66 5y agoNone. Just use a simple function call like almost every other language. Why is std::cout::write(myInt) such a hard thing to write that we decided std::cout << myInt was a better idea?
- trinovantes 5y agoIf I have to guess, it's probably to support operator overloading (printing custom data type) without requiring OOP e.g. must be a class that implements Writable
- fbkr 5y agoDisclaimer: I dislike iostreams and in our environment <iostream> is completely banned. However, in C++98, how else would you handle when you have an arbitrary number of things to print in a type-safe way? e.g. cout << myInt << ": " << something << " - " << otherthing << " - " << etc << '\n'; printf is not type-safe, nor supports user defined types. I'd rather not write 8 lines of functions calls for the same thing either. I think it made some sense C++98, though it is an awful API in 2021.
- google234123 5y agostd::cout::write(myInt,": ",something," - ",otherthing," - ",etc,'\n'); Possible with preprocessor.
- fbkr 5y ago
- deleted 5y ago[deleted]
- DethNinja 5y agoFinally, now they just need to add networking then C++ will have a “good enough” standard library.
- fivea 5y agoWhy do you feel it's a good idea to shove networking into the standard library? Doesn't your choice of network library depend on other tech decisions regarding things like sync/async IO? And moreover, if you want a java-like standard library that's good enough then you already have a bunch of options like Qt, Boost, POCO, etc.
- joe_guy 5y agoWouldn't you say the same thing about file io, or, just about everything? Networking is an extremely standard need, making the standard library a good place for it.
- lenkite 5y agoBecause every other PL has networking now. Because the lack of a networking framework fragments the C++ library ecosystem and prevents the development of re-useable and interoperable higher level libraries. The lack of such interoperable libraries make C++ a third-class citizen in the choice of language for middleware development.
- KptMarchewa 5y agoAgain, C++ solves problems it itself created.
- deleted 5y ago[deleted]
- nextaccountic 5y agoWhat are the issues with iostream?