Tabs or Spaces?

General discussion about LÖVE, Lua, game development, puns, and unicorns.

Tabs or Spaces?

Tabs
25
76%
Spaces
6
18%
Mix
2
6%
 
Total votes: 33

User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Tabs or Spaces?

Post by Jasoco »

ivan wrote:It's 2 spaces for me. Notepad++ has a setting that overwrites tabs with spaces automatically.
Another reason to use spaces is that tabs may be displayed differently by different editors.
Sounds like a personal choice. Personally I hate when I download a .love and the files use 2 spaces instead of a tab. The point is with tabs, they always use spaces. So if I press tab to add new text it'll match the rest. If I download your .lua file with 2 spaces per tab and mine is set to 4 spaces, it will not show up right.

Tabs are superior. Tabs are king. Tabs should not be denied. The first thing I'll do when I get a third party .lua file is convert the spaces to tabs. I've seen plenty of files with mixed usage that look wrong because people used unstandard 2 spaces per tab when tabs are generally always displayed at 4.

So my answer is tabs.
User avatar
Zilarrezko
Party member
Posts: 345
Joined: Mon Dec 10, 2012 5:50 am
Location: Oregon

Re: Tabs or Spaces?

Post by Zilarrezko »

Jasoco wrote:
ivan wrote:It's 2 spaces for me. Notepad++ has a setting that overwrites tabs with spaces automatically.
Another reason to use spaces is that tabs may be displayed differently by different editors.
Sounds like a personal choice. Personally I hate when I download a .love and the files use 2 spaces instead of a tab. The point is with tabs, they always use spaces. So if I press tab to add new text it'll match the rest. If I download your .lua file with 2 spaces per tab and mine is set to 4 spaces, it will not show up right.

Tabs are superior. Tabs are king. Tabs should not be denied. The first thing I'll do when I get a third party .lua file is convert the spaces to tabs. I've seen plenty of files with mixed usage that look wrong because people used unstandard 2 spaces per tab when tabs are generally always displayed at 4.

So my answer is tabs.
+1
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Tabs or Spaces?

Post by kikito »

Jasoco wrote: Sounds like a personal choice. Personally I hate when I download a .love and the files use 2 spaces instead of a tab. The point is with tabs, they always use spaces. So if I press tab to add new text it'll match the rest. If I download your .lua file with 2 spaces per tab and mine is set to 4 spaces, it will not show up right.
Since I have tab mapped to two spaces when opening Lua files, when I press tab in your tab-based file, it neither aligns (unless I convert tabs to spaces before, which I always do :) )
Jasoco wrote:Tabs are superior. Tabs are king. Tabs should not be denied.
Try not to get too attached to a particular indentation policy. Don't be "a tabs guy" or "a spaces guy". The truth is that each style has its merits.

Regarding indentation, some languages admit "whatever"(C, C++, Java). Those are the worst, because they create discussions like the one we're having now.

More civilized languages have indentation rules, or at least recommendations. Some recommend spaces (ruby, python), and others tabs (go).

When I am programming in a new language, I do what is "standard" in that language. So I use spaces when I do ruby, and tabs in Go. And I am happy that I didn't have to make the choice myself, and don't have to fight anyone about it, and I can move on writing code.
Jasoco wrote: unstandard 2 spaces per tab when tabs are generally always displayed at 4.
It depends on your definition of "standard". Lua's creators declined to explicitly say "the recommendation is using xxx for indentation". That, in my opinion, was a mistake, because now everyone has to "choose a camp" and "fight the other camp".

In my case, when I write Lua, I use two spaces, simply because that's what PIL does (I don't share Bartbes' opinion that that's because it is a book; even the C source code used in Lua is two-spaces-based). I didn't impose my personal preference, I actually tried to find an existing rule or recommendation, and that's the best I could find.

So no, in Lua, it is not "standard" to use tabs. Neither is using spaces. Although I think that there's a bit more implicit preference for them by the language's authors, and that's why I use them.
When I write def I mean function.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Tabs or Spaces?

Post by Robin »

Positive07 wrote:I use tab because:
  • Its just one keypress
  • I can delete it with a single keypress
  • Allows me to select lots of text and press tab once to indent it all (or shift tab to un-indent it)
I use spaces because:
  • Its just one keypress
  • I can delete it with a single keypress
  • Allows me to select lots of text and press tab once to indent it all (or shift tab to un-indent it)
---

Okay, which I use depends on several factors (like language, see kikito's post) and "discussions" like this one are silly and pointless. I just wanted to point out that those arguments were based on widely implemented editor features, not on the choice of tab vs space.

Please, /thread, for sanity's sake.
Help us help you: attach a .love.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Tabs or Spaces?

Post by Positive07 »

Ugh Robin always correcting me when I'm wrong! Hahaha

Well yeah as I said that is my point of view and my current configuration... I could make notepad++ replace tabs with spaces... but I dont like it. So yeah whichever you use is fine... this is a really pointless argument (but kinda fun, while everyone is peaceful, so dont start a fight over this)
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Tabs or Spaces?

Post by Robin »

Positive07 wrote:Ugh Robin always correcting me when I'm wrong! Hahaha
Nitpicking is my superpower. :P
Help us help you: attach a .love.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Tabs or Spaces?

Post by Positive07 »

Yeah! You and Bartbes are the super-villains of the love forum hahaha
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests