There are very few things I am absolute on. Don't get me wrong: I'm fully aware that I'm stubborn and that I have a lot of strong opinions. But after over 20 years in this industry, I have seen exceptions to almost every rule or convention that has been thrown at me.
For this month's T-SQL Tuesday, Alex Yates asks us to talk about occasions where we have changed our minds about something – an opinion, an understanding, a practice. Multiple incidents came to mind immediately, but one of my favorite religious debates has always been…
I am a stickler for formatting, and have always been against tabs because of how inconsistent they can make code when moving between different editors or users with different settings. Where I copy and paste code most is between SSMS or Azure Data Studio and a limited textarea on Stack Exchange. As an answer progresses, I might copy and paste back and forth many times, and I would lose some of the formatting each time. Especially when each new line in certain editors inherits spaces from previous lines but converts them to tabs. When the textarea content is rendered on a web page, the spots where that happened stick out like sore thumbs. So when I could, I would convert my editors to insert spaces whenever I used tabs.
I once got scolded for using spaces; the argument was that all those incidents where there were four spaces instead of a single tab would cause the code to execute poorly. After Andy Mallon blogged about this debate for T-SQL Tuesday #99, where he baited me, I tested the performance. I concluded that there was no discernible performance impact of using spaces instead of tabs.
So, I was still on the same page with Andy, where spaces were the logical choice for formatting and indenting, especially since I had personally debunked the performance myth. What could change my mind?
Sometime after Andy's post, there was a discussion on social media where people advocated for accessibility over cosmetics. In particular, when you have code that is being reviewed by someone using a screen reader, or a very wide screen, or their own settings to convert tabs to <n spaces>, the difference between tabs and spaces can become quite painful. A couple of pieces I'd urge you to read:
I was convinced before I even got to the end of either of those posts. So, now that I know tabs are more friendly than spaces for folks with accessibility issues, I'm going to fix my habits. As with other changes I've made to my long-standing conventions (like lower-case data types), I'm not going to go back and edit all my existing code out there, but I will be making a conscious effort to use tabs going forward.