3 ms·
I'm not sure when single-quoted strings became the default (at least in Python/Ruby/similar languages), but it's almost entirely about fashion rather than funct
by caymanjim 7y ago
I'm not sure when single-quoted strings became the default (at least in Python/Ruby/similar languages), but it's almost entirely about fashion rather than functionality. Double-quoted strings were the norm for literally decades until recently. There is no strong argument for favoring one over the other. So long as everyone uses the same thing (at least within a given project, but ideally within an entire language's work), everything is fine. It's still hard for me to break the double-quote habit because single-quoted strings were unheard of in my entire career until about ten years ago.
- mixmastamyk 7y agoThey both mean the same thing in JS and Python. One is easier to type, easier to read, and used by the Python REPL. Single quotes FTW.
- vonseel 7y agoAnd you've got at least a few single-quotes in your comment through language use of contractions. In code, I prefer whichever style tends to produce the fewest escape-sequence situations. If the code contains hard-coded strings, that's usually double-quotes, though not always. Otherwise I guess it makes less sense to want to push +shift+ everytime you enter a quote on a Python dict key, for example, versus using the single quote.
- paulddraper 7y agoSingle quotes are slightly less noisy. "this", "that", "and", "the", "other" vs 'this', 'that', 'and', 'the', 'other' However, in Ruby, PHP, Groovy, and JavaScript single quotes have actual functional advantages, either through simpler syntax abilities, or by not requiring escaping double quotes for HTML/XML.
- prepend 7y agoI used double quotes for years, but appreciate being able to type more quickly with single quotes. It’s 90% convenience and 10% less clutter since single quotes are just smaller. It’s not a big deal to me as I don’t care too much (similar to tabs vs space). I have a preference but would likely spend zero time caring if my team were trying to decide and would never in a million years try to change someone else’s project.