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
-
theuser48025yTo tell you the truth, this has been asked before, and the answer is apparently spaces because most modern editors will convert a tab character to 4 spaces by default.
Its pretty much like newlines and version control. They will generally be converted to unix newlines by default and so the issue is not really relevant anymore -
Spaces, if I get to choose, but the difference is so insignificant that I often just leave it on whatever the editor default is.
-
kamen69885yTabs. You can change at will how they appear without touching the code (or by only touching prettier/lint files). Today I prefer tabs to be equal to 4 spaces. Tomorrow I might switch to 2. You can't do that with spaces.
-
iamai21075ySpaces for the control but sometimes tabs because it's quicker. I use spaces more often because I like to line-up my codes and paragraphs nicely.
-
hjk10157315yTab vs spaces here we go again. So 2 spaces or 4 or are you eccentric and 3 spaced out.
Thank Go for tabs and a build in formatting tool.
Spaces displayed consistent everywhere is a myth. Depends on Font. So tabs can be adjusted to your needs is just about any decent editor. Removing the whole how many spaces debate which is far more important than bullshit consistency. Tabs are made for indentation spaces are not. -
hjk10157315y@FrodoSwaggins I'm not a lunatic but open dyslexic font looks way different than courier.
If I feel that lines are getting to long to fit I can adjust my tab with for the project without fucking up the contents.
Don't get me wrong I'm using PSR-2 on PHP as this is the dominant standard and that is fine. I will adapt. However tabs are better. Using golang makes that clear every time. There is some discussion about the Drupal code standard again for Drupal 9. Won't see that happen with any Go project. -
An interesting concept I found on a SO post about this type of discussion, is that you store your source as whatever, and have your editor just format it the way you want to see it. Kinda like how HTML and CSS are supposed to work.
Are there any editors/IDEs that have experimented with that type of functionality? -
Tabs because spaces are stupid. Makes it harder to select the right position with the mouse and you can't navigate with arrow keys which I do all the time for efficiency
They're objectively worse -
@FrodoSwaggins To be fair, it's the same argument as "spaces look the same everywhere". 4-wide tabs are the standard that everyone uses
-
theuser48025y@12bitfloat True, "everybody" uses tabs because obvious reasons. Spaces are error prone and less convenient, simple as that. If editors did not have any sort of automatic conversions, then the majority would press tab to get their indents on.
-
@theuser Which makes me wonder why people are using spaces in the first place when they are so annoying to use, editors have to pretend they are actually tabs
-
theuser48025y@12bitfloat Spaces are more absolute and consistent. If you worked in a public open source project with lots of contributors, then that project would probably use spaces consistently. For other smaller or internal projects where everybody have the same tooling, then the consistency would not be such a big factor.
-
@theuser My code is 100% consistent stylistically, and I exclusively use tabs. I guess it's more of a concern when doing crazy half-indents for wrapped lines or something but that's definitely harder to keep consistent than just two tabs
-
3 spaces of course.
It's a very satisfying compromise between frontenders who use 2 and backenders who use 4. -
@12bitfloat sadly not everyone uses 4-wide tabs (https://kernel.org/doc/html/...)
Other wise I totally agree w/ you, spaces suck
And maybe spaces are visually more constant, but fuck that when fucking symfony now forces you to use 4 spaces in YAMLs but your 300_000 LOC codebase uses 2 ! π‘ -
@MagicSowap OMG, indeed, enforcing more spaces per indentation level is not pragmatic at all.
-
Tabs. And I just can't get why the hell people can just still think about spaces.
@12bitfloat mentioned how awful it is for navigation, which is true, objectively
Now about presentation, as far as I understand the functioning of tabs, it is rendered as regular separation of a certain amount of space fixed by your editor
So visually you can't see a difference with spaces, plus there's something great about it: since it is rendered by your text editor, you can set it to be of any width you want without annoying your coworkers working on the same file with different indent likings. So no stupid compromise. -
@CodeTalker Spaces are better if you want to align indents to some text element. For example in python if your function call gets too long you're allowed to break the parameter list into multiple lines, but they have to be aligned to the opening parenthesis. You can't do that with tabs precisely because you can't expect them to be exactly 4 chars wide.
-
To be honest, I tend to stick with what this tells me:
https://ukupat.github.io/tabs-or-sp...
That way, when I publish my code or collab, I minimize the chance of annoying others... because to be honest, I don't really care all that much.
I was serious about 3 spaces though, all my historical Haskell projects are 3-spaced in any place where indentation is an arbitrary choice instead of alignment-based, because I've worked professionally on multiple large Haskell codebases which where 3-space indented.
Their reason really was "it's a compromise between 2 and 4", and it grew on me after a while. -
Spaces. The debate has dried up, and all but a minority of styling docs now specify spaces (for most languages anyway.)
At this point it doesn't really matter about the finer reasons why, it becomes about being pragmatic rather than principled. There's some things in life where going against the flow and being principled is really worth it - spaces vs tabs is not one of those arguments. -
@AlmondSauce ON TO THE LIGHT VS DARK MODE DEBATE!
No?
OK HOW ABOUT FIGHTING BLOODY BATTLES OVER CURLY BRACE PLACEMENT? K&R VS 1TBS, ROUND ONE, DING DING DING!
Still no?
OSX VS LINUX? VIM VS EMACS?
No?
OK can we at least all agree that Postgres beats both MySQL and MariaDB? -
@bittersweet OpenLDAP if you ask me.
Or if you want it to react fast: Redis on a swapped drive (because all our data wouldn't fit into memory) which is actually a giant LVM logical volume spanning over several files on networked drives mounted to the database server with SFTPFS. -
@bittersweet SFTP filesystem. It's a tool to mount sftp shares. It should be sftpmnt though.
-
jaeyo145yAccording to language. There’s different best practice as defacto by languages and in most cases, that is space. The only matter is how many spaces. 2 or 4.
-
@vintprox thing is, you can't just enforce a different indentation level on an existing codebase !
Especially as we are talking about yaml here, which means bad indentation = bugs/crashes and you can't just regex 2 to 4 spaces easily.
Maybe you like 4 spaces in your yamls, but I don't. And I have other things to do than changing the indentation of config files ffs ! -
@Lor-inc I'm rarely doing that so I didn't think about it, but you have a point
This is a shame this can't be done with tabs — though I can't see a proper way to do it -
@CodeTalker It can't be done with tabs precisely because their width is adjustable, which is a their selling point. What could be done, is to have the IDE differentiate alignment from indentation and convert to spaces only the alignment part.
-
@MagicSowap But I jsut said that: it's very inconvenient, you know. Syntax enforcing more spaces/indent = evil
-
kurast3364yTab on the keyboard. The editor may or may not convert it to spaces. I leave it to luck.
Only relevant for python anyway, which i don't use much -
@pythondev No, they're actually for alignment in columns. That's why their width varies depending on what's before them. For indentation you wouldn't need this - otherwise quite problematic - feature.
-
theuser48024y@shakur Good point, I did not know this. He may have felt that two wasn't legible enough and 4 was too error prone? Its quite convenient to hit the spacebar three times as opposed to four.
-
@theuser @pythondev I highly doubt RMS would've pressed the spacebar three times, he's the kind of person who, if he has to do something thrice, will get the editor to do it for him so he only needs to issue indent and outdent commands.
Related Rants
tab vs spaces, which do you prefer?
joke/meme
spaces
funny
tabs