Tabs Vs. Spaces

Yesterday I came across a weird problem which took me a whole day to troubleshoot but without luck. Speaking simply, one YAML configuration cannot be parsed due to whatever ParserException..

Alright this morning, I finally got it solved by editing the file with UltraEdit instead of Vim. As always I’d like to dig out what exactly was going on there. Then I found out that when I insert a new line, both Vim and UltraEdit can indent automatically for me, the difference is, the latter uses spaces but the former users tabs!!

But what’s wrong with Tabs???

Then I was embarrassed to find one of the only two items of YAML’s FAQ talks about this:

Why does YAML forbid tabs?
Tabs have been outlawed since they are treated differently by different editors and tools. And since indentation is so critical to proper interpretation of YAML, this issue is just too tricky to even attempt. Indeed Guido van Rossum of Python has acknowledged that allowing TABs in Python source is a headache for many people and that were he to design Python again, he would forbid them.

So that’s it! It is a classical “religious war” within computer science.(Just like the war between Emacs & Vi). Check out this good article.

I instinctively feel that Tabs should be the one, like the article above said

Simply put, tabs is proper, and spaces are improper. Why? This may seem ridiculously simple given the de facto ball of confusion: the semantics of tabs is what indenting is about, while, using spaces to align code
is a hack.
Now, tech geekers may object this simple conclusion because they itch to drivel about different editors and so on. The alleged problem created by tabs as seen by the industry coders are caused by two things: (1) tech geeker’s sloppiness and lack of critical thinking which lead them to not understanding the semantic purposes of tab and space characters. (2) Due to the first reason, they have created and
propagated a massive none-understanding and mis-use, to the degree that many tools (e.g. vi) does not deal with tabs well and using spaces to align code has become widely practiced, so that in the end spaces seem to be actually better by popularity and seeming simplicity.
In short, this is a phenomenon of misunderstanding begetting a snowball of misunderstanding, such that it created a cultural milieu to embrace this malpractice and kick what is true or proper. Situations like this
happens a lot in unix. For one non-unix example, is the file name’s suffix known as “extension”, where the code of file’s type became part of the file name. (e.g. “.txt”, “.html”, “.jpg”).
Another well-known example is HTML practices in the industry, where badly designed tags from corporation’s competitive greed, and stupid coding and misunderstanding by coders and their tools are so
wide-spread such that they force the correct way to the side by the eventual standardization caused by sheer quantity of inproper but set practice.

It’s good to get my problem solved, and it’s of so much fun to read these stories :)

About Kymair

A simple guy living in Zhuhai, likes reading, not go out often.
This entry was posted in Development. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>