Julia Evans on Nostr: did some buffering tests in 10 languages where I wrote the equivalent of this program ...
did some buffering tests in 10 languages where I wrote the equivalent of this program and then ran the program with `./program | grep hello`
```
while True:
print("hello")
sleep(1)
```
In 4 of the languages (Python, Ruby, C, Perl) nothing at at all gets printed (because they buffer the output)
in the others (Go, C++, JS, Rust, Java, Lua, bash) you see "hello" printed out once per second
code:
https://github.com/jvns/buffer-stdout-testsPublished at
2024-11-27 16:23:34Event JSON
{
"id": "49e0926b29cacf372d2ef7ff6dd83d1d74456f2d3d936b72d4f3f8623b33be71",
"pubkey": "26cad6f140bf86de9c26b7c15419cab1aebdd7086358d26aa2d750e21cf3bf2e",
"created_at": 1732724614,
"kind": 1,
"tags": [
[
"proxy",
"https://social.jvns.ca/users/b0rk/statuses/113555840341853716",
"activitypub"
]
],
"content": "did some buffering tests in 10 languages where I wrote the equivalent of this program and then ran the program with `./program | grep hello`\n\n```\nwhile True:\n print(\"hello\")\n sleep(1)\n```\n\nIn 4 of the languages (Python, Ruby, C, Perl) nothing at at all gets printed (because they buffer the output)\n\nin the others (Go, C++, JS, Rust, Java, Lua, bash) you see \"hello\" printed out once per second\n\ncode: https://github.com/jvns/buffer-stdout-tests",
"sig": "63eabbbc2e0599204fd276432d458d8f973f31c7df252195f1e79ecb1b0b14f7e82cd028b697347f451f41d64bb97b2d09ac08717e695d15b65a1af00f8878ab"
}