💾 Archived View for gem.pwarren.id.au › gemlog › 2022-03-11.gmi captured on 2024-05-12 at 14:52:17. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-07-16)
-=-=-=-=-=-=-
https://blog.sunfishcode.online/bugs-in-hello-world/
That article purports that it's a program bug when the 'hello world' C program writes to a full filesystem and doesn't correctly identify that it was not able to output correctly and emit appropriate error codes.
I would contend that this is a failure of the program specification.
The "Hello World" specification, is generally considered to be
* Print the string "Hello World" to the console.
Now in the linux world, that assumes that you can always write to the 'stdout' file descriptor, and for a console, that holds true and the usual:
#include <stdio.h> #include <stdlib.h> int main(void) { puts("Hello World!"); return EXIT_SUCCESS; }
Does that just fine!
However, if you _can't_ write to the stdout file descriptor, the program will not know about it.
However, if we specify the program to:
* Emit the string "Hello world" to the console
* Include handling for when the console output is redirected to non-consoles (files, FIFOs, devices etc)
That would cover articles issues.
(I think, as an amateur programmer who hasn't written serious code in around 10 years)