News for hackers. Stuff that matters.
Re:Std: Print is headed for C++23. std:cout is now a code smell by _prototype_ on Monday November 29, 2021 @09:11PM (#29387987)
Someone 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.

Re:Std: Print is headed for C++23. std:cout is now a code smell by astrange on Monday November 29, 2021 @09:28PM (#29388159)
It 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.

Re:Std: Print is headed for C++23. std:cout is now a code smell by BenFrantzDale on Monday November 29, 2021 @09:43PM (#29388298)
It’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.
Re:Std: Print is headed for C++23. std:cout is now a code smell by astrange on Monday November 29, 2021 @10:08PM (#29388474)
Well 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.
Re:Std: Print is headed for C++23. std:cout is now a code smell by jdsully on Monday November 29, 2021 @10:30PM (#29388628)
There already is such a thing and its called the C++ Core Guidelines: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
Re:Std: Print is headed for C++23. std:cout is now a code smell by colejohnson66 on Monday November 29, 2021 @07:13PM (#29387134)
Using shift operators for reading and writing to streams never made sense to me
Re:Std: Print is headed for C++23. std:cout is now a code smell by eklitzke on Monday November 29, 2021 @07:17PM (#29387161)
What operator would you have used?
Re:Std: Print is headed for C++23. std:cout is now a code smell by colejohnson66 on Monday November 29, 2021 @07:21PM (#29387191)
None. 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?
Re:Std: Print is headed for C++23. std:cout is now a code smell by fbkr on Monday November 29, 2021 @08:24PM (#29387643)
Disclaimer: 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.

Re:Std: Print is headed for C++23. std:cout is now a code smell by google234123 on Monday November 29, 2021 @10:22PM (#29388561)
std::cout::write(myInt,": ",something," - ",otherthing," - ",etc,'\n');

Possible with preprocessor.

Re:Std: Print is headed for C++23. std:cout is now a code smell by slavik81 on Tuesday November 30, 2021 @01:34AM (#29389558)
I'm not sure how that could be done before variadic templates were introduced in C++11.
Re:Std: Print is headed for C++23. std:cout is now a code smell by fbkr on Tuesday November 30, 2021 @01:48AM (#29389629)
I doubt that's possible with the C++98 preprocessor.
Re:Std: Print is headed for C++23. std:cout is now a code smell by kayamon on Wednesday December 01, 2021 @01:29AM (#29401273)
> 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.

If I were the one designing the language, I'd have simply fixed printf to be type-safe. (e.g. via adding macro support a la Lisp)

Re:Std: Print is headed for C++23. std:cout is now a code smell by trinovantes on Monday November 29, 2021 @07:46PM (#29387397)
If 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
Re:Std: Print is headed for C++23. std:cout is now a code smell by fivea on Monday November 29, 2021 @08:20PM (#29387613)
> What operator would you have used?

Qt does it right: fluent-style interface which does string interpolation.

Re:Std: Print is headed for C++23. std:cout is now a code smell by astrange on Monday November 29, 2021 @09:29PM (#29388165)
Is that localizable, or does it compile the interpolated string into code so it can't be replaced?
Re:Std: Print is headed for C++23. std:cout is now a code smell by slavik81 on Tuesday November 30, 2021 @01:31AM (#29389546)
Qt has a pretty extensive localization framework. You would probably want to wrap both strings in tr(). https://doc.qt.io/qt-5/i18n-source-translation.html
Re:Std: Print is headed for C++23. std:cout is now a code smell by KptMarchewa on Monday November 29, 2021 @08:22PM (#29387626)
Again, C++ solves problems it itself created.
Re:Std: Print is headed for C++23. std:cout is now a code smell by DethNinja on Monday November 29, 2021 @07:27PM (#29387230)
Finally, now they just need to add networking then C++ will have a “good enough” standard library.
Re:Std: Print is headed for C++23. std:cout is now a code smell by fivea on Monday November 29, 2021 @08:24PM (#29387641)
Why 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.

Re:Std: Print is headed for C++23. std:cout is now a code smell by lenkite on Monday November 29, 2021 @10:34PM (#29388656)
Because 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.
Re:Std: Print is headed for C++23. std:cout is now a code smell by joe_guy on Monday November 29, 2021 @09:13PM (#29388015)
Wouldn'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.

Re:Std: Print is headed for C++23. std:cout is now a code smell by nextaccountic on Thursday December 02, 2021 @05:18AM (#29414439)
What are the issues with iostream?