Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I'm not sure which one's better, but it's great fun to argue about!
(I use spaces as most text editors will display them properly) -
Trinsec1837yI usually use tabs. It's easy to instantly change the amount of spaces a tab should display in any good editor.
-
But supposably there's something dangerous about using tabs, and I wanted to know what it was.
-
Root825997yTabs or spaces work fine, so long as you're consistent. However, I will always argue in favor of spaces.
Tabs make code more difficult to read on e.g. github because you cannot change their width. They also make aligning difficult for non-multiples of tab_width (ex: multiple declarations of type char, multiline array literal within a comparison, etc.). Tabs lead to other readability issues as well, and there are usually ways to avoid them, but not always.
Of course, everything also turns into a giant unreadable disaster if devs mix tabs and spaces, so consistency is more important than your choice. -
@Root gofmt indents with tabs and aligns with spaces. And since everyone uses it, there can't be ambiguity for go code. Javascript though is a different beast 😨 I also stumble upon files in the codebase that were written using different editor settings (exactly because they have spaces, which is 2 spaces but I like to see them as 4, so I need to reformat)
Related Rants
What's better tabs or spaces ?
I don't know the implications of each.
question
tabs
spaces