Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Continuation passing monads form the basis of a perfectly valid and usable software architecture and programming pattern.

In the case of ostream and operator<<, this pattern reduces the number of intermediate objects that would otherwise be constructed.

If you object to iostream on religious or stylistic grounds, there's always fmt which is more like Go or Python string interpolation.[0]

0. https://fmt.dev



> If you object to iostream on religious or stylistic grounds,

No I object to it on usability grounds. It took more than 30 years for the committee to admit it but C++ now has typesafe std::print/std::format finally, after admonishing programmers for using `printf` in C.


C++ only acquired the capabilities to have a statically type safe format string only recently.

Iostreams have a lot of issues, but overloading<< is a very minor one.


But it is achievable without operator overloading, isn't it? There is also a reason why format strings seem to be more popular among the crowd.


Streams have numerous design problems (e.g. representation is managed by the stream, not the thing you’re printing) making the shift operator syntax the least of the problems.


Which part of operator<< involves continuations, let alone continuation passing monads?




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: