In HTML specifically, many sites I view the source of sometimes tend to be the same: the coder indents things using spaces and not tabs.
First of all: using spaces instead of tabs DOESN'T make your file size's smaller. In fact it does the opposite. One space = one byte. One TAB = one byte. They're equal. However, nobody who does tabs with spaces stops at one space. They usually use 3 or 5 spaces. Now, 3 spaces = 3 bytes as opposed to 1 tab = 1 byte.
So using spaces instead of tabs makes your source's white spaces become 3 times as large. Or if you use 5 spaces instead of a tab, 5 times as large.
Advantages/Disadvantages to Spaces + Sure it makes your source smaller, but who cares? - It makes your file size larger than with tabs. + You can indent to more levels without getting horizontal scrollbar. - Hard to make changes (i.e. to move one far-indented block of text a level closer, you have to hit delete many times for all the spaces as opposed to just a couple for tabs)
Advantages/Disadvantages to Tabs + Makes your file size smaller - Makes your source longer to read but who cares? + Easy to make changes (see above) - Can only indent so many levels before horizontal scrollbar shows up
There's more obvious pros and cons on either side, but using tabs rather than spaces is more efficient (this is mostly referring to HTML, since programming languages lose all their excess space on compilation anyway). _________________ Current Site (2008) http://www.cuvou.com/
Joined: 27 Jan 2005 Posts: 109 Location: Lewiston, ME
Posted: Sat Jun 04, 2005 12:24 am Post subject:
QUOTE(Cer @ Jun 3 2005, 03:08 PM)
Advantages/Disadvantages to Spaces - Hard to make changes (i.e. to move one far-indented block of text a level closer, you have to hit delete many times for all the spaces as opposed to just a couple for tabs)
Advantages/Disadvantages to Tabs + Easy to make changes (see above) - Can only indent so many levels before horizontal scrollbar shows up
many programs allow you to tab with spaces, ie. when you hit tab it inserts 5 spaces (or however many you have it set too..)
Joined: 06 Jan 2004 Posts: 562 Location: Netherlands
Posted: Sat Jun 04, 2005 1:01 pm Post subject:
Quote:
So using spaces instead of tabs makes your source's white spaces become 3 times as large. Or if you use 5 spaces instead of a tab, 5 times as large.
That's a very quick conclusion. I could also state, if you don't intend your file size will become X times smaller! Wow! Let's all not use intending at all!
It doens't matter WHAT you use, as long as it is readable. Many [good] editors automatically convert spaces to tabs or vice versa automatically or with some option. There are also some good editors out there which have the option to select a block of code and click "intend" or "unintend" and it does the work for you.. No backspaces!
Even more so, tabs don't work on IPB, unfortunatly. Ever tried it? I think darkmonkey is refering to that. Spaces so fine, tabs don't, a horrible pain the *annoying*. Luckaly theres always the search & replace (or auto-intend option) in editors.
In the end it doesn't matter whether you use spaces or tabs.. As long as the code is readable and maintainable. Likewise it doesn't matter whether you use if(!..) or just unless(...). It both does the same thing.
Plus, personally, if I post something, I convert it to spaces. Why? Because spaces have a fixed length, whereas tabs depend highly on the font/font size used. In my code I always use tabs because I'm too lazy for spaces.
Joined: 19 Jul 2004 Posts: 556 Location: Los Angeles, CA votes: 1
Posted: Mon Jun 06, 2005 4:20 pm Post subject:
A tab in NOT usually one character...it actually depends on what your tab spacing is set to in the editor your using. For example in the Perl editor i use i ran a simple test:
Code:
print length(" ");
by pressing tab between the quotes.... it printed 7 so that would be 7 bits added to the code..when i could have indented with 3 and had the same effect. _________________ [ matt ]
Joined: 27 Jan 2005 Posts: 109 Location: Lewiston, ME
Posted: Mon Jun 06, 2005 4:25 pm Post subject:
for my own site I write html in paragraph form. Its so much easier to find something in particular that way. It may not be as readable to someone else, but I know what each paragraph represents.