by jve · 1mo ago · 0 comments
I guess my IDE choices never surface the issue for me... visually they just look the same. I cannot say which codebase uses spaces which uses tabs. I never even think about it. I just smash tab character and don't care that there have been spaces. Or enter or { and IDE does the indentation. I just choose not to press space 2-4-8-16 times in a row.
Now I hope I won't get bulldozed over by HN crowd...
These days, I try avoid them outside of makefiles.
From bash(1):
> If the redirection operator is <<-, then the shell strips all leading tab characters from input lines and the line containing delimiter.
That's also how it works with zsh.
This is why my here-doc delimiters are always un-indented despite surrounding indentation.
Wish bash had something like ruby's `<<~`, which accepts either space or tab indentation of the delimiter and additionally removes the indentation of the block (likely based on the least indented line).
That said, the original UNIX V7 implementation of /bin/sh didn’t distinguish different kinds of whitespace:
With tabs pretty much every editor except something like notepad.exe could do it since ancient times, with spaces the editor needs to do a bit more processing, so you were a bit more restricted in editor choice, if you really were bothered so much by the indents chosen in the project.
So it is actually quite similar to the ligature discussion. It would be good if the code looked the same for everybody but now instead of saying "But 8-space indents waste so much space on the screen :(" some people now go "But I don't like seeing things like != or -> instead of modern Unicode symbols :("
tab * 4 + space * 7 + tab * 2
tab * 2 + space * 1 + tab * 1
tab * 1 + space * 4 + tab * 2
space * 16 + tab * 3 + space * 4
tab * 4 + space * 2 + tab * 2 + space * 2
tab * 3 + space * 3 + tab * 1 + space * 6
The code ends up looking janked unless you use the particular tab-width of the space/tab-indenter[1], which isn't always 8. It completely defeats the whole purpose of the tab indentation.[1] On those first 2, given the odd (not even) number of spaces, it's likely that use of spaces was for alignment, but then a tab-indenter added tabs to that...
It's too bad spaces won, tabs is just correct I think, since one can configure the tabstop to use any indent size they would like. I'm quite tired of reading 2-space indent. Seems everything has moved this way now except python. I'm even seeing C with it, which is especially jarring. I think the languages that use braces for indentation particularly need 4. Python needs it least, and I can read Ruby because its blocks are delimited by words and it's bad style to write long methods
Granted, I'm also someone who heavily encourages the use of Black as the Python formatter in projects I'm on, specifically because it has no configurable options - can't have a holy war about formats if nothing can be changed.
The reason spaces won is that it's not (spaces) vs (tabs), it's (spaces) vs (tabs AND spaces).