Skip to content

Instantly share code, notes, and snippets.

@thlorenz
Last active December 19, 2015 16:59
Show Gist options
  • Save thlorenz/5988049 to your computer and use it in GitHub Desktop.
Save thlorenz/5988049 to your computer and use it in GitHub Desktop.
Tabular vs. White Space removed

Trying to get people's opinions on what they consider more readable, not focusing on comma first or not, but on the fact that the original is tabular and the beautified one removed the whitespace and therefore is not.

Please vote +1 for either original or beautified.

var path = require('path'),
fs = require('fs'),
leveldb = require('valuepack-core/mine/leveldb'),
github = require('valuepack-core/mine/namespaces').github,
sublevel = require('level-sublevel'),
dump = require('level-dump'),
store = require('../lib/store-github-repos'),
existsSync = fs.existsSync || path.existsSync
var path = require('path')
, fs = require('fs')
, leveldb = require('valuepack-core/mine/leveldb')
, github = require('valuepack-core/mine/namespaces').github
, sublevel = require('level-sublevel')
, dump = require('level-dump')
, store = require('../lib/store-github-repos')
, existsSync = fs.existsSync || path.existsSync
@chrisdickinson
Copy link

+1 original

@toddself
Copy link

+1 original.

But if you're only going to do one var statement, I'd prefer 4 space indents, otherwise each line should have a var. (The python dev in me wants four spaces always, and var at the beginning of each line, but I digress)

var path = require('path'),
    fs = require('fs'),
    leveldb = require('leveldb');

or

var path = require('path');
var fs = require('fs');
var leveldb = require('leveldb');

Mostly because this is the predominant way that variable assignment and layout is taught (i've never seen a text with the equal spacing), and if you don't have a nifty plugin for your editor, it's a bunch of extra work to do the spacing (plus it requires a plugin).

@thlorenz
Copy link
Author

@toddself So you'd prefer the tabular version (the original) with var on each line like below?

var path    = require('path');
var fs      = require('fs');
var leveldb = require('leveldb');

@toddself
Copy link

@thlorenz without the equal spacing, yes.

PEP8 says the equal spacing is incorrect and the zen of python says explicit is always better than implicit, ergo, the var declaration on each variable would explicitly explain that those variables are all local to the current scope.

However, I do understand I'm not programming Python and feel a single var would suffice due to it's prevelance in the community, but then I'd prefer the commas at the end of the line, mostly due to it's familiarity in English punctuation rules (typesetting and formatting rules prohibit the punctuation from beginning a line. My dad is a typesetter...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment