Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@Tamrael single quotes for strings are my nightmares. Mainly because I started programming in C++ and C#. Single quotes are for characters (and thats how I use it in javascript and PHP as well)
-
@Codex404 Right? It seems so weird to use single quotes for something larger than a character.
-
Tamrael1855y@Codex404 I started that way but bad code with embedded variables (breaking all over the place, no escapes) has brought me to this dark place where I prefer the single quotes because at least the people get forced to think about where their strings end and variables begin.
-
Tamrael1855y@Codex404 some languages allow developers to include variables into double quoted strings. This has many downsides and can lead to many security issues. Readability suffers and things can get really messy.
With those languages it's better to stick to single quoted strings to force the dev to think about what they are doing and if the variable they put into the string are really safe to use there.
It's about how the code is structured in those languages and about better division of the concerns just like MVC patterns, having the string not containing some arbitrary untyped variable is a good idea.
If all languages would treat double quoted strings as string not to be interpreted at all but just used as strings there would be no case against it for me. In languages where string are really just strings I use the standard, whichever that language prefers.
Related Rants
Prettier formatter, AirBnB linter.
Prettier defaults to double quotes for strings. AirBnB loves it some single quotes. Would probably be able to change the configuration in order to maintain sanity *now*, but when I was a newbie dev, I was given a repo with AirBnB linting built in after being recommended Prettier.
It was not fun times.
rant
linter
at war
wk36
formatter