yuhr/blog.yuhr.org

Soft Tabs Are Hard

Closed this issue · 0 comments

yuhr commented

Every time I hear people saying “hard” or “soft” when talking about indentation style, I feel it's the other way around, because what people call the “soft” way is to bake the visual width of indentation into the file, which can be thought as a typical instance of hardcoding, like in analogy with “hard wraps”.

Actually, they're saying “hard” or “soft” about “tabs”, not about “indentation”, so I understand it's okay to say baking tabs into the file as “hard tabs”. But wait...

Strictly speaking, what exactly we want to do is to perform indentation, not to insert tabs or spaces specifically. Tabs or spaces are just two naïve implementations of indentation. It sounds unnatural to me to use the words like “hard tabs” and “soft tabs” when talking about indentation. I don't know who has started such wording, but this is the time to reconsider what those words mean.

Instead I propose this wording: “soft indentation” and “hard indentation”. Just like the “soft wrapping” leaves where to insert line break to the renderer, “soft indentation” leaves how much width a single level of indentation takes to the renderer. On the other hand, “hard indentation” hardcodes it by encoding the width to the number of spaces. Quite natural, isn't it?

TL;DR, the correspondence is:

  • Soft indentation = Hard tabs
  • Hard indentation = Soft tabs

So, remember, soft tabs are hard.