About Me

Curriculum Vitae

A brief list of my current skill set

Bloggybits

Automatically Cropping Images is Hard
Monday, 21st October 2013, 19:00

But maybe we can use face detection?

The Git Cheat Sheet
Friday, 6th September 2013, 11:30

for github, bitbucket, that kinda stuff

CoffeeScript and TypeScript are a Burden
Saturday, 17th August 2013, 11:21

Be sure you understand the cons as well as the pros

Changing the Order of the jQuery Event Queue
Wednesday, 3rd July 2013, 20:27

It's just a push to the left

How Do Spammers Get My Email Address?
Wednesday, 15th May 2013, 18:03

I think these days I have a pretty good idea

XSLT, node.js 0.10 and a Fun Two Days of Native Modules and Memory Leaks
Thursday, 25th April 2013, 17:14

documentation makes things less cryptic, so lets not write much of it

Fixing CentOS high cpu usage when running as a virtual machine under VirtualBox
Sunday, 21st April 2013, 20:28

innotek rocks! I mean Sun... I mean Oracle...

Repairing a dK'Tronics Keyboard and Scoping Out a ZX Spectrum 48k - Part One
Sunday, 17th March 2013, 23:51

What signals inside of it actually look like

Tabs vs Spaces and Why You Should Always Use Tabs
Monday, 4th March 2013, 19:51

Spaces are bad, just real bad

Why you should ban Amazon's Cloud IPs
Thursday, 27th December 2012, 14:50

And how to do it in nginx, Merry Christmas Amazon

Building Better jQuery DOM Inserts
Thursday, 20th December 2012, 15:18

Break it down baby

SEO Companies - Don't Waste Your Money
Wednesday, 12th December 2012, 16:16

Spammers by any other name

Pulse Width Modulation and How 1-bit Music Works
Wednesday, 5th December 2012, 23:34

Beep beep multi-channel!

Making PDFs from HTML on your webapp in CentOS
Thursday, 29th November 2012, 14:00

Not as easy as it should be

Some Days I Wish For an Async String.replace
Monday, 19th November 2012, 12:59

MinnaHTML to the rescue!

Projects and Sillyness

MAME Cabinet Diary

How I built my own arcade cabinet

Loading Screen Simulator

I don't miss the ZX Spectrum, I still use it!

The Little Guy Chat Room

It's a Pitfall inspired chat room

GPMad MP3

A fully featured MP3 player what I wrote

GP Space Invaders

My first little emulator

GP32 Development Page

Some info and links about this cute little handheld

Disney Nasties

Uncensored images, you must be 18 to view them

Diary of a Hamster

Learn about how hamsters think, first hand

Utilities

Time Calculator

A simple little online utility for working out how many hours to bill a client

A Few Links

Tabs vs Spaces and Why You Should Always Use Tabs
Monday, 4th March 2013, 19:51

Wow, been ages since I've had the time to update my blog, and when I'm insanely busy the first thing to suffer is always my blog :( I feel really bad about that but the best solution to this is add another entry, so here we go, I'm going to wade in on a contentious topic, that old classic tabs vs spaces in coding.

So, it's probably best to start with my general opinions on formatting of code. I have preferences, I prefer lots of nice white space, but I'm not pigheaded enough to think that the way I choose to format things is better than anybody else's, it is just personal preference.

Because my background comes from C/C++, I tend to favour the sort of coding style that dates back to when we had editors which didn't know what syntax highlighting was and debuggers which showed your code next to the compiled assembly language, usually on text mode 80 column screens.

Probably the closest thing to my coding style is the standard that the MAME team demand. Which translates into Javascript (the language I code most in presently) like this:

if (var a = 0; a < 1; a++)
{
// do things
}

As opposed to what is almost the complete opposite more cramped:

if(var a=0;a<1;a++) {
// do things
}

I find the former easier to read and follow. But I accept that this is just me, and when I'm coding with other people's projects where possible I try and follow their style as best I can.

Tabs or Spaces?

Which leads us onto the thorny much disputed question of whether you should indent at whatever level you choose to indent to, using tabs or if you should use spaces. And the answer is simple, tabs! Always tabs!

The reason I'm going to give isn't that spaces consume less characters in files than spaces, whilst they do, this is source code that gets compiled or minified usually in some way or another, so who cares about that.

It's just one simple reason, and that is choice.

Usually when coding, you can use any editor you like, pick any font you like, even non-proportional ones if your editor supports it and you are a bit weird like that. You might not be able to decide how your code is generally formatted, but in this day and age with people coding on everything from a small screened laptop to a 1920 pixel wide monitor and beyond, being able to choose your tab stop width is a luxury we can all live with.

If you prefer two characters for your tabs, then fine you can do it. If like me you stick with four, you can do that too!

Unless the indenting is with spaces, that is. At that point you are removing choice for no benefit whatsoever. You wouldn't want to inflict your font choice and size on another coder, so why would you want to inflict your tab stop width?

All our brains work slightly differently, some people look at wide open white spaces and struggle to see the whole code picture, others look at tight code text and cannot deal with the bombardment of information their eyes take in.

So use tabs, there is really no reason not to, where as there is at least a few for not using spaces.

Comments

Add Your Own Comment