Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
nitnip18153yYou SHOULD be consistent. Nothing else matters. Stick to one.
Tabs are for indentation. You can control how tabs look (how many spaces are used to represent them in your editor), while also counting as a single character, making them a better choice in my eyes.
Spaces are better when it comes to presentation. (Imagine declaring an object in javascript, but you want every key-value pair to look like a table, with each value starting at the same column in your editor). -
Tabs can cause weird readability issues when collaborating on code. The style guide might dictate a single tab but the layout of the code might look fine with a tabstop of 2 spaces but really weird with a tabstop of 8 or vice versa. A code style that defines the indentation size is more consistent
-
sariel85873yUsing tabs for indentation is the equivalent to training wheels for programming.
Change my mind. -
kamen69803yWho told you you SHOULD?
IMO spaces are spaces and indentation is indentation. For me tabs are the way to go since they don't impose anything on the appearance, i.e. you have one level of indentation and you can make it appear 1, 2, 3, 4, 5 or even 8 spaces wide if you're so inclined - and that's without ever changing the code. Good luck doing that with spaces. -
sariel85873y@kamen my IDE allows for that...
Most do these days. It's easy to figure out what's an indent and what's not with regex. -
asgs115673yYou mean you were asked to use spaces?
You can use either, though I would prefer tabs anyday. What matters is the consistency within a class/file/project -
Hazarth93863yYou should use tabs for indents and a IDE that can convert between the two automatically so you can set up a consistent style
-
kamen69803y@sariel You mean you can present leading spaces differently without changing them in the file? If it's that, it's new to me and kinda cool, but I can see it leading to some problems.
-
no you shouldn't. and you should slap everybody who says you should.
tabs are the one true god of indentation.
I just found out that I should be using 4 spaces and not a tab for indentation, MY WHOLE LIFE IS A LIE.
rant