Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why use double quotes for strings #5811

Closed
squarepants opened this issue Nov 27, 2015 · 4 comments

Comments

@squarepants
Copy link

commented Nov 27, 2015

I have read this wiki 《Coding guidelines》, it says we should use double quotes for strings and I have no problems with that.

But I can't stop wondering that what are the reasons behind this?

@DanielRosenwasser

This comment has been minimized.

Copy link
Member

commented Nov 27, 2015

Hi there @squarepants, from the top paragraph:

While these guidelines are mainly meant for contributors to the TypeScript project, certain suggestions apply as to how idiomatic TypeScript code should be written (e.g. the "Names" and "Style" sections).

@DanielRosenwasser

This comment has been minimized.

Copy link
Member

commented Nov 27, 2015

But to specifically answer your question, we occasionally work in languages other than TypeScript. All those languages either require double quotes for strings (e.g. C#, C++, F#) or at least allow double quotes for strings (e.g. Python, Ruby). It's easier not to ask people to shift their muscle memory when switching back and forth between languages.

One of the most common head-scratching problems with JSON is "why can't my JSON file be parsed?" and an hour later you'll find out single-quoted strings aren't part of the JSON standard.

So double quotes have the least cognitive burden for us on the team. Hope that answers your question!

@zpdDG4gta8XKpMCd

This comment has been minimized.

Copy link

commented Nov 27, 2015

we decided to ban single quotes after a day of full text searching for
"width" in code and not being able to find it because it was written 'width'

On Fri, Nov 27, 2015 at 1:44 PM, Daniel Rosenwasser <
notifications@github.com> wrote:

But to specifically answer your question, we occasionally work in
languages other than TypeScript. All those languages either require
double quotes for strings (e.g. C#, C++, F#) or at least allow double
quotes for strings (e.g. Python, Ruby). It's easier not to ask people to
shift their muscle memory when switching back and forth between languages.

One of the most common head-scratching problems with JSON is "why can't my
JSON file be parsed?" and an hour later you'll find out single-quoted
strings aren't part of the JSON standard.

So double quotes have the least cognitive burden for us on the team. Hope
that answers your question!


Reply to this email directly or view it on GitHub
#5811 (comment)
.

Aleksey Bykov

@squarepants

This comment has been minimized.

Copy link
Author

commented Nov 30, 2015

Thank you @DanielRosenwasser , I take your point completely.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.