Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Retvals, terrible teaching, and admitting we have a problem (rachelbythebay.com)
12 points by chmaynard on Dec 7, 2020 | hide | past | favorite | 2 comments


I generally agree; you can't rely on the average programmer to actively avoid mistakes. Instead you have to make it more difficult to make those mistakes. On the other hand, while I wouldn't say any language is perfect (let alone any that are suited to every possible task), I can think of a few that are better than C.


C tends towards using in-band error signaling, which is indeed likely to lead to the kill(-1) problem discussed in the article.

... that said, there are other ways to get error handling wrong, and e.g. some (scripting) languages tend to have very succinct specifications of functions, which often leaves out important details and/or error handling. Contrast Python's https://docs.python.org/3/library/os.html#os.fork with OpenBSD's https://man.openbsd.org/fork.2 (or POSIX' https://pubs.opengroup.org/onlinepubs/9699919799/functions/f...). Python's solution works reasonably well here - there's not that much you can do to handle fork() failing - but os.fork() isn't exactly the worst-documented part of the Python standard library either...




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

Search: