7 ms·
> "Strings may be single quoted." What's the point? I cringe every time a project uses both double quote and single quote, a mix of semicolon and no semicolon
by mickael-kerjean 5y ago
> "Strings may be single quoted."
What's the point? I cringe every time a project uses both double quote and single quote, a mix of semicolon and no semicolon and a mix of tabs and space, ....
Which one to pick isn't relevant as soon as the code base is consistent
- jeppester 5y agoMaybe they don't think it should be up to them to decide which one you should go with.
- selcuka 5y agoWhat's the point of standards then?
- dane-pgp 5y agoTo support people's use cases?
- xboxnolifes 5y agoThe standard says you can use either. Why do you disagree with the standard?
- deleted 5y ago[deleted]
- selcuka 5y agoI disagree with the OP, not the standard. The standard says you can't use backticks for quoting strings, so it's still "up to them to decide which one you should go with".
- itsibitzi 5y agoIt allows you to put double quotes in the string without escaping them, which is pretty nice.
- amelius 5y agoWhat if you want both? E.g., how would you put the following sentence in a string: You can use both " and ' to delimit a string.
- kangalioo 5y agoYou'd use escapes: "You can use both \" and ' to delimit a string"
- weird-eye-issue 5y agoThat was their point, you inevitably have to escape one or the other, so just pick one
- samhw 5y agoMy only disagreement is that you imply that this is no better than plain old JSON – I think it's positively _worse_. It makes it difficult to remember which of the two quote marks to escape, without checking the beginning of the string to see what quote marks were there (and this difficulty exists not only for humans but for machines, which introduces more complexity in parsers). The benefit of JSON is that it's simple, opinionated, and pretty. Putting bells and whistles on it ruins the very ethos of JSON. If you want JSON++, use XML or Jsonnet or whatever.
- weird-eye-issue 5y agoI didn't imply that, in fact my comment agrees with what you are saying. Did you reply to the wrong person?
- samhw 5y agoHaha, I only meant that as a "I agree with you, but I'd go even further" preface. In hindsight, this being HN, I should have been more precise!
- deleted 5y ago[deleted]
- incrudible 5y agoGetting over your pet peeves is a superpower.
- IshKebab 5y agoYeah exactly. That's why they should have stuck with just double quotes. Double quotes are far more popular than single quotes anyway.
- DonHopkins 5y agoHow about sticking with JavaScript, as long as that's what the J and the S in JSON stand for. And as we all know, JavaScript supports both single and double quotes. Or they could pull a YAML, and retroactively redefine what JSON stands for, the way YAML originally stood for "Yet Another Markup Language" until some party pooper pointed out to their great surprise that YAML was not actually a document markup language, but a data serialization language, so they redefined it to mean "YAML Ain't Markup Language" -- the opposite of what it originally meant. https://en.wikipedia.org/wiki/YAML#History_and_name https://en.wikipedia.org/wiki/YAML#History_and_name https://en.wikipedia.org/wiki/Markup_language https://en.wikipedia.org/wiki/Markup_language Pro Tip: When naming you file format, look up what the words in your acronym mean, first.
- smt88 5y ago> What's the point? Some code bases use single quotes, and it's annoying to copy/paste an object from that code into a JSON objdct and have to change the quotes.