Nithin Bekal

Posts About Notes Slides

Single quotes or double quotes?

04 Feb 2014

The single quote has been under attack today. (In my team, at least). I saw this in the our team chatroom this morning:

Why do we need to follow the “always use single quotes, unless you need interpolation” rule in our coding conventions? Why not use double quotes everywhere?

What insolence! How dare anyone question a convention we have followed religiously for years months!

The community maintained Ruby style guide prefers the former, while the Github styleguide recommends the use of double quotes everywhere. Github’s convention does make sense. We need double quotes for interpolation anyway, so using them everywhere makes it consistent.

However, for me, a single quote says that the string doesn’t have any interpolation magic going on inside. When I see double quotes, I immediately scan the string for expressions that are being interpolated.

For now, I’ve managed to save the single quotes in our codebase. Frankly though, there is no “right” option here. As I’ve mentioned in a similar pointless rant on tabs vs spaces, pick whatever convention the team agrees on, and then follow it consistently.

So why did I spend half an hour in the chat room defending the single quote and then write a blog post about it, you ask? I’m wondering that myself.

Some Ruby style guides

Hi, I’m Nithin Bekal, a software craftsman with over 7 years of experience in shipping web applications. I mostly use Ruby, but lately have also been exploring Elixir. Co-founder of, and helping organize Rubyconf India. Tweet to me at @nithinbekal.