[ / / / / / / / / / / / / / ] [ dir / animu / asmr / cafechan / egy / leftpol / miku / vg / zoo ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Email
Comment *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

[–]

 No.1022580>>1022672 [Watch Thread][Show All Posts]

/tech/, I don’t understand the benefit of 4 spaces or at the very least how to make myself efficient with spaces. FWIW, I’m using vim, and here are some scenarios. A lot of these are probably because of how much I am used to tabs:

>I’m doublechecking the nesting.

>Holding down that ‘j’ key.

>Oops, I hit a line with a comment in it.

>With tabs, I’m probably going to remain vertically aligned in the correct place.

>With spaces, HAHA YOU’RE FUCKED.

>How deeply nested am I again?

>’0’, count the number of times I press ‘l.’

>with spaces I press it four times as much.

>>Actually, I don’t even do that, I can press ‘V’ and since the highlighting indicates individual characters in a different color than the space inbetween tab characters, I can visually see the nesting number at the beginning of the line.

>I need to close these two loops.

>Just delete two tabs.

>With spaces, go back 8 times…then notice every once in a while I missed a key because the nesting didn’t line up with things previously.

>I move to a new system without all my custom configs because of temporary reasons.

>No matter, typing in a tab isn't that onerous.

>Press enter after a typical nesting character like ‘{‘.

>It automatically indents, but in this case I don’t actually want to indent (yes, there are reasons for wanting this).

>I just press backspace once. Good luck in 4 space land.

Just, in general, what I like about tabs is that it automatically delineates nesting very easily when editing, and it saves on key spaces. If I forget how deeply nested I am, I can see the number of tabs in the beginning, I don’t have to count spaces and divide by 4. There are times where I want to go not just to the beginning of the line, but to a specific nesting number (for example, if I decide to close a loop or tag or what-have-you).

Those of you who use 4 spaces: fucking how? Do you never nest or use loops in your code ever? Are you so obsessed with coding smells that you refuse to nest or something; is that how you deal with the inefficiency? Do you have some crazy assembly of auxiliary code that essentially makes 4 spaces act like tabs(*)? How do you live with yourselves at night? Do you really love your wife’s son, or do you just deal with him?

(*) The only piece of auxiliary code I have is one that changes 4 spaces to tabs while I’m editing, and back to spaces before I save the code again. So I don’t run into these minor irritations while coding.

 No.1022584>>1022661

8 spaces. Using tabs is the equivalent of using a font that isn't monospaced for coding.

<b-b-but muh poor ugandan editor can't handle that

Did you ever think of using a better editor?


 No.1022585>>1022661 >>1022678

If your editor can't format spaced code in current year it's time for an upgrade. There is literally no reason for tabs to even exist.


 No.1022605

>typing all that shit over muh tabs

no1curr

take your meds


 No.1022661>>1022662 >>1022687 >>1023925

>>1022584

>>1022585

The same argument Java programmers will use to defend their OOP disaster; the editor will suggest and autocomplete things for you, "the editor will fix it".


 No.1022662

>>1022661

There is actually nothing wrong with autocompletion / suggestions. If I could I would have my editor generate my whole program for me.


 No.1022672

>>1022580 (OP)

Use four spaces if you are autistic about your code looking the same on everyone's screen. Use tabs if you are autistic about semantics of indentation.

Personally I prefer tabs for indentation and spaces for alignment. That way anyone can set up the tab width to whatever they want and it will look good. With that said, it also depends on the language. Python uses indentation for delimiting code blocks, so using only spaces ensures that the code won't break. Lisp has no indentation, only alignment, so I use only spaces there as well. In HTML/XML I use tabs with a tab width of two characters.


 No.1022678

>>1022585

>There is literally no reason for tabs to even exist.

>Unicode smiley faces are okay but the primary adjustable indent character has no reason to exist

Sure.


 No.1022687

>>1022661

You must hate Lisp too, then. Because Lisp without an editor indenting and showing you the matching bracket is hell.


 No.1022713>>1022998

>move to a new system without all my configs

:set sts=4 sw=4 et ai

Not hard to remember

>Do you have some crazy assembly of auxiliary code that essentially makes 4 spaces act like tabs

Yep. Its called vim. Check it out if you get the chance

>why use spaces then

Tabs are for tables. In that context, they need to be (at least) eight chars. Indents should only be 4 chars, so they need to use a different character.


 No.1022998

>>1022713

>they need to be (at least) eight chars

Wrong, they're 4 chars by default and of changable length if your editor doesn't suck.


 No.1023925

>>1022661

It's pretty comfy writing Java in Intellij IDEA; they write half of your program for you.




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
11 replies | 0 images | Page ?
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / animu / asmr / cafechan / egy / leftpol / miku / vg / zoo ][ watchlist ]