5 ms·
Could you please elaborate? Why is true a better value than yes? Seems like an arbitrary choice to me. Does one choice have some advantages over the other?
by distcs 4y ago
Could you please elaborate? Why is true a better value than yes? Seems like an arbitrary choice to me. Does one choice have some advantages over the other?
- stocknoob 4y agoWhat fraction of existing code uses languages with true/false vs yes/no? I’d imagine it should be “least surprising” for most users.
- RadiozRadioz 4y agoTrue/false is more widely used than yes/no in this context. The fact that the author felt the need to explain that yes/no maps to true/false indicates that they also believe this to be the case. The only time I can remember seeing yes/no used in a format like this is YAML, and that caused problems[1]. [1]: https://hitchdev.com/strictyaml/why/implicit-typing-removed/ https://hitchdev.com/strictyaml/why/implicit-typing-removed/
- yellowapple 4y agoThe Norway problem came to mind for me, too, but I don't think there's much opportunity for that to arise here given that strings are quoted. Meanwhile, there's plenty of other precedent for yes/no instead of true/false; shell scripts come to mind. I don't know if I prefer this over treating everything as a string and letting readers/writers decide on their own how to parse things, but it seems like a much more reasonable approach than YAML's.
- RadiozRadioz 4y agoYes, I agree, the format described here is more reasonable than YAML and would not suffer from the Norway problem. I'm interested in what you mean when you mention shell scripts; I find it more idiomatic to write: if [ true ]; then echo test; fi Over if [ yes ]; then echo test; fi Because the behavior is more consistent when you try to use it in other constructs: while true; do echo test; done Versus yes | while read _; do echo test; done Or maybe while yes | :; do echo test; done There's also no "no" command. To get that effect, you'd have to confusingly write: yes no Is there a particular instance of yes/no in shell scripting that you had in mind?
- yellowapple 4y ago> Is there a particular instance of yes/no in shell scripting that you had in mind? Yes! I see them all the time in various build scripts, especially for Slackware packages / SlackBuild scripts; it's a pretty common convention to use yes/no values for enabling/disabling (respectively) various build options. OpenBSD's rc.conf(.local) also uses "NO" to indicate that a service/daemon should be disabled entirely; for example, the default httpd_flags=NO in rc.conf entirely disables httpd - unless, of course, you re-enable it later with httpd_flags= in rc.conf.local. "YES" is also sometimes used, e.g. library randomization being enabled by default via library_aslr=YES.
- coffeeblack 4y agoBecause even the author uses true to describe what he means by yes.
- stillkicking 4y agoThis is why you should never finalize specs until you've written the documentation for it. If it sounds stupid when you say it out loud, it _is_ stupid.
- scatters 4y agoWell, "false" can't get confused with the ISO code for Norway.
- anamexis 4y agoTo be fair, it can't here, because all strings are delimited.
- Someone 4y agoI would say “yes” and “no” are locale specific. Why not German “ja” and “nein”, French “oui” and “non” (with the advantage of being of the same, short, length), etc? Yes, “true” and “false” are English words, but in programming circles, IMO transcend locale. (The more locale agnostic ⊤ and ⊥ (https://en.wikipedia.org/wiki/Verum https://en.wikipedia.org/wiki/Verum and https://en.wikipedia.org/wiki/Up_tack https://en.wikipedia.org/wiki/Up_tack), IMO are a bit elitist and difficult to type)
- _kst_ 4y agoUXF has plenty of English-specific keywords. I agree that "true" and "false" would be clearer than "yes" and "no", but the fact that "yes" and "no" are English words isn't an issue.