Discuss Scratch

gosoccerboy5
Scratcher
1000+ posts

Tabs vs spaces

The ultimate battle. Which one do you prefer?
I'm a spaces guy.
-Accio-
Scratcher
1000+ posts

Tabs vs spaces

Tabs. More distinct difference and if you don't have an auto indent editor, it is easier to press tab once than space 2/4 times. Same with backspacing. I would rather backspace one tab than 2/4 spaces.
dhuls
Scratcher
1000+ posts

Tabs vs spaces

-Accio- wrote:

Tabs. More distinct difference and if you don't have an auto indent editor, it is easier to press tab once than space 2/4 times. Same with backspacing. I would rather backspace one tab than 2/4 spaces.
I completely agree with this.
Steve0Greatness
Scratcher
1000+ posts

Tabs vs spaces

I only use space, when I'm trying out a new software that lets me make html(or any text document… yes html is text), and it doesn't let me use tab.
Space is bad and I turned off tab to space in the Chrome OS text app

Last edited by Steve0Greatness (May 28, 2021 03:35:47)

fdreerf
Scratcher
1000+ posts

Tabs vs spaces

None. I write all my code in Microsoft Word with center justification.
Sheep_maker
Scratcher
1000+ posts

Tabs vs spaces

I think the main benefit of tabs is that it lets you customise its width, kind of like dark theme/light theme. Tabs for indentation, spaces for alignment.

-Accio- wrote:

Tabs. More distinct difference and if you don't have an auto indent editor, it is easier to press tab once than space 2/4 times. Same with backspacing. I would rather backspace one tab than 2/4 spaces.
Perhaps, though I feel like most editors that insert a tab character when you press tab also support space indentations.
Chiroyce
Scratcher
1000+ posts

Tabs vs spaces

Tab

fdreerf wrote:

None. I write all my code in Microsoft Word with center justification.
That's for HTML! What about JS or Python?

Last edited by Chiroyce (May 28, 2021 06:34:17)

linearlemur
Scratcher
500+ posts

Tabs vs spaces

Spaces. For me, the tab button is located at a really awkward spot on the keyboard, and I'm much more used to spaces. Also, it's easier to type a button multiple times quickly than one button slowly.
wvj
Scratcher
1000+ posts

Tabs vs spaces

spaces
gosoccerboy5
Scratcher
1000+ posts

Tabs vs spaces

Soft tabs allow you the benefit of tabs with the flexibility of spaces
gdpr5b78aa4361827f5c2a08d700
Scratcher
1000+ posts

Tabs vs spaces

i only indent my code using ඞ
Sheep_maker
Scratcher
1000+ posts

Tabs vs spaces

linearlemur wrote:

Spaces. For me, the tab button is located at a really awkward spot on the keyboard, and I'm much more used to spaces. Also, it's easier to type a button multiple times quickly than one button slowly.
Wait—you prefer manually typing out each space? o_O

potatophant wrote:

i only indent my code using ඞ
Hmm, I wonder which languages ignore ඞ as whitespace or a comment. BrainF is one of them—characters outside its 8 character set are ignored—and perhaps HTML if you use a font that makes ඞ invisible

More languages allow ඞ in their variable names, though:
(define  'amogus)
let  = 'amogus'
.::after { content: 'amogus' }
imfh
Scratcher
1000+ posts

Tabs vs spaces

I prefer spaces, because it is the Python standard. Most modern code editors support making them act like tabs in regards to the tab key and backspace, so I don’t see that as a problem.

Although it is nice that tabs can be customized with themes, I don’t really see that as much of an advantage either. I prefer a standard 4 space size, and it seems the vast majority of people who publish code do too. If someone prefers a different size, they can always convert my spaces to tabs later.

One advantage of using spaces is that your indents don’t all have to be the same size. If you use tabs, you have to use a combination of tabs+spaces to get specific indent position, which not only doesn’t seem like good practice (mixing whitespace), it is also a big no no for Python (throws an error in Python 3).

Here’s a couple snippets of actual code I wrote which use varying indents using spaces.

See how spaces are used to line up self.color.b with self.color.r (there are 29 spaces before self.color.b)
        pen.color = pg.Color(self.color.r, self.color.g,
                             self.color.b, self.color.a)
Also, here's a mess I found when I was looking for an example. It has custom spacing in front of the for loop. Can anyone tell what it does out of context like this?
            blockmap['code'] = "async def " + clean_identifier(
                "cb_" + mutation['proccode']) + "(self, util, " +\
                ', '.join(clean_identifier("arg_" + arg)
                          for arg in json.loads(mutation['argumentnames'])) +\
                "):\n{SUBSTACK}"
Here's the regex I used to find these if anyone wants to check their code to see if they've used custom spacing somewhere.
\n( {4})+? {1,3}\S
NormalMaker
Scratcher
500+ posts

Tabs vs spaces

For the purpose of indenting, tab, because the only time I need to indent things is when I'm making trashy programs in python for school, which doesn't require specific amounts of indentation, and there's no reason to press space 4 times when I could press a button that's right above a button that I use every 5th line.
mybearworld
Scratcher
1000+ posts

Tabs vs spaces

Only spaces. Python automatically uses spaces, so I'm way more used to just tapping space 4 times (and in JS I just use 1 space)

Last edited by mybearworld (May 29, 2021 13:25:10)

gosoccerboy5
Scratcher
1000+ posts

Tabs vs spaces

NormalMaker wrote:

For the purpose of indenting, tab, because the only time I need to indent things is when I'm making trashy programs in python for school, which doesn't require specific amounts of indentation, and there's no reason to press space 4 times when I could press a button that's right above a button that I use every 5th line.
Modern code editors will automatically indent on a newline based on the previous line..
imfh
Scratcher
1000+ posts

Tabs vs spaces

mybearworld wrote:

Only spaces. Python automatically uses spaces, so I'm way more used to just tapping space 4 times (and in JS I just use 1 space)
The pain of seeing so many people who don’t know how to set their editor to insert 4 spaces when you hit tab. Please do yourself a favor and figure out how to set that up.
mybearworld
Scratcher
1000+ posts

Tabs vs spaces

imfh wrote:

[View post]

mybearworld wrote:

Only spaces. Python automatically uses spaces, so I'm way more used to just tapping space 4 times (and in JS I just use 1 space)
The pain of seeing so many people who don’t know how to set their editor to insert 4 spaces when you hit tab. Please do yourself a favor and figure out how to set that up.
I guess I could see if I find that in IDLE, but I don't think you can do that in Notepad (for JS)-
Edit: IDLE actually already does that, I still prefer spaces.

Last edited by mybearworld (May 29, 2021 13:40:20)

Maximouse
Scratcher
1000+ posts

Tabs vs spaces

mybearworld wrote:

I guess I could see if I find that in IDLE, but I don't think you can do that in Notepad (for JS)-
Install an actual code editor instead of using Notepad.

I thought IDLE replaces tabs with spaces by default?
Edit: It does, and it isn't even possible to disable that.

Last edited by Maximouse (May 29, 2021 13:40:46)

mybearworld
Scratcher
1000+ posts

Tabs vs spaces

Maximouse wrote:

[View post]

mybearworld wrote:

I guess I could see if I find that in IDLE, but I don't think you can do that in Notepad (for JS)-
Install an actual code editor instead of using Notepad.

I thought IDLE replaces tabs with spaces by default?
It does, I just didn't care for the “tab” button enough to notice that.
Also why would I install a code editor? Notepad works fine.

Last edited by mybearworld (May 29, 2021 13:41:52)

Powered by DjangoBB