Hacker News new | ask | show | jobs
by jahewson 3800 days ago
Ah, tabs are bad, because if you let people choose their own tab widths then it becomes impossible to align anything anymore. It makes it impossible to align anything which is != a tab width.

Tabs aren't "designed" for indenting text: they're a hangover from typewriters, where they were literally metal tabs used for creating tables. Tabs don't carry semantics - that's the job of the language's syntax. Tabs as a concept should be confined to history IMHO, especially their implementation in modern word processors, where they just give you ad-hoc semantic-less tables.

The tab key on the otherhand is great for indenting - in most sensible editors it will insert a configurable number of spaces. Perfect.

2 comments

This is so very wrong....

> tabs are bad, because if you let people choose their own tab widths then it becomes impossible to align anything anymore.

In what world is that true. If you indent your code with tabs, and I indent your code with tabs and I show my tabs as 4 chars wide and you show yours and 8 EVERYTHING IS STILL ALIGNED. It's just greater or lesser levels of indentation. You only have problems when you MIX tabs and spaces. Be consistent in your use and you won't have problems.

> It makes it impossible to align anything which is != a tab width.

Yes. So? Don't mix tabs and spaces.

> Tabs aren't "designed" for indenting text: they're a hangover from typewriters, where they were literally metal tabs used for creating tables.

What is a table? It's a tool FOR ALIGNING MULTIPLE COLUMNS OF TEXT... so yes, they ARE designed for indenting text.

For a more fully thought out argument on why it's a dick move to use spaces as pretend tabs: http://weblog.masukomi.org/2010/07/26/why-you-should-never-i...

There is an easy solution to the alignment problem: don't align stuff.

I haven't used column alignment in at least 20 years. I don't miss it at all, and I'll never go back to aligning things.

Column alignment causes far too many problems. Once you give it up, any advantage of spaces over tabs disappears. Code written without alignment reads the same whatever you use for indentation, and it is even perfectly readable in a proportional font!

I've written a few comments on HN about the problems with column alignment and the advantages of an alignment-free style. Here are a couple of previous discussions with specific examples:

https://news.ycombinator.com/item?id=10206860

https://news.ycombinator.com/item?id=9469713