news.volyx.in

Bugs in Hello World (blog.sunfishcode.online)

527 points by sizediterable · 1651 days ago · 252 comments on HN

Article summary

The article discusses how even simple 'Hello World' programs can have bugs, specifically when it comes to handling I/O errors. It highlights an example in C where the program does not properly handle the case when standard output is redirected to a device that is out of space, such as Linux's /dev/full. This bug can lead to silent data loss and incorrect exit status. The article also compares the behavior of different programming languages in this scenario.

Main themes

  • I/O error handling
  • programming language design
  • error handling strategies
  • language age and reliability
  • systems programming
  • rapid development trade-offs
  • testing for edge cases
  • programmer awareness and responsibility

What commenters say

  • Some argue that modern languages are less exhausting to use for writing correct code because they catch more programmer errors, but others counter that this is not necessarily true for all modern languages.
  • The importance of understanding the language and its potential pitfalls is emphasized, as even simple programs can have unexpected behavior in edge cases.
  • There is disagreement on whether the age of a language is a determining factor in its ability to handle errors, with some pointing out that older languages may have gotten it right while newer ones may not.
  • Some commenters note that in certain contexts, such as systems programming, the ability to handle errors and edge cases is crucial, while in other contexts, such as rapid development, it may be less of a concern.
  • It is suggested that even in languages that provide some level of error handling, it is still important for programmers to be aware of potential issues and take steps to mitigate them.
  • The example of /dev/full is seen as a useful tool for testing how programs handle I/O errors, but it is noted that not all operating systems have this feature.
  • There is a discussion on how to properly handle errors in programs, including whether to check return values, use exceptions, or ignore certain types of errors.
  • Some argue that in many cases, ignoring certain types of errors, such as print failures, can be the 'right' thing to do, while others argue that this can lead to byzantine failures rather than resilience.