Microsoft veteran ditches Team Tabs, blaming storage trauma of yesteryear
- Reference: 1728376215
- News link: https://www.theregister.co.uk/2024/10/08/microsoft_engineer_tabs_spaces/
- Source link:
The debate has vexed engineers for decades – is it best to indent code with tabs or spaces? Osterman, a four-decade veteran of Microsoft, was Team Tabs when storage was tight, but has since become Team Spaces with the advent of terabytes of relatively inexpensive storage.
"Here's the thing," he [1]said . "When you've got 512 kilobytes, and you're writing a program in Pascal with lots of indentation, if you're taking eight bytes for every one of those indentations, for eight spaces, you could save seven bytes in your program by using a tab character."
[2]
It all added up, even when floppy disks were part of the equation.
[3]
[4]
However, according to Osterman, things have changed. Storage is less of an issue, so why not use spaces? A cynic might wonder if that sort of attitude has led to the bloatware of today, where software requires ever-increasing amounts of storage in return for precious little extra functionality and a never-ending stream of patches.
Any decent compiler should strip out any extraneous characters, assuming the code is indeed being compiled beforehand and not interpreted at run-time.
[5]Office 2024 unveiled for Microsoft 365 refuseniks
[6]Saying goodbye to the tech dreams Microsoft abandoned with Windows 11 24H2
[7]Microsoft throws in the towel on HoloLens 2
[8]Microsoft hits go on Windows 11 24H2: Fresh features, bugs, and a whole lotta AI
For his part, Osterman is now a member of team spaces. "I like spaces simply because it always works and it's always consistent," he said.
The nightmare scenario is where developers have mixed tabs and spaces in the same source code file, creating a mess that has the potential to be indecipherable by whoever has to maintain it in the future.
[9]
The argument is set to rumble on, even as fights break out over using [10]Rust or C in Linux . Then there is the near-religious fervor with which developers debate the benefits of vi versus [11]Emacs .
Ultimately, Osterman's recommendation is sound: whatever a developer's preference, the most important thing is not to mix the two approaches.
We'd add that any organization worth working for will have coding standards that should put the matter to rest one way or the other.
[12]
Otherwise, if you want to fill your source code with spaces, plenty of companies are more than happy to sell you some extra cloud capacity for all those extra characters. Osterman, no doubt, can probably name at least one. ®
Get our [13]Tech Resources
[1] https://youtu.be/iqhJev33Qno?si=8dtEcz10ck8_7wQ-
[2] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2ZwUCxdFJjItPH3TcefBhxgAAAME&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0
[3] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44ZwUCxdFJjItPH3TcefBhxgAAAME&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0
[4] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33ZwUCxdFJjItPH3TcefBhxgAAAME&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0
[5] https://www.theregister.com/2024/10/04/office_2024/
[6] https://www.theregister.com/2024/10/03/whats_gone_from_windows_11/
[7] https://www.theregister.com/2024/10/02/microsoft_hololens_2_dead/
[8] https://www.theregister.com/2024/10/02/windows_11_24h2/
[9] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44ZwUCxdFJjItPH3TcefBhxgAAAME&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0
[10] https://www.theregister.com/2024/09/19/torvalds_talks_rust_in_linux/
[11] https://www.theregister.com/2016/10/31/google_man_drags_emacs_into_the_1990s/
[12] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33ZwUCxdFJjItPH3TcefBhxgAAAME&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0
[13] https://whitepapers.theregister.com/
Re: where developers have mixed tabs and spaces
Or several coders who think they know best, but disagree.
But hey, you mean there are source files where this doesn't happen? Like everything else in the world, it's a mess and you have to just deal with it. Purists should be left to eat flamebait (he says, posting some just for the lulz).
Is it a really a problem?
"Thou shall use four spaces per indentation, and an indentation shall be four spaces."
And then if you wanted to line things up nicely to aid readability then the remainder is done using spaces.
Tabs. Always tabs. It's very easy to see indentation differences when it's 1 tab, 2 tabs or 3 tabs. But when you use spaces, the intention to use 4 spaces, 8 spaces or 12 spaces invariably ends up being 3, 5, 9, 11, 13 etc.
Also, if you then want to add another IF condition within a while loop within another while loop, what's quicker - tab tab tab or space space space space space space space space space space space space?
Tabs all the way.
This isn't about storage any more, however code readability shouldn't suffer.
NB I'm assuming four spaces is the chosen number; any less and it's hard to work out what's what.
Tabs all the way... just standardise how many spaces = 1 tab, it's really not difficult and that's the cause of 99% of problems.
Personally, I hate any editor that distinguishes and compilers shouldn't care one bit. The nonsense with Makefiles and other indentation-dependent languages is so ridiculous that it's laughable it still survives in the modern age.
Hell, if you must, insist that pressing Tab literally inserts 4 spaces into the document.... I'm happy with that as a compromise.
But don't say I *can't* use a Tab key and *must* type in 4 individual spaces for every indent level in a large codebase.
> tab tab tab
Is indeed quicker, which is why any text editor that is worth the CPU/Memory/... to run will automatically insert the correct number of spaces (including less than four if there is already a character or more in place. And auto-indent the next line to match (use shift-tab to reduce indent). A serious editor (eg. what you should be using if paid to write code) will support an editorconfig file in the repo so the team shares settings and does not depend on everyone configuring their editors the same.
If your standard editor cannot do this, then PEBCAK.
What I don't understand
is why code editors don't just go, "do you want tabs or spaces?", get on with prettying it up for you, and offer the option of stripping it all out anyway when you save out.
I mean, if Notepad had that option, I'd never use anything else.
Re: What I don't understand
Eclipse always used to, I don't know if it still does.
The Coding Style (or whatever it was called) tab on Eclipse was one of the best formatters/linters I know, and would operate as-you-typed as well as allow you to just "format all" (in essence, though I forget the procedure to do that now).
Re: What I don't understand
If your editor cannot do this natively there may well be an extension to do it.
Tabs. Life's too short to peel grapes and count spaces.
Does it matter?
It isn't too difficult to run source code through a a filter to convert to and from tabs and spaces or, more intelligently, ingest the source code into an (annotated) abstract syntax tree and emit a canonically formatted version of that code.
The venerable C code formatter indent does a pretty decent job and doesn't actually grok C syntax.
Syntactically white space should be white space but historically various syslog.conf and Makefile implementations have begged to differ.
At least on this vi and emacs agree in seemingly allowing most common indentation variations.
One peculiar and confusing situation was looking at C code in a terminal window stuck on a proportional typeface - ugly enough but oddly the tabbed indents aligned but the spaced indents didn't.
" The nightmare scenario is where developers have mixed tabs and spaces in the same source code file, creating a mess that has the potential to be indecipherable by whoever has to maintain it in the future. "
That isn't the fault of spaces, that isn't the fault of tabs. It's the fault of a coder who thinks they know best.