Goombert
|
|
Posted on: July 20, 2014, 03:07:56 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Well I recently provoked IsmAvatar on GitHub about two spaced indentations in which she raised some interesting counter arguments. https://github.com/IsmAvatar/LateralGM/pull/128I also recently updated the coding techniques article to address this. http://enigma-dev.org/docs/Wiki/Coding_conventionsAnybody with a GitHub account respond there, otherwise respond here.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
|
edsquare
|
|
Reply #2 Posted on: July 20, 2014, 03:46:21 pm |
|
|
Location: The throne of ringworld Joined: Apr 2014
Posts: 402
|
Tabs are pretty much superior in every way, but because mixing tabs and spaces is painful everyone seems to have standardized on spaces. Unfortunately.
So true.
|
|
|
Logged
|
A child of five would understand this. Send someone to fetch a child of five. Groucho Marx
|
|
|
|
Josh @ Dreamland
|
|
Reply #4 Posted on: July 20, 2014, 09:44:22 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
My aversion to tabs is that they have not been assigned a logical width. People individually choose how big they want their tabs. While that's great for personalization, it's bad for consistency. You can't align variables easily, or use half-indentations or double-indentations without explosion (my double is 4 spaces; some are 16). The biggest offender is when people try to line up variables after "int" or "var." It's not really my style, but it happens; exactly four spaces of indent are required to pad the next line so that all the identifiers line up. You can use spaces to do exclusively the non-indentation alignment, of course, assuming your editor lets you, but I've never seen anyone pull that off.
The lack of size agreement leads to more solid problems, in my case. GNU style seems to be two-space indent, but any leading eight spaces of indent are replaced with a single tab character. This means for me to correctly view anything GNU, I have to set my tab width to eight. My preferred tab width is two. When you send me a file and every fucking line is indented eight tabs, I flip shit. I find lately that I leave my tab widths both at two and manually replace "\t" with " " in GNU sources.
So yes, in a perfect world, everyone agrees, and we all use tabs. In this world, tabs are any multiple of 1 in size (even that's not playing it safe—some people don't use fixed-width editors, but no one cares what they think). Spaces, however, I have never noticed to be rendered as anything other than a single space of width, with or without special coloring or symbolage to denote that there's actually a character there. So I use two spaces, and my code looks the same whether it's loaded in emacs, in vim, in MS fucking Notepad, or in an actual code editor.
inb4 gr8 b8 m8
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
edsquare
|
|
Reply #5 Posted on: July 20, 2014, 10:12:31 pm |
|
|
Location: The throne of ringworld Joined: Apr 2014
Posts: 402
|
My aversion to tabs is that they have not been assigned a logical width. People individually choose how big they want their tabs. While that's great for personalization, it's bad for consistency. You can't align variables easily, or use half-indentations or double-indentations without explosion (my double is 4 spaces; some are 16). The biggest offender is when people try to line up variables after "int" or "var." It's not really my style, but it happens; exactly four spaces of indent are required to pad the next line so that all the identifiers line up. You can use spaces to do exclusively the non-indentation alignment, of course, assuming your editor lets you, but I've never seen anyone pull that off.
The lack of size agreement leads to more solid problems, in my case. GNU style seems to be two-space indent, but any leading eight spaces of indent are replaced with a single tab character. This means for me to correctly view anything GNU, I have to set my tab width to eight. My preferred tab width is two. When you send me a file and every fucking line is indented eight tabs, I flip shit. I find lately that I leave my tab widths both at two and manually replace "\t" with " " in GNU sources.
So yes, in a perfect world, everyone agrees, and we all use tabs. In this world, tabs are any multiple of 1 in size (even that's not playing it safe—some people don't use fixed-width editors, but no one cares what they think). Spaces, however, I have never noticed to be rendered as anything other than a single space of width, with or without special coloring or symbolage to denote that there's actually a character there. So I use two spaces, and my code looks the same whether it's loaded in emacs, in vim, in MS fucking Notepad, or in an actual code editor.
inb4 gr8 b8 m8
Yea I have seen code indented like the one that wrote it had a 40" monitor I didn't know it could happen when you indent with tabs on windows I assume, and then open it on linux. If this is for Enigma's code editor then you could go the SPE (Stany's Python Editor) and force the size of the tabs to two spaces only and always, when you indent you can use either spaces or tabs, since it converts the tabs to two spaces automatically.
|
|
|
Logged
|
A child of five would understand this. Send someone to fetch a child of five. Groucho Marx
|
|
|
Rusky
|
|
Reply #6 Posted on: July 20, 2014, 10:58:08 pm |
|
|
Joined: Feb 2008
Posts: 954
|
Aligning variables and half/double-indentation are not useful. There are a few patterns in common use that make tabs ugly, but they're easy to get around:
Instead of this:function_call(foo, bar, baz) which still pushes code far to the right anyway while you were trying to avoid long lines, I do this:function_call( foo, bar, baz ) If you really want you could put the parenthesis on the line with the last argument, but this way it matches how you use {}s and lets you move arguments without grabbing the closing parenthesis. Same pattern applies to function declarations, large expressions in control structures, etc:
if ( do_something_really_long && split_up_over_multiple_lines || ( with_sub_expressions ) ) { stuff }
|
|
|
Logged
|
|
|
|
Goombert
|
|
Reply #7 Posted on: July 21, 2014, 12:08:26 am |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
For all the reasons Josh stated is why I agree with him ceteris paribus, the very fact that it opens the same everywhere is the reason it is standard in my opinion because it makes it universal. And ironically there is a code beautifier by this name. http://universalindent.sourceforge.net/Also apparently Wikipedia has this all documented. https://en.wikipedia.org/wiki/Indent_style#GNU_styleI would just prefer we all use the same indentation style, so that everything opens properly on GNU as well. I get sick of opening up source files either I or someone else edited and the formatting being all wrong, so I asked Josh and he told me to switch to 2 space, and I prefer it because of the universality so I would prefer we just all use that.
|
|
« Last Edit: July 21, 2014, 12:12:22 am by Robert B Colton »
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
edsquare
|
|
Reply #8 Posted on: July 21, 2014, 12:50:06 am |
|
|
Location: The throne of ringworld Joined: Apr 2014
Posts: 402
|
For all the reasons Josh stated is why I agree with him ceteris paribus, the very fact that it opens the same everywhere is the reason it is standard in my opinion because it makes it universal.
And ironically there is a code beautifier by this name. http://universalindent.sourceforge.net/
Also apparently Wikipedia has this all documented. https://en.wikipedia.org/wiki/Indent_style#GNU_style
I would just prefer we all use the same indentation style, so that everything opens properly on GNU as well. I get sick of opening up source files either I or someone else edited and the formatting being all wrong, so I asked Josh and he told me to switch to 2 space, and I prefer it because of the universality so I would prefer we just all use that.
Not sure if I understood correctly, but you mean two spaces for every level or not?
|
|
|
Logged
|
A child of five would understand this. Send someone to fetch a child of five. Groucho Marx
|
|
|
Goombert
|
|
Reply #9 Posted on: July 21, 2014, 02:44:59 am |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
I'm not sure, what I mean is you press tab and the selected text is indented two spaces.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
TheExDeus
|
|
Reply #10 Posted on: July 21, 2014, 04:55:47 am |
|
|
Joined: Apr 2008
Posts: 1860
|
I also like tabs a lot. I don't get the "width" issue though, because it doesn't matter if a tab is 1cm or 5cm. The code will still be indented properly. So I haven't had any problems with that, but I rarely use linux, so I don't know if they have problems there or now. I haven't had any problems in Code::Blocks, Notepad++, VS and Wordpad. Works flawlessly everywhere. So it's seems to be a linux issue. edit: I personally use https://en.wikipedia.org/wiki/Indent_style#Kernel_style and https://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS . More the 1TBS.
|
|
« Last Edit: July 21, 2014, 05:00:49 am by TheExDeus »
|
Logged
|
|
|
|
|
edsquare
|
|
Reply #12 Posted on: July 21, 2014, 11:06:23 am |
|
|
Location: The throne of ringworld Joined: Apr 2014
Posts: 402
|
I'm not sure, what I mean is you press tab and the selected text is indented two spaces.
Now I understand, that is what I proposed when said you could imitate SPE, that is exactly what that IDE does.
|
|
|
Logged
|
A child of five would understand this. Send someone to fetch a child of five. Groucho Marx
|
|
|
|
|
|