DEV Community

yuhr
yuhr

Posted on • Originally published at blog.yuhr.org

Soft Tabs Are Hard

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.

Hot sauce if you're wrong - web dev trivia for staff engineers

Hot sauce if you're wrong · web dev trivia for staff engineers (Chris vs Jeremy, Leet Heat S1.E4)

  • Shipping Fast: Test your knowledge of deployment strategies and techniques
  • Authentication: Prove you know your OAuth from your JWT
  • CSS: Demonstrate your styling expertise under pressure
  • Acronyms: Decode the alphabet soup of web development
  • Accessibility: Show your commitment to building for everyone

Contestants must answer rapid-fire questions across the full stack of modern web development. Get it right, earn points. Get it wrong? The spice level goes up!

Watch Video 🌶️🔥

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

DEV shines when you're signed in, unlocking a customized experience with features like dark mode!

Okay