Kitz ADSL Broadband Information
adsl spacer  
Support this site
Home Broadband ISPs Tech Routers Wiki Forum
 
     
   Compare ISP   Rate your ISP
 
Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1] 2

Author Topic: Spaces vs tabs for source code  (Read 1814 times)

sevenlayermuddle

  • Helpful
  • Kitizen
  • *
  • Posts: 3295
Spaces vs tabs for source code
« on: June 19, 2017, 02:33:04 PM »

I've always had strong opinions on this, with a dislike of tabs in source code.   Many of my colleagues used to agree.   Finally a justification...

http://www.bbc.co.uk/news/technology-40302410

 :)
Logged

roseway

  • Administrator
  • Senior Kitizen
  • *
  • Posts: 38756
  • Penguins CAN fly
    • DSLstats
Re: Spaces vs tabs for source code
« Reply #1 on: June 19, 2017, 04:11:21 PM »

It never even occurred to me that this was an issue. I've always used spaces personally, and if asked for justification I would say that spaces are universal - so long as you use a monospace font, spaces will always look the same, in any editor. I suppose that one possible reason for the higher salaries is that higher-paying commissioning companies tend to require spaces to be used.
Logged
  Eric

burakkucat

  • Global Moderator
  • Senior Kitizen
  • *
  • Posts: 20170
  • Over the Rainbow
    • The ELRepo Project
Re: Spaces vs tabs for source code
« Reply #2 on: June 19, 2017, 05:32:15 PM »

Hmm . . .

Now in my 40th-plus year of writing source-code, I have always used a tab (with the conversion factor of eight spaces to one tab).
« Last Edit: June 20, 2017, 05:35:55 PM by burakkucat »
Logged
:cat:  100% Linux and, previously, Unix. Co-founder of the ELRepo Project.

Please consider making a donation to support the running of this site.

adrianw

  • Member
  • **
  • Posts: 78
Re: Spaces vs tabs for source code
« Reply #3 on: June 19, 2017, 05:50:06 PM »

I actively wrote code for 48 years (gulp) and preferred spaces for any language that was usually indented to follow its structure.
Logged

sevenlayermuddle

  • Helpful
  • Kitizen
  • *
  • Posts: 3295
Re: Spaces vs tabs for source code
« Reply #4 on: June 19, 2017, 06:21:12 PM »

In the early days of my career I probably did use tabs, as it cut down down on file size.  In those days each module would generally have only one author, so he/she could choose their own coding style.   As long as it contained only tabs or spaces (not a combination) the code would still look neat to colleagues, except that the line length would differ if the viewer's tab stop preference differed from the author.

As time went by however, and modules became shared among multiple authors under shared source control a problem arose... some contributors would use spaces, some would use shorter tab stops, and some longer tab stops.  That led to source code that looked pretty for nobody, other than the small area that fitted on a screen area that had been edited by the last contributor. :(

That said, the only code I have written in the past 6 years has been using Apple Xcode IDE's built editor, which does a fine job of auto-indenting.   And do you know what, I have no idea whether it uses tabs or spaces. :-[

That said, the likelihood of anybody else ever needing to see my code is minimal, so maybe it is a return to days of old in a way.  :)

« Last Edit: June 19, 2017, 06:23:22 PM by sevenlayermuddle »
Logged

WWWombat

  • Kitizen
  • ****
  • Posts: 1637
Re: Spaces vs tabs for source code
« Reply #5 on: June 20, 2017, 10:33:16 AM »

I worked in an environment where we gradually moved from "one person, one module, one editor" toward something closer to a free-for-all anarchy. Part of QA always had a peer-review component, so it was imperative that everyone could follow other people's coding style, even before they then needed to work on it.

Nothing caused bigger problems than the tab-vs-space argument, especially when compounded by some people's desire to use a 4-space tab in their editor. Where to put the closing "}" bracket was a distant second place.

In the end, we learnt that the best answer was to force through a single coding style (for the complete code) that specified spaces. Editors could be used with the tab key, but set to an auto-indent mode that added space characters not tab characters, and aligned at 4-character intervals. This really helped everyone, from the smartest down to the weakest junior team members.

Like @7LM, the circle turned as integrated development environments became more capable. The problem of displaying indentation is then left to a smart editor.

The battle in the middle, it turned out, was really between a team taking collective responsibility for quality vs individual ego. And, in places, it was quite a battle.

How does that relate to the difference in salary? I wonder...

For a software organisation, there is nothing more important than the quality of your software, and the QA process you choose to follow.

In this context, then, perhaps that difference of salary is explained by how much of a team player you are, and how much emphasis you and your team collectively places on QA. Those who can subsume their ego into a best practice that is understood by everyone might just go further in the organisation, and get paid more.
Logged

Chrysalis

  • Content Team
  • Kitizen
  • *
  • Posts: 4996
Re: Spaces vs tabs for source code
« Reply #6 on: June 20, 2017, 11:56:12 PM »

Yeah I read the article and found funny.

I have always used tabs but I only write shell scripts not programs.
I also use tabs in config files.

The exception is if I am editing a script I didnt create or a config where spaces were already used and dont match the indent size of tabs, then I will use spaces.

Tabs just save so much time.
Logged
Sky Fiber Pro - Billion 8800NL bridge & PFSense BOX running PFSense 2.4 - ECI Cab

sevenlayermuddle

  • Helpful
  • Kitizen
  • *
  • Posts: 3295
Re: Spaces vs tabs for source code
« Reply #7 on: June 21, 2017, 06:19:29 PM »

The exception is if I am editing a script I didnt create or a config where spaces were already used and dont match the indent size of tabs, then I will use spaces.

Ah, but even if the indents are spaces that do match your own editor's tab stop, and so you use tabs, the next person to view or edit the file may have a different tab stop and will see wonky indents.

Regarding the alledged salary difference, I wonder if it might just be that those who favour spaces are more likely to have worked for multiple different employers, with multiple different ear bashings from new pedantic colleagues, until they finally gave in.   The point of switching jobs is often to get a pay rise, after all, so they might well skew the statistics. :)
Logged

Chrysalis

  • Content Team
  • Kitizen
  • *
  • Posts: 4996
Re: Spaces vs tabs for source code
« Reply #8 on: June 21, 2017, 06:42:36 PM »

its simple really, using spaces takes more time so as such they are worth more money.

I have had one guy who insisted on me using spaces, I did it but it cost him more money.

I accept the point on mismatched indent sizes, so any file shouldnt have mixed tabs and spaces.
Logged
Sky Fiber Pro - Billion 8800NL bridge & PFSense BOX running PFSense 2.4 - ECI Cab

WWWombat

  • Kitizen
  • ****
  • Posts: 1637
Re: Spaces vs tabs for source code
« Reply #9 on: June 21, 2017, 08:33:51 PM »

The concept of "saving money" seems to be restricted to the case where one person edits the code.

I found the biggest waste of my time (and hence the company's money) was when I had to sort out random indentation because there was a mix of tab and spaces from other people, who used different philosophies and different tab indents.

In the interim period, where you gained freedom of choice over the editor, I tended to use emacs set with auto-indent features on IIRC, and to use spaces rather than tabs: I hit the tab key once, it took me to the right place using spaces. A philosophy that seems to have moved over to IDE's.

There are uses for mixed tabs and spaces, though it might depend on your choice of language. There is a "Tabs are evil" page talking through philosophy.

Logged

tbailey2

  • Kitizen
  • ****
  • Posts: 1215
  • it's is its when it isn't it is. No 'could of'!
    • MyDSLWebStats
Re: Spaces vs tabs for source code
« Reply #10 on: June 26, 2017, 05:56:52 PM »

Just to be different, ever since I started programming back in ca 1979, I've always used real tabs set to TWO spaces in source code.

Purely because the first editor I ever used (can't remember what it was) used that as a default. It's also much better if you have nested indentations as the deeper ones are still visible and don't disappear off the right of the editor view...
« Last Edit: June 26, 2017, 08:17:03 PM by tbailey2 »
Logged
Tony [Admin MyDSLWebStats]
Upload & View your stats from anywhere MyDSLWebStats
My Books!
Plusnet 80/20 - DSLstats - HG612/TG582n - ECI

sevenlayermuddle

  • Helpful
  • Kitizen
  • *
  • Posts: 3295
Re: Spaces vs tabs for source code
« Reply #11 on: June 26, 2017, 07:23:44 PM »

@Tbailey2,

I am certainly in agreement on the merits of a smaller indent, regardless of the space vs tab debate.  Maybe you and I alike remember the days of crt monitors with fixed fonts and line width, and the challenge of keeping it all looking pretty within 80 chars, even with nested indents?

Since starting this thread though, I've been trying to search through my failing brain to the earliest days of my career.   Paid employment commenced with coding sheets & punched cards for which spaces vs tabs were irrelevant, then progressing to using a terminal editor for assembly language wherein, iirc, only a single indent was usually required... Labels started in column zero, commands didn't, no further beautification required. :)
Logged

lloyd

  • Reg Member
  • ***
  • Posts: 103
Re: Spaces vs tabs for source code
« Reply #12 on: June 27, 2017, 01:13:54 PM »

Those of us who wrote in Fortran 77 may well remember the need to put certain items in certain columns  - left over from punched cards:

columns 1-5     Label field
column 6         Continuation field
columns 7-72   Statement field
columns 73-80 Not to be used (card sequence field)

Logged

WWWombat

  • Kitizen
  • ****
  • Posts: 1637
Re: Spaces vs tabs for source code
« Reply #13 on: June 27, 2017, 05:56:02 PM »

One term of Fortran at university was enough, thank you very much. All memory of which was immediately wiped by a term of C.
Logged

burakkucat

  • Global Moderator
  • Senior Kitizen
  • *
  • Posts: 20170
  • Over the Rainbow
    • The ELRepo Project
Re: Spaces vs tabs for source code
« Reply #14 on: June 27, 2017, 11:20:10 PM »

Those of us who wrote in Fortran 77 may well remember the need to put certain items in certain columns  - left over from punched cards:

Similar to COBOL, I recall.

Many years ago I was employed as a COBOL programmer and I duly wrote precisely one COBOL program. Having then discovered C (pre any standard and when "the bible", K&R, started with Chapter 0) I then wrote in no other language. If the code required, at the hardware level, was too cumbersome I would then use native assembly language.
Logged
:cat:  100% Linux and, previously, Unix. Co-founder of the ELRepo Project.

Please consider making a donation to support the running of this site.
Pages: [1] 2
 

anything