News for hackers. Stuff that matters.
Re:Why stdout is faster than stderr? by weinzierl on Wednesday January 10, 2024 @02:58PM (#38942388)
Does it say somewhere why in Rust one is buffered and the other is not?
Re:Why stdout is faster than stderr? by loeg on Wednesday January 10, 2024 @03:27PM (#38942639)
Both (line-buffered stdout, raw stderr) date to the initial implementation 10 years ago: https://github.com/rust-lang/rust/commit/94d71f8836b3bfac337... . The commit message mentions that stderr is no longer buffered (probably as a result of the RFC 899 discussion, which I cannot seem to locate).
Re:Why stdout is faster than stderr? by weinzierl on Wednesday January 10, 2024 @07:34PM (#38945724)
Thanks for digging this up! It is good and interesting info, but unfortunately still doesn't satisfactorily answer why they are treated differently.
Re:Why stdout is faster than stderr? by loeg on Thursday January 11, 2024 @09:36AM (#38952701)
I did some more digging. By RFC 899, I believe Alex Crichton meant PR 899 in this repo:

https://github.com/rust-lang/rfcs/pull/899

Still, no real discussion of why unbuffered stderr.

Re:Why stdout is faster than stderr? by masklinn on Friday January 12, 2024 @08:36AM (#38967741)
Because stderr being conventionally used for error reporting it's important to immediately output that information to avoid losing it in case the program then crashes or ends without flushing.

Stdout is generally the "normal output" so loss of information on crash tends to be less relevant, and throughput more so as programs commonly send huge amounts of data to stdout.