monterail / guidelines

[DEPRECATED] We are Ruby on Rails experts from Poland. Think hussars. Solid & winged. These are our guidelines.
71 stars 17 forks source link

Single vs double quotes #228

Closed jandudulski closed 9 years ago

jandudulski commented 9 years ago

http://anti-pattern.com/always-use-double-quoted-strings-in-ruby

WDYT?

MichalZalecki commented 9 years ago
  1. It's rather a style guide thing not an anti pattern.
  2. I think the question is for what? It's more readable? Ohh... is it? When I'm looking for sth in the code (probably not mine, that's why I'm "looking for") when I see single quotes, I now it's just string... and moving along to the next line. It's not a big deal, though.
  3. For consistency? We actually have consistency now. Single quotes -> raw strings, double quotes -> interpolated strings. And this is also true among different languages e.g. PHP. Fair enough consistency for me.
  4. There is a nasty lack of margin left on the ul element. UX anti-pattern (no bullets on mobile)... just saying.
teamon commented 9 years ago

Single quote should be for Char data type, (which does not exist in ruby but do in Elixir!) so I'm for double quotes in ruby everywhere :) On Tue 23 Jun 2015 at 21:30 Michał notifications@github.com wrote:

  1. It's rather a style guide thing not an anti pattern.
  2. I thing the question is for what? It's more readable? Ohh... does it? When I'm looking for sth in the code (probably not mine, that's why I'm "looking for") when I see single quotes, I now it's just string... and moving along to the next line. It's not a big deal, though.
  3. For consistency? We actually have consistency now. Single quotes -> raw strings, double quotes -> interpolated strings. And this is also true among different languages e.g. PHP.
  4. There is a nasty lack of margin left on the ul element. UX anti-pattern (no bullets on mobile)... just saying.

— Reply to this email directly or view it on GitHub https://github.com/monterail/guidelines/issues/228#issuecomment-114617569 .

teamon commented 9 years ago

@monterail/dev any other comments?

chytreg commented 9 years ago

I'm for using double quotes everywhere.

Ostrzy commented 9 years ago

:+1: for double quotes everywhere

jcieslar commented 9 years ago

Double quotes in ruby sounds good but I don't care about consistency in this case.

metrox commented 9 years ago

http://stackoverflow.com/questions/1836467/is-there-a-performance-gain-in-using-single-quotes-vs-double-quotes-in-ruby

Benchmarks show that we gain milliseconds while using single quotes which is obviously not worthwhile.

I use doubled quotes when I know that interpolation will be needed and single one in other situations, but I know that there are sometimes some optimalization fans and they prefer only singled quotes religion, and that's doesn't bother me. If they want to waste their time for going through the project and change every single one quote that's they call.

I don't think this is a big issue with single/double quotes and programmers should decide for themselves which side they are on. In my opinion, this shouldn't be normalized.

jandudulski commented 9 years ago

Optimization is not the issue - it's a myth in this case.

The issue is being consistent. To be honest - it is painful for my eyes when I see mixed style e.g. in Gemfile. But that's me.

metrox commented 9 years ago

I think that we should be consistent across the same files. For example as you said in Gemfile but it wouldn't bother me if I got one type in Gemfile and another in Rspecs.

Ostrzy commented 9 years ago

@metrox - But it's beter to have general guideline about that in the project, because then you don't have to check what is used in the file you are currently in.

hodak commented 9 years ago

I was resistant at first but after observing how I work with single quoted strings for a while I agree that just always using double quotes is better. It's useful not only for interpolation, but also when using apostrophes in sentences (e.g. in specs), changing single quotes to double is irritating.

Will create pull request as I think most agree.

hodak commented 9 years ago

Merged https://github.com/monterail/guidelines/pull/238