Tabs vs Spaces, Google Entry Number 1,034,123

18 Jan 2018

I’ll start by saying I’m on Team Tab. It’s a no brainer, the tab can be set to the user’s preference. Do I want to set my tab width to two spaces, go for it. We setting it Python style to four, be my guest. By using tab, we allow each programmer not only to have readable code, but readable code in the sense that they are comfortable with. No one needs to compromise, we all have the perfect length of tab space.

The reason why I think tab is better than space has to do with readability. Readability is what seperates a 5 minute debug session from a 5 hour bug debug session. In my last semester, I took a Scripting class where I had to implement scripts using Javascript, and I made many errors where I didn’t indent properly, close my functions the best, etc. It led to this mess of a code, that when I only had four minutes left, and Murphy’s law takes over, guess what, my code isn’t running. I was missing a semi colon somewhere, but for the life of me I couldn’t find it. Ok found it, but now a new error is popping up, variable “xyz” is not defined. Ok, so I need to declare the variable as a global variable, but where is it in the first place. If I made my code readable from the start, that problem most likely would not have existed. And that is what readability is about.

Someone once said somewhere on some blog post, “Write your code for other people”. Write out the comments, make your variables have usable names, etc etc. I took that comment, and from personal experience came up with a new quote. “Write your code for your future self who needs to understand what your present self was trying to say”. I’m sure there is a more concise version out there, but that really struck with me when I had to go back to past projects and try to figure out just what I was thinking. Maybe if instead of naming my variables i, j, k, and l, and named them “instanceLoop”, “numOfIntegers”, and “returnInteger” instead, I might have actually understood what I was trying to get at.

Coding Standards are important because they enforce some set of rules, that we all can follow by. Theres a video online, where they show how to cross the street in some city in Asia. It’s a mess, there are no lanes on the road, theres at least 30 mopeds just zipping left and right. The consensus was, you just need to walk peacefully in a straight line, and the upcoming cars would swerve to avoid you. That situation is not having coding standards. Sure, you definetly will code faster if you didn’t have to mut a comment explaning every function, or naming your variables letters. I’m sure you’ll finish way faster if you can make a three line return statement into a concise one line version. You may finish that code five minutes faster. But think of the poor chump who needs to fix your broken code a few days later, think of the amount of time he needs to read that code. It’ll be a lot longer than the five minutes you saved, and you never know, you just might be that poor chump one day.