Page 2 of 4
Posted: Fri Aug 10, 2007 2:27 pm
by superdezign
AKA Panama Jack wrote:This is by far the BEST way to enter functions because it is much easier to visually match beginning and ending brackets.
I didn't even notice that this is what they were referring to. I always match brackets, and I even put brackets on statements that only execute one line of code. It may take more space, but it's more organized, IMO.
Posted: Fri Aug 10, 2007 5:32 pm
by Christopher
astions wrote:Tabs are the work of the Devil. If I was god I would abolish them into the depths of nothingness. They are useless placeholders destined to be replaced with spaces.
astions wrote:But the files are different. They should show as different.
The files are different when you compare the whitespace. But because (besides Python) most languages are whitespace independent it does not matter to PHP.
If anything, I would think the infinitesimal time it takes to parse over all those extra space characters rather than the far fewer tabs would make a man of your passionate opinions pro-tab!
Posted: Fri Aug 10, 2007 5:35 pm
by Benjamin
I became annoyed with tabs when my code would get misaligned from one editor to another. That never happens with spaces, so my code is still pretty

Posted: Fri Aug 10, 2007 5:37 pm
by Christopher
AKA Panama Jack wrote:
This is by far the BEST way to enter functions because it is much easier to visually match beginning and ending brackets.
The counter argument I have heard to this is that because modern editors will show bracket errors that never using one true brace is more consistent shows more program lines per page -- which is an essential goal of that style.
FYI - that opening brace style was because in C you declared parameters between the function declaration line and the code block, so the opening code brace lined up with those declarations. Languages like PHP put the parameter declaration in the function declaration line so the one true brace is no longer needed.
Posted: Fri Aug 10, 2007 5:46 pm
by Christopher
astions wrote:I became annoyed with tabs when my code would get misaligned from one editor to another. That never happens with spaces, so my code is still pretty

Yup, that's the reason to use spaces. It is often a good practice on teams that use different editors, as well as large public projects. However if the team can configure their editors to translate, or have the CVS to it for them, then it can become a non-issue. I have worked on teams where each programmer checked out code with their own preference. Releases were pretty-printed to some agreed upon target.
Posted: Fri Aug 10, 2007 5:59 pm
by Benjamin
arborint wrote:I have worked on teams where each programmer checked out code with their own preference. Releases were pretty-printed to some agreed upon target.
That sounds like a pretty cool way to do it. I find myself going through others code and indenting it properly. I don't know if it makes the other guys mad or not but they never say anything about it lol.
Posted: Fri Aug 10, 2007 6:06 pm
by Christopher
astions wrote:That sounds like a pretty cool way to do it. I find myself going through others code and indenting it properly. I don't know if it makes the other guys mad or not but they never say anything about it lol.
I should have to clean up all my code. What I do is probably anathema to you -- I don't care much if the indenting is a little off so I just leave it however it is ...
Posted: Fri Aug 10, 2007 6:32 pm
by s.dot
superdezign wrote:AKA Panama Jack wrote:This is by far the BEST way to enter functions because it is much easier to visually match beginning and ending brackets.
I didn't even notice that this is what they were referring to. I always match brackets, and I even put brackets on statements that only execute one line of code. It may take more space, but it's more organized, IMO.
That would be the Zend standard way. Always brackets. Always. =] I like it that way. I like the function brackets.. but not so much the if ()'s.
Posted: Fri Aug 10, 2007 6:34 pm
by AKA Panama Jack
astions wrote:I became annoyed with tabs when my code would get misaligned from one editor to another. That never happens with spaces, so my code is still pretty

That is an editor problem and not a coding problem. I have tried many different editors before sticking with UEStudio and every one of them would cut and paste tabs perfectly if you disabled the "TABS as SPACES" feature if the editor has it.
Personally, I found far more problems with misaligned cut and paste code when programmers used SPACES instead of TABS because it seems like every programmer has a different definition of how many spaces it takes to make a tab. If you use TABS then they will ALWAYS be the right distance when you cut and paste between applications.
Posted: Fri Aug 10, 2007 6:38 pm
by AKA Panama Jack
arborint wrote:AKA Panama Jack wrote:
This is by far the BEST way to enter functions because it is much easier to visually match beginning and ending brackets.
The counter argument I have heard to this is that because modern editors will show bracket errors that never using one true brace is more consistent shows more program lines per page -- which is an essential goal of that style.
I have heard that too and find it an annoying argument.
Most modern editors will do automatic bracket matching. I use UEStudio and it does that as well but I like being able to LOOK at program code and tell at a glance where bracketed code blocks are instead of moving the cursor to each bracket to see the corresponding bracket highlighted. The latter is time consuming and less efficient.
Posted: Fri Aug 10, 2007 6:41 pm
by Benjamin
@arborint: The main reason why I go through and indent the code is because I can process the code and know where I am in the flow without having to actually read the code. This makes it much faster and easier for me to zero in on the part I want to modify. When it's not indented I have to read the code instead of just the if/while/foreach statements. Also, it's amazing how many undiscovered bugs I have found by doing this.
@aka: Are you a windows fan? I would venture to guess that most Linux guys probably prefer spaces, while most windows guys prefer tabs.
Posted: Fri Aug 10, 2007 6:59 pm
by AKA Panama Jack
I prefer Linux for servers as it is better suited for that task.
I don't care for Windows but I use it because I have to use it if I want to use certain applications and games. Yes, games also play as bit a part as applications. Linux is getting there but way too slowly for my tastes. Until entertainment companies start including Linux versions by default in all of their releases I doubt that I will be switching anytime soon.
Posted: Sat Aug 11, 2007 12:03 am
by The Phoenix
arborint wrote:The counter argument I have heard to this is that because modern editors will show bracket errors that never using one true brace is more consistent shows more program lines per page -- which is an essential goal of that style.
To which I say, welcome to the world of 20"+ monitors, dual monitors, zooming text, and IDE's that do code folding. I'm not a fan of modern IDE's, but the whole "I can see more on one page" line seems more and more laughable as monitors get larger than windshields..
AKA Panama Jack wrote:
Any Diff programm worth it's salt will basically ignore leading spaces and tabs that are outside quotes when comparing file code. If it doesn't then that DIFF program has a really bad problem. I have one called Free Diff that only compares actual code differences which is what a Diff program should do.
A rephrase could be that there are some diff programs that offer the ability to ignore whitespace differences. But by default almost every one of the unix standard diff (for the last twenty YEARS mind you) has indeed seen tabs as different than spaces.
Because they are.
But yes, you can get an editor that converts tabs to spaces. And yes, you can get a diff program that ignores tabs v. spaces, and you can also even use a program to prettify the formatting before committing. But in the end, all of those give you workarounds to the main problem - inconsistencies between programmers.
AKA Panama Jack wrote:it seems like every programmer has a different definition of how many spaces it takes to make a tab
Which is why we have coding standards.

By saying "no tabs at all", that issue is entirely eliminated.
Posted: Sat Aug 11, 2007 12:49 am
by AKA Panama Jack
The Phoenix wrote:AKA Panama Jack wrote:it seems like every programmer has a different definition of how many spaces it takes to make a tab
Which is why we have coding standards.

By saying "no tabs at all", that issue is entirely eliminated.
Couldn't be more wrong on that because you will find different people claiming coding standards that use spaces instead of tabs have different idea as to what is the proper number of spaces to use in place of tabs.
You see tabs were created for a REASON way back in the old typewriter days and refined with computers. Tabs have a built in STANDARD for width so if you use a tab in one editor it will show properly in another program unlike spaces. Just about every major or decent editor that offers the ability to use tabs instead of spaces allows the number of spaces per tab to be set by the user. And you will find that not all editors have the same default number of spaces to represent a tab.
If any programmer wants to have display consistency they would never use spaces but stick with tabs as tabs because the display will always be the same no matter what editor they use. Even Linux editors support tabs as tabs. You would probably have to really dig to find a modern editor, even on Linux, that doesn't display tabs properly as tabs.
Posted: Sat Aug 11, 2007 12:51 am
by Benjamin
@aka, I think your totally right about how tabs have a set width. But isn't that related to document formating? As in for print? I think code is a bit different.