> At this point, it seems clear to me we’ve just poorly designed our function. It solely exists to clamp numbers, so why would we accept strings?
To me it sounds like you are using a poorly-designed language
To me it sounds like you are using a poorly-designed language
Not language specific. A C example that comes to mind is checking every non-nullable pointer parameter in every function for NULL and reporting an error instead of just letting the program crash. (Please, don't do that: just let contract violations produce crashes.)
The article's author describes a problem of experience and spirit, not a language wart.
The nullable pointer you’ve given is another great example of language wart. And one that’s often highlighted as a specific criticism against Go lang.
If your language requires you to manually track function contracts then that’s a problem with the language itself. Not the developer.
"
golem$ ed
?
help
?
?
?
quit
?
exit
?
bye
?
hello?
?
eat flaming death
?
^C
?
^C
?
^D
?
Note the consistent user interface and error reportage. Ed is generous enough to flag errors, yet prudent enough not to overwhelm the novice with verbosity."