What is wrong with tabs in source code?

For some reason, almost all code conventions prohibit use of tab character (they recommend using spaces).
For example, in Real Word Haskell p. 66 and they state that tabs are bad and repeat in chapter 3: “[…] never use tab characters in Haskell source files. Use spaces.”
The explanation: tab character may look different for different users.
But why is it bad? I like using source code with tabs, because I can define tab as 2, 3, 4 or 8 spaces; I cannot do it with a source that uses spaces.
So, I see many reasons using tabs for tabulation instead of spaces (assuming you use it consistently):

  • Configurability: I define the size of tab, depending on my preferences, screen size or whatever. Dictating me the size of tab is no more logical than saying me what font color to use.
  • Ease of use: turn “cursor through tabs” oftion off; backspaces/delete button deletes tab; navigating code is easier
  • Consistancy: tab char enforces you to use equal identation
  • Revertability: converting tab to X spaces is easy; converting X spaces to tab is more difficult, when you don’t know X value.
  • Advertisements

    Tags: , ,

    4 Responses to “What is wrong with tabs in source code?”

    1. oyd11 Says:

      the only real problem is Python code, my 5 y/o Python code doesn’t compile!
      all I did was ‘open – edit – save’ cycles, ie, the problem with tabs – is *EDITORS* that save them into spaces and vice-versa!
      now, I have to guess the reindentation of my python code!

      • komap Says:

        Sounds strange. AFAIK you use vim for editing, which is great for preserving tabs.
        But it is not really important what is your favorite editor as far as you consistently use tabs: both tab key and use tab character in your editor.
        I use interchangeably vim/notepad++/IDLE and there is no problems.
        OK, there is soe problem with IDLE, (see here)

    2. oyd11 Says:

      I only had problems with ‘recovering’ old python code though 3 computers (ie, copying from an abandoned disk twice) donno who touched the files (apart from editors), anyhow, Python had had it’s nice period, but it seems to be over.

      • komap Says:

        “Python had had it’s nice period, but it seems to be over.” — oh no, please don’t start flame war :)
        For me, python is my default language for wide range of task between non-realtime image processing to system scripting and web programming. It is definitly not going anyway.

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s


    %d bloggers like this: