Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Styling - Tabs Versus Spaces #3426

Closed
tresf opened this issue Mar 14, 2017 · 9 comments
Closed

Code Styling - Tabs Versus Spaces #3426

tresf opened this issue Mar 14, 2017 · 9 comments

Comments

@tresf
Copy link
Member

tresf commented Mar 14, 2017

I assume the decision to use tabs over spaces is historical due to the use of editors like vi.

Since we're supporting many platforms and multiple versions of those platforms, configuring QtCreator for each machine can get tedious.

First, I'll make the assumption that QtCreator is the preferred IDE for most contributors. This has never been made official by the dev team (I personally use whatever is on the machine -- gedit, kate, notepad++, vi, TextWrangler) but I've spoken with many C++/Qt developers over the last year that use it exclusively, and now I'm starting to use it so it's the basis of discussion.

  • Currently, configuring QtCreator is a 4-step process.

    • Is this something that can be solved by a preference file in the source repo?
  • The argument of tabs vs. spaces is a very old and often heated one but switching to spacing (e.g. 4 spaces instead of the default tab width of 8) can prevent the code from "walking too far to the right".

  • A major downside to switching from tabs to spaces is it's not default for the majority of text editors.

Is this a standard worth changing moving forward? What is the primary IDE of choice among developers and how do you handle this problem in other large projects?

This isn't meant to start any flame wars. I'm well aware this is a sensitive topic.

@Spekular
Copy link
Member

Spekular commented Mar 14, 2017

"switching to spacing (e.g. 4 spaces instead of the default tab width of 8) can prevent the code from "walking too far to the right"."

Can't this be fixed by adjusting tab width in your editor of choice? I don't see any argument for spaces unless they've been used in the past and we're keeping consistency.

@tresf
Copy link
Member Author

tresf commented Mar 14, 2017

Can't this be fixed by adjusting tab width in your editor of choice?

That depends on

-    what you consider the "editor" 
+	what you consider the"editor" 

... since GitHub is what PR reviews are performed on.

I don't see any argument for spaces

The S.O. article here mentions a few good arguments for both sides.

@PaulBatchelor
Copy link
Contributor

I sure do love me my spaces, and I have to switch my preferences in vim just to do stuff in LMMS. However, I think efforts can be better spent elsewhere.

@Spekular
Copy link
Member

@Umcaruje
Copy link
Member

What is the primary IDE of choice among developers

I use Atom which automatically recognizes the indentation, so I'm fine either way.

I don't see why QtCreator taking 4 steps to switch to tabs should affect the coding conventions, also I haven't seen too many devs using it really. If we switch to spaces, all of the active Pull Requests would need to get changes as well as every file in the codebase. In my opinion, not worth the effort.

@tresf
Copy link
Member Author

tresf commented Mar 14, 2017

If we switch to spaces, all of the active Pull Requests would need to get changes as well as every file in the codebase. In my opinion, not worth the effort.

Not true! Code standards should happen gradually over time.

@tresf seems github tab size can be changed.

Thanks however that's per hyperlink, not very useful.

I use Atom which automatically recognizes the indentation, so I'm fine either way.

That sound like a very nice feature!

I think efforts can be better spent elsewhere.

It's a standardization question only. This isn't meant to be a sweeping change.

@tresf
Copy link
Member Author

tresf commented Mar 14, 2017

I don't see why QtCreator taking 4 steps to switch to tabs should affect the coding conventions

The decision doesn't have to be influenced by QtCreator, it is only what sparked the question. As I stated, all of my other editors default to tabs. I simply want to get a feeling for how people are handing this problem today.

@vlad0337187
Copy link

As for me, tabs are better, because everybody can adjust their width in text editor so, as is maximally comfort to him.

@tresf
Copy link
Member Author

tresf commented Mar 16, 2017

Closing this to keep the tracker clean. There isn't enough consensus to change the standard now but people are free to chime in.

It sounds like Qt's settings are global which seems like a bad IDE design. I use a proprietary editor for some other projects and it lets you easily define this setting at a project-level as well as what I consider superior GitHub integration... however... I know there are mixed feelings with the group on proprietary applications so I don't feel the research is worth it at this point.

If anyone's aware of other cross-platform C++ editors that work well, please mention them as well. At some point we need to make our project compilable (and editable!) in an IDE with minimal effort if we want to maximize productivity.

Back on topic...

Here's a quote from a previously linked article which I believe accurately describes my feelings on the topic.

All of the arguments for tabs are great in theory. But...

In theory, practice and theory are the same. In practice, they are not.

Yes, with tabs you can decide your indentation level. And yes, you can use a combination of tabs and spaces to align things. And in an ideal world it would

In reality, you can't see the difference between spaces and tabs, they always seem to get mixed up when moving code around, and viewing the code in another program that has tabs set to 8 columns is a nuisance.

I used to use tabs. Then I started to work as part of a team and share code. I quickly became a proponent of spaces. So while I can sympathize with the utopia of tabs, I can't imagine not using spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants