Tabs vs Spaces

User avatar
joe7575
Member
 
Posts: 344
Joined: Mon Apr 24, 2017 20:38
Location: Germany, in the deep south
GitHub: joe7575
In-game: JoSto

Tabs vs Spaces

by joe7575 » Tue Oct 03, 2017 16:32

Why shall tabs be used for indentation instead of spaces?
Tabs are a mess, the code looks horrible, if you use different editor settings.

The Minetest developer Wiki says that "...this is largely based on the Python style guide".
But the Python style guide and many other prefer spaces:
https://www.python.org/dev/peps/pep-000 ... -or-spaces

/Joe
Sent from my Commodore 64. My Mods: TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Entrance, Minecart, Signs Bot.
 

User avatar
rubenwardy
Moderator
 
Posts: 6012
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Tabs vs Spaces

by rubenwardy » Tue Oct 03, 2017 16:37

Real answer: it's the preference of celeron55, the founder.


My answer: it makes it impossible to half-indent something, and allows people to choose which indentation to use. You're just not used to different indent sizes which is why it looks "horrible".

Python really should use tabs being a whitespace dependent language. Largely-based doesn't mean entirely based. Note that the style guide is only for the official repos (minetest and minetest_game) you can use whatever style you like for your own mods :)
 

User avatar
Krock
Developer
 
Posts: 4475
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: Tabs vs Spaces

by Krock » Tue Oct 03, 2017 16:53

The code looks horrible when you use tabs the wrong way, like here, here or here.

Tabs should ALWAYS be used as indents for the beginning of a line. All acceptable editors allow changing the size of a tab, so that the developer can work with their preferred settings.
It also ensures that you don't mess up the amount of indents. After the first character of the actual code is written, tabs should no longer be used, as it results in a visual disaster (first example above) when working with different tab sizes.

Honestly I can't understand why some programming languages and IDEs insist on or default to spaces.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 

sofar
Developer
 
Posts: 2124
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Tabs vs Spaces

by sofar » Tue Oct 03, 2017 17:35

In Open Source, you adhere to the style of the existing code in the project. If the code uses tabs, you use tabs, if it uses spaces, you use spaces.

Whatever there is stated in style guides is probably irrelevant, just like Python is largely irrelevant, since there is not a fricken single line of python code in Minetest. It was also just copied without thinking by someone, so again, irrelevant.

Lua and C++ style rules for MTG and MT are pretty consistent, though, just review most of the recent PRs and you'll see that even absent clear rules they are applied consistently by most if not all the devs.
 

User avatar
joe7575
Member
 
Posts: 344
Joined: Mon Apr 24, 2017 20:38
Location: Germany, in the deep south
GitHub: joe7575
In-game: JoSto

Re: Tabs vs Spaces

by joe7575 » Wed Oct 04, 2017 08:13

Thanks for your answers.
This is my favourite: "...you can use whatever style you like for your own mods" :D
/Joe
Sent from my Commodore 64. My Mods: TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Entrance, Minecart, Signs Bot.
 

User avatar
azekill_DIABLO
Member
 
Posts: 7494
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO
 

User avatar
joe7575
Member
 
Posts: 344
Joined: Mon Apr 24, 2017 20:38
Location: Germany, in the deep south
GitHub: joe7575
In-game: JoSto

Re: Tabs vs Spaces

by joe7575 » Sun Oct 08, 2017 15:00

I try to live with the tabs approach.
From my background, I was used to using spaces instead of tabs.
I was working on many projects in the last decades, in different languages for different customers and I can not remember a single time that tabs were required...
Sent from my Commodore 64. My Mods: TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Entrance, Minecart, Signs Bot.
 

User avatar
Linuxdirk
Member
 
Posts: 2419
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

Re: Tabs vs Spaces

by Linuxdirk » Mon Oct 09, 2017 06:27

Spaces everywhere. I know that tabs are more flexible (every modern editor can set tab width) but I still prefer spaces.
 

User avatar
azekill_DIABLO
Member
 
Posts: 7494
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Tabs vs Spaces

by azekill_DIABLO » Mon Oct 09, 2017 16:15

Linuxdirk wrote:Spaces everywhere. I know that tabs are more flexible (every modern editor can set tab width) but I still prefer spaces.

Image
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 1 guest

cron