[TW5] Why are double quotes preferred over single quotes for string literals?

80 views
Skip to first unread message

andrew harrison

unread,
Jun 25, 2016, 2:04:15 PM6/25/16
to tiddly...@googlegroups.com
Why are double quotes preferred over single quotes for string literals? It means that every time there is a double quote character it takes up twice the space in the core or in plugins because it has to be escaped. Single quotes don't have to be escaped so why not use those whenever possible? I'm just asking because I'm finding it reduces size, increases speed and the only exception I can find to using single over double is triple.

PMario

unread,
Jun 26, 2016, 2:05:30 PM6/26/16
to TiddlyWikiDev
On Saturday, June 25, 2016 at 8:04:15 PM UTC+2, Andrew wrote:
Why are double quotes preferred over single quotes for string literals?

It's just a convention, which is probably active since TWclassic, and discussing it may cause a "religious war" ;)
 
It means that every time there is a double quote character it takes up twice the space in the core or in plugins because it has to be escaped.

It's exactly the same problem and argument with 'I don\'t want to escape double quotes'. If I do understand your argument right.
 
Single quotes don't have to be escaped so why not use those whenever possible?
I'm just asking because I'm finding it reduces size, increases speed and the only exception I can find to using single over double is triple.

I don't understand this statement. ... I think nobody (except the browser programmers) really know, what browsers do with our strings. So trying to optimize speed and memory usage with using ' over " is wasting time.

just some thoughts
-mario


infurnoape

unread,
Jun 27, 2016, 9:00:51 PM6/27/16
to tiddly...@googlegroups.com
Ok, I am now seeing the rediculousness of my question. It would require way to much work to replace double with single and for what reason and is a waste of time. Not a good idea to mess with a work of art. Thank you for your valuable guidance.



Happy Connecting. Sent from my Sprint Samsung Galaxy S® 5
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/78bf1db3-20bb-4073-b562-6da83c3b8602%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeremy Ruston

unread,
Jul 1, 2016, 5:22:08 AM7/1/16
to tiddly...@googlegroups.com
Hi Andrew

Why are double quotes preferred over single quotes for string literals? It means that every time there is a double quote character it takes up twice the space in the core or in plugins because it has to be escaped. Single quotes don't have to be escaped so why not use those whenever possible? I'm just asking because I'm finding it reduces size, increases speed and the only exception I can find to using single over double is triple.

Just to answer the “why”: I’ve always defaulted to using double quotes for string literals in code because I find that single quotes appear in literal strings much more often than double quotes (mainly because of the way we re-use the single quote as an apostrophe).

Best wishes

Jeremy



Reply all
Reply to author
Forward
0 new messages