git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: On Tabs and Spaces

From
CWChrister Weinigel <christer@weinigel.se>
Date
Oct 16, 2007, 23:51 UTC
Message-ID
<20071017015109.303760cc@localhost.localdomain>
In-Reply-To
<alpine.LFD.0.999.0710161559150.6887@woody.linux-foundation.org>

On Tue, 16 Oct 2007 16:05:34 -0700 (PDT) Linus Torvalds <torvalds@linux-foundation.org> wrote:

Show 14 quoted lines
> I do indeed. I don't think it's sensible. And I did think I already 
> answered that issue by talking about how most editors don't even
> support it or show the difference between tabs and spaces.
> 
> For example, the editor I use - microemacs - supports tabs just fine.
> It does auto-indentation etc. But it does it with hard-tabs by
> default, so now you have to have some editor-specific setup for that
> particular project if you ever want to do anything else.
> 
> And that's really what it boils down to. Everybody support
> 8-character hardtabs (and usually by default). They may support other
> things *too*, but any time you move away from that standard
> behaviour, you'll most likely find something that doesn't support the
> alternatives.

Unfortunately most editors are totally confused about the difference between tab size and indentation level. Visual Studio, probably the most commonly used development environment on Windows, by default uses TAB characters that are 4 spaces wide, and users are recommended not to change that because of that a lot of existing Windows source code and examples uses those settings.

Two years ago, when I last looked at it, Eclipse, a very commonly used development environment, managed to confuse tabs and indentation and make it almost impossible to write Java or C code with a tab size of 8 with a different indentation level. The Eclipse 3 betas did see some improvement there, I think it got possible to do the right thing in Java at least, but the normal text editor and C editor lagged behind. But it was still a big mess and it was much too easy for someone to get a tab size which is not 8. Hopefully this has been fixed by now, but I wouldn't bet any significant amount of money on it.

Nedit (which runs on Linux) has a very confusing settings dialog with terms such as "tab spacing", "emulated tabs". I guess emulated tabs means the indentation level, but guess how easy that is to mess up.

gedit can control the tab width, but has no setting at all for configuring the indentation level. Guess what people do when they want a 4 space indentation level? Yes, right, change the tab size to 4.

A a former colleague who used visual slickedit usually produced code with tab size 4. I think I've gotten the same crap from ultra edit 32 users.

And so on... Mercifully, _all_ of these editors have a setting to use spaces instead of tabs, and telling people to turn on that setting is the absolutely easiest way of making things "just work". Yes, I know, the correct answer is to tell people to always use tab size 8, and I frequently and loudly do that. But at the same time, perfect is the enemy of good. It's much easier to explain "tabs will act differently in different editors, but if you always us spaces it will not be a problem" than to get into a discussion about the semantic difference between tab size and indentation.

If you assume that everyone is sane and use a tab size of 8 you will get bitten, sooner or later. Or actually, you, Linus, who are lucky enough to work mostly with Linux source, you might personally not get bitten all that often. But us poor suckers that have to work with other people, often Windows programmers, we do.

  /Christer
Previous: Linus TorvaldsNext: Linus Torvalds
Message 22 of 100 in “On Tabs and Spaces”
  1. Michael WittenOct 16, 2007
  2. Shawn O. PearceOct 16, 2007
  3. Michael WittenOct 16, 2007
  4. Andreas EricssonOct 16, 2007
  5. Sam RavnborgOct 16, 2007
  6. Petr BaudisOct 16, 2007
  7. DavidOct 17, 2007
  8. Andy ParkinsOct 17, 2007
  9. Adam PiatyszekOct 16, 2007
  10. Lars HjemliOct 16, 2007
  11. Adam PiatyszekOct 16, 2007
  12. Jeffrey C. OllieOct 16, 2007
  13. Michael WittenOct 16, 2007
  14. Jari AaltoOct 16, 2007
  15. Linus TorvaldsOct 16, 2007
  16. Mike HommeyOct 16, 2007
  17. Linus TorvaldsOct 16, 2007
  18. Linus TorvaldsOct 16, 2007
  19. Matthieu MoyOct 16, 2007
  20. Tom TobinOct 16, 2007
  21. Linus TorvaldsOct 16, 2007
  22. Christer WeinigelOct 16, 2007
  23. Linus TorvaldsOct 17, 2007
  24. Michael WittenOct 17, 2007
  25. Linus TorvaldsOct 17, 2007
  26. Luke LuOct 17, 2007
  27. Michael WittenOct 17, 2007
  28. Luke LuOct 17, 2007
  29. Nikolai WeibullOct 17, 2007
  30. Michael WittenOct 17, 2007
  31. Jari AaltoOct 17, 2007
  32. Andreas EricssonOct 17, 2007
  33. Jari AaltoOct 17, 2007
  34. Dmitry TorokhovOct 18, 2007
  35. Jari AaltoOct 18, 2007
  36. Petr BaudisOct 18, 2007
  37. Nikolai WeibullOct 18, 2007
  38. Miles BaderOct 22, 2007
  39. David KågedalOct 18, 2007
  40. Mike HommeyOct 18, 2007
  41. Jari AaltoOct 18, 2007
  42. Linus TorvaldsOct 17, 2007
  43. Johannes SchindelinOct 17, 2007
  44. Tom TobinOct 17, 2007
  45. Linus TorvaldsOct 17, 2007
  46. Tom TobinOct 17, 2007
  47. Linus TorvaldsOct 17, 2007
  48. Nicolas PitreOct 17, 2007
  49. Josh EnglandOct 17, 2007
  50. Linus TorvaldsOct 17, 2007
  51. Christer WeinigelOct 17, 2007
  52. Linus TorvaldsOct 17, 2007
  53. David KastrupOct 18, 2007
  54. Johannes SchindelinOct 17, 2007
  55. Christer WeinigelOct 17, 2007
  56. Johannes SchindelinOct 17, 2007
  57. Christer WeinigelOct 18, 2007
  58. Andreas EricssonOct 18, 2007
  59. David KågedalOct 18, 2007
  60. Linus TorvaldsOct 17, 2007
  61. David KastrupOct 17, 2007
  62. Johannes SchindelinOct 17, 2007
  63. Jan WielemakerOct 17, 2007
  64. Jeff KingOct 18, 2007
  65. Linus TorvaldsOct 18, 2007
  66. Jeff KingOct 18, 2007
  67. david@lang.hmOct 18, 2007
  68. Jeff KingOct 18, 2007
  69. Linus TorvaldsOct 18, 2007
  70. Linus TorvaldsOct 18, 2007
  71. Linus TorvaldsOct 18, 2007
  72. Jeff KingOct 18, 2007
  73. Add a message explaining that automatic GC is about to startkoreth@midwinter.com, Oct 18, 2007
  74. Steven GrimmOct 18, 2007
  75. Jeff KingOct 18, 2007
  76. Shawn O. PearceOct 18, 2007
  77. Brian GernhardtOct 18, 2007
  78. Steven GrimmOct 18, 2007
  79. Jeff KingOct 18, 2007
  80. Shawn O. PearceOct 19, 2007
  81. git-gc: improve wording of --auto notificationJeff King, Oct 19, 2007
  82. Shawn O. PearceOct 19, 2007
  83. Jeff KingOct 19, 2007
  84. Nicolas PitreOct 18, 2007
  85. Nicolas PitreOct 18, 2007
  86. Jeff KingOct 18, 2007
  87. Jeff KingOct 18, 2007
  88. David KastrupOct 17, 2007
  89. Nicolas PitreOct 17, 2007
  90. David KastrupOct 17, 2007
  91. SeanOct 17, 2007
  92. David KastrupOct 17, 2007
  93. Sam RavnborgOct 16, 2007
  94. Paul WankadiaOct 18, 2007
  95. Linus TorvaldsOct 18, 2007
  96. Dmitry PotapovOct 18, 2007
  97. Andreas EricssonOct 16, 2007
  98. Jan-Benedict GlawOct 16, 2007
  99. Andreas EricssonOct 16, 2007
  100. Robin RosenbergOct 20, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.