Re:Front End Development Guidelines
by fuzionmonkey on Thursday May 05, 2011 @08:46PM
(#2519564)
I think the idea is that if you use single quotes for strings, you don't have to escape the double quotes that are often found in html. '<p id="foo">something</p>'
But the same goes for something like "you can't do that"
I guess it just depends what you don't want to escape. For Google, the more probable scenario was probably the former.
The former isn't a very good reason: HTML/XML accept both double and single quotes, so "<p id='foo'>something</p>" would work equally well.
Re:Front End Development Guidelines
by joshontheweb on Friday May 06, 2011 @12:49PM
(#2521533)
yes, but it is much more common for double quotes to be used in html
Single quotes are not 'C-style strings'. The article is wrong on strings in C. In C, strings and characters are different things (well actually, strings don't even really exist - they are pointers to the beginning of a char-array). So you can say char a1 = 'a'; and char* a2 = "a"; and they're very different things; for one, a2 has a terminating zero. (meaning: the first influences only the contents of a single byte, the second one two, leaving aside alignment).
In C: single quote = character, double-quote = easy initialization of array of characters terminated with \0.
(the above contains many simplifications, of course)
I'm yet to see a compelling argument for either. My original paragraph for string creation forgave C style strings, as they do seem very clean cut and easy to identify. I think this is an area that needs some debate.