DEV Community

Cover image for Tabs vs Spaces
Adrian Mejias
Adrian Mejias

Posted on

Tabs vs Spaces

Tabs.

Discussion (5)

Collapse
jorgecc profile image
Jorge Castro

I prefer TAB because it exists and it does the job. However, some frameworks and specifications discourage the use of it.

It's not my fault that some people don't use a proper and modern tool.

However, if the project is open source, then I stick the standard: 4-spaces. Also, sometimes I prefer 2 spaces. Why?

Behold a pyramid code:

code { 
    morecode {
        extracode {
             additional {
                   again  {
                   }
             }
        }
    }
}

And if the pyramid reaches to 80 characters per line, then the standard forces to break in more lines, i.e. we have a messy code.

Collapse
adrianmejias profile image
Adrian Mejias Author

i set the config to 2-4 spaces as well. :)

Collapse
buphmin profile image
buphmin

I don't care xD. Really as long as it is consistent across the code base per language. At my work we use 4 spaces officially, but there is some old code that is all over.

For most languages I prefer the look of 4 spaces with the exception of js/ts I like the look of 2 since js has a lot of nesting. By look I mean the typical width of 4 spaces, I don't care whether it is a tab or a space, as long as pushing the tab button works.

Collapse
ghost profile image
Ghost

spaces, you can't mistake a space for a tab but you can't know if a tab are spaces. To me there should be just 1 kind of non visible character and unless you like this spaces it is. To me having tabs is like having 2 kinds of A that look the same but are different. And talking about proper modern tools, every editor under the sun can make 2 or 4 spaces with the tab key. Finally, tabs change the cursor speed when moving or deleting which is annoying.

Collapse
khrome83 profile image
Zane Milakovic

I was tabs, then tab rendered as 4 spaces, then tab rendered as 2 spaces.

As I get older I want it to be smaller.

But to be honest, I develop in the conventions of the language I am working with.