Hacker News new | past | comments | ask | show | jobs | submit login

The real-world choice is not (tabs) || (spaces), it's (tabs && spaces) || (spaces). Which is why spaces is the objectively superior choice.



In any project I've worked on that has used tabs for indentation, I've found no need to combine tabs and spaces. I've never been anywhere that enforces neurotic alignment standards, and if such guidelines aren't part of your workflow, I don't know why anyone would consciously inflict spaces upon themselves or their team. Some editors handle them like shit, and formatting fuckups always find their way in unless you're using an autoformatter.

The only arguments I hear for spaces are alignment (I don't have time to give a shit about such minor aesthetic preferences) and forcing other people to see code a certain way (I really don't understand why I would want to force my editing preferences on others). I don't think either one of them justifies the annoyance of spaces.


Huh? You say "[I wouldn't] force my editing preferences on others", yet you want to insist on inserting invisible whitespace characters into shared source code. That seems inconsistent to me.


That's a disingenuous misinterpretation of the comment. There's a clear difference between "I'd like code to be indented", which is widely agreed upon to be a good idea, and "you need to see my code indented with four characters because I hardcoded this into my source code", which is personal preference.


They are invisible whitespace characters that are handled reliably and flexibly in every editor that I've ever used them in. The same cannot be said for spaces. If a codebase is using two space indenting, I get to look at the resulting puke (this is subjective, of course) on my screen. I might be able to do some hackjob fix to change how they're displayed, but why should I have to? There's a character that satisfies both me and the animal that wanted to indent their code with 2 spaces.


You’re jumping to conclusions. Projects use both tabs and spaces because they have different purposes: tabs are for indentation, and spaces are for alignment. When you use spaces exclusively, you’re conflating the two and requiring tooling to be more complex to handle figuring out what you meant semantically from a lossy format. (Also, many people use who use tabs will do so exclusively and give up alignment, for simplicity’s sake.)


I'm not jumping to anything. Rather, I'm sharing my observations. I've been in the field for 20 years, and I stand by my point, which is that spaces will always find their way into a project. Projects that use tabs inevitably end up containing spaces too; not because of an intended specialized use case, but because of human nature.


Human nature being that people who prefer spaces will end up inserting them where they don't belong, and then have the gall to blame tabs for being confusing because they messed up the indentation :/


That's not true if your code style doesn't allow visually lining things up. Then tabs will only ever act as standard indentation, and so tabs vs spaces doesn't actually matter aside from enforcing line length.


Tabs allow each developer to choose his level of indentation. I think personal choice and flexibility to always be the objectively superior choice.


It depends on the exact formatting used. Many popular schemes only require tabs at the beginning of the line, and are not dependent on tab size.


Using hanging indents for line continuations solves this issue by making the choice of using tabs or spaces a non-issue.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: