3 ms·
The usual argument is that a space is always the same width, whereas a tab can have varying widths depending on your editor. So, if you indent something with 4
by Sylos 10y ago
The usual argument is that a space is always the same width, whereas a tab can have varying widths depending on your editor.
So, if you indent something with 4 spaces, then other people viewing your code will also always see 4 spaces, therefore ensuring that whatever you found to be readable indentation, does actually come out like that on the other end.
- Retr0spectrum 10y agoBut why does that matter? The reader can adjust their tab-width setting to whatever they prefer.
- scrollaway 10y agoSome people absolutely want indentation to be one specific size for everybody and don't fully understand that what might look readable for them at 2 space-widths, would be more readable for some others at 4 space-widths. Tabs are accessibility. People use spaces for the same misguided reasons they use px font sizes in css. (Rant over. Yeah, this annoys me.)
- roblabla 10y agoMy personal reason : Because it makes aligning stuff harder than it should be. I often have conditions that span multiple lines, and if they aren't aligned, it makes everything harder to read. By using spaces, I make sure the alignment is good for everybody. I'm sure there are other reasons too.
- Retr0spectrum 10y agoSee the third example on this page: https://blog.codinghorror.com/death-to-the-space-infidels/ https://blog.codinghorror.com/death-to-the-space-infidels/