5 ms·
Google seems to prefer spaces over tabs
by paule89 10y ago
Google seems to prefer spaces over tabs
- ams6110 10y agoI 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.
- ekimekim 10y agoWhich 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)
- sorenjan 10y agoThis 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.
- rifung 10y agoGolang uses tabs and not spaces though.. I actually thought everyone used spaces instead of tabs till I had to use it.
- riskrisk 10y agogolang also had/has a style guide and a gofmt tool that would indent/align things the same way from the beginning.
- e40 10y agoAnd 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.
- tomlu 10y agoIt'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.
- rossjudson 10y agoWrong. 3 spaces is the sweet spot. What is it with you people and powers of two? ;)
- lisivka 10y agoIt 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.