Is it poor practice to not use spaces between parameters in a scripting language (or any for that matter)?

With spaces:

def does_a_thing(x, y):

does_a_thing(5, 9)

Without spaces:

def does_b_thing(x,y):


I have seen it done both ways and personally prefer using spaces as it shows more readable.

Are there situations where either style should be preferred?

  • Readability is always preferred. the compiler or interpreter couldn't care less. – Simon B Nov 11 '16 at 23:18
  • I like lots of white space as it improves readability for me. Of course, I compress script for distribution, e.g. use Google's closure compiler. – Erik Eidt Nov 11 '16 at 23:26
  • 1
    I didn't know we have a tag for whitespace! – Erik Eidt Nov 11 '16 at 23:27
  • I prefer as much whitespace as possible. I normally measure whitespace in gigabytes. – user22815 Nov 12 '16 at 3:45
  • How do you use whitespace in plain written text? You, use, whitespace, after, comas, and, after, a, fullstop. Do that in your code. – gnasher729 Nov 13 '16 at 6:47

Are there situations where either style should be preferred?

Yes. If the rest of the code base uses spaces then use spaces. If the rest of the code base doesn't use spaces then don't use spaces. It's called consistency.

Trivial things like this matter. Not because one is so much better than the other. But because watching style change from one to the other is distracting and I have better things to be thinking about than this.



  1. What is used by your team? Keep your style consistent with your colleagues.

  2. If there is no team (for instance the project haven't started yet), then use the style commonly used in your company.

  3. If there is no previous usage (for instance your company never used a specific programming language), then use the official style for a giving language. Languages such as C# or Python do have an official style.

  4. If there are no official style, as it is a case in JavaScript, use either a convention published by a well-known company, or a style which appears to be popular when looking at open source projects.

In all cases:

  • Don't reinvent the wheel: don't invent your own style, because (1) it requires an excellent knowledge of the language, (2) is difficult to do well, (3) won't be known by other developers and (4) is subject to criticism from your peers.

  • Enforce the style automatically. The best choice is to make your IDE behave in a way that developers would not have to think about style in the first place. When impossible, at least check the style automatically through the pre-commit hook.

  • Remember that the existence of style rules matter much more than which rules are used. In other words, what is important is consistency, not that you put braces on a new line or the same line or that you use tabs or spaces.

Not the answer you're looking for? Browse other questions tagged or ask your own question.