Reputation:
Why do the most languages employ double quotes not single for String Literals?
As far as I know, the only language to employ single quotes is JavaScript where this manner works well.
Any historical reason ?
EDIT: Thank you all for various inputs. This really helps me out.
Upvotes: 5
Views: 381
Reputation: 221262
Not to be too obvious, but standard English punctuation uses double quotes for quoting and single quotes for interior quotes, so it makes sense that programming languages would default to double quotes.
Upvotes: 1
Reputation: 11515
because usually when you type text strings, you need the single quote more than the double quote like:
this way you have less escaping to do, and it's more readable.
also, i like the way JavaScript does this, it accepts both single and double quotes for strings.
Upvotes: 4
Reputation: 94131
In some languages double quotes represent strings, and single quotes represent characters. In other languages double quotes can interpolate variables while single quotes can't. JavaScript is not the only one that allows single quotes for strings, PHP does, and so does Ruby, and many others, but in JavaScript there's no difference at all of using one or the other.
Upvotes: 4