59
lxmcf
7y

Spaces instead of tabs... Is there anything worse you could do? Nope, cant think of it...

Comments
  • 12
    Tabs instead of spaces... Is there anything worse you could do? Nope, can't think of it...
  • 5
    Don’t use tabs read about soft tabs always spaces unless the language force like Go and Makefile
  • 2
  • 3
    @Condor this guy knows the about our holy saviour of tab key!
  • 1
    @Condor Deus Vul/t 🗡️🛡️
  • 3
    *clack* *clack* *clack* *clack*
  • 4
    @rkajaste you evil bastard
  • 1
    If you use tabs only, how do you ident 3 spaces to align parameters fo exaple?
  • 1
    @enclaver I don't align parameters, will use tabs to align variables initialisation though.

    Aligning parameters ends up messy imo
  • 1
    @lxmcf tbh I dont care that looks meesy to you. There are code standards for different languages
  • 1
    @enclaver tabs is for indentation, spaces for alignment, it's called smart tabs, available in every ide as far as I know.
  • 0
    Insertin NULL characters is nice as well though they arr not white space...
  • 1
    @Codex404 I dont use ide. I set my editor to insert 4 or 2 spaces when I press the tab key on a keyboard. Is that what you call smart tabs? If thats it, I would say you use only spaces in your source code, which I do also
  • 0
    @Condor no,please, nobodu imagines how tabs are set. Blanks are the true white space.
  • 2
    Soft tabs ftw!
  • 0
    @enclaver are you trolling? Or are you just clueless how tab indenters work? Which makes me curious if all spacedenters have this when discussing it?
  • 1
    I was a tab fanatic, until I realized you can't have an 80 char limit (or any other number) and also have variable indentation.

    But as long as you agree the tab width, you are still good!
  • 2
    2 spaces for indentation is what we follow in our team. We transferred one guy to other team when he used tabs despite giving multiple warnings.

    2 or 4 spaces are a standard at most of the teams I have worked with.

    Even if you choose tabs, make sure that everyone else in your team follow the same standards.
  • 0
    I've asked this multiple times but what are advantages from spaces over tabs?

    I've tried both quite a lot and prefer tabs myself. So far the only point to use spaces I understand so far is the support for editors like vim where you can't change tabsize for some reason
  • 2
    @Codex404 i have no idea what you are talking about. My bottom line is: you will not find any \t characters in my source.
  • 0
    @enclaver I will get to my or to explain then
  • 2
    @Codex404 There's no advantage which are important. The only advantage of spaces that I got was I can choose to have 2 spaces instead of regular 4 and if any other developer in my team accidentally uses 4 spaces, the code doesn't break or look ugly. All spaces take same size, thus the IDE settings are also irrelevant for tab sizes.
    The other advantage for me is that I can easily paste the code into a markdown file or Stackoverflow whenever needed. I personally prefer 2 spaces, as the code looks better with that to me.

    You don't have to actually type spaces. All IDEs know how to convert a tab key into 2 or 4 spaces.

    In the end, it's all about the Standard that your team is following. If most of them prefer tabs, go with tabs and vice versa. Just pick one and stick with it. Don't let any other developer go in any other direction.

    If you're into JavaScript, I would suggest you to read Douglas Crowford's thoughts on this in his book "JavaScript: The good parts".
  • 0
    Taken from another thread, take a look at this: http://ukupat.github.io/tabs-or-spa...
  • 0
    @enclaver

    I use:

    Tabs for indenting,

    Spaces for alignment (for example parameters alignment)

    By using the smart tabs option available in almost all IDE's and editors I only have to use the tab key. This way I've the best of both worlds. Personal indent size (Depending on the language I prefer a width of 2, 3 or 4 characters), and nice alignment no matter what tab width you use.

    Some C# to explain:

    https://pastebin.com/5m9PyqJa )
  • 0
    @creator You say you are using spaces, but all I can gather from your story is that tabs are for you...

    I also prefer a tab width of 2 or 3 spaces in most languages. By using tabs each person can choose for themselves. Using spaces you cannot really do that (without converting the characters in your ide forth and back)
  • 1
    Either your explanation doesn't make sense or everyone will hate you
Add Comment