9 points

The argument for having tabs adjust depending on your ide sounds better than it is in practice. Someone formatting code to look nice with width 4 will look horrendous for someone who uses width 8.

Spaces makes it uniform and captures the exact style the original dev intended

permalink
report
reply
0 points
*
Deleted by creator
permalink
report
parent
reply
11 points

If you have your tab width set on 8, that is on you. You will also set your IDE to insert 8 spaces when you press TAB and I will cry when I have to give you a code review.

When I indent my code, I am indicating that I am in a nested block. I don’t care if, on your screen, that indent is 2, 3, or 4 characters.

permalink
report
parent
reply
2 points

Anarchist: tab with set to 1

permalink
report
parent
reply
2 points

That’s fine, when I view it I will get my preferred tab width. This situation is only anarchist with spaces, with tabs they are just a masochist.

permalink
report
parent
reply
1 point

Honestly, my editor (Neovim) just picks between tabs and spaces for me, so I just end up using whatever’s already there. The only language where I’ll explicitly use one is Haskell, just because spaces there allow me to keep everything nice and lined up.

permalink
report
reply
6 points

why don’t we store code unformatted and have everybody’s IDE display it with their preferred format applied? it would make everything easier and stop people bickering over pointless things.

permalink
report
reply
2 points

Storing an AST would be interesting, but it’d require the IDE to support parsing each specific language, so you’d probably want something like an LSP but for just parsing to handle that.

permalink
report
parent
reply
19 points

That’s what tabs are for. 1 tab, to an ide, means “you choose how many spaces this tab is, and when we commit it back to git it won’t fuck the history up.”

permalink
report
parent
reply
5 points

I guess they were referring to formatting other than tabs, like place of brackets and line length, which sounds like a neat idea

permalink
report
parent
reply
5 points

…until you start using languages where whitespace is the only way to distinguish code blocks. (Most notably Python.)

permalink
report
parent
reply
1 point

Wrong.

permalink
report
reply
9 points

I think calling one way better than the other is flawed. The reason the title is saying that tabs are objectively better is because they are used in addition to where spaces are used elsewhere. You could make the same argument in favor spaces due to keeping things simpler.

The argument of having variable indent size for tabs so viewers can decide how big they are is imho legitimate but also not the goal as it’s addressing something that teams generally agree on. There is max characters per line, brace placement, general code style and rules. Yes we can eject the indentation from the rules that are agreed on but once again simplicity over complexity has an equal say.

In the end it doesn’t matter that much, a good programmer will be able to work in either setting, the Editor will do most of the work anyways.

With all that said, spaces all the way!

permalink
report
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.5K

    Monthly active users

  • 1.6K

    Posts

  • 26K

    Comments