Re:Shell Style Guide from Google
by paule89 on Saturday June 04, 2016 @06:19PM
(#11838418)
Google seems to prefer spaces over tabs
[ Parent
| on HN ]
I prefer spaces. Tabs can render differently in different editors, making alignment harder.
Always irks me when I come across some config file format that only accepts tab delimeters.
Which is why I take (well, prefer) a third option:
Tabs for indentation. Spaces for alignment.
The idea is you should be able to set any tabstop you like and the code will still align correctly. For example:
^Ia_really_long_method(a_very_long_argument,
^I the_second_argument)This is the most logical option. Tabs to add an indentation level, the width of that is unimportant and can be configured by each user. Spaces to align, since they're like any other character in a mono spaced font thereby perfectly matching the line above.
And 2 spaces is way too little. 4 is the sweet spot.
Reason: with 2 the visual lines at different indent levels are just too close, in many fonts/sizes.
It's 2 spaces for everything here, even python. I don't like it and don't think I'll ever get used to it, like you say 2 is too little.
Re:Shell Style Guide from Google
by rossjudson on Saturday June 04, 2016 @11:07PM
(#11839441)
Wrong. 3 spaces is the sweet spot. What is it with you people and powers of two? ;)
It is easy to catch an indentation error with two spaces, while it is harder to make an indentation error with just two spaces. It also easier to type two spaces than 3 or 4 spaces, which is important when program is typed without help of an autoindentation tool. Two spaces are enough for fixed length font, typical in terminal, but also saves screen space, which is just 80 characters in width.
Golang uses tabs and not spaces though.. I actually thought everyone used spaces instead of tabs till I had to use it.