General / Off-Topic code indentation - tabs or spaces?

Back in the good(?) old days, indentation (along with anything else that might actually make a program readable, like only having one statement per line) was shunned, in the interests of making the darned thing run faster:

Loc_Bas.png



An example of Locomotive BASIC (for Amstrad CPCs) I've just found at random, to illustrate the way we used to do things. Careful scrutiny of the code reveals this little gem of 'structured programming':

230 ...FOR n=1 TO 10:IF n>3 AND n<8 THEN 250
240 LOCATE citypos(n),25: PRINT"[]";
250 NEXT...

(THEN 250' is shorthand for 'THEN GOTO 250'). Why write two for-next loops to do something, when you can replace them with a single one that does the same thing, and as a bonus does nothing at all for the hell of it...
 
Last edited:
3. Always comment out old code (never delete unless major version update)

revision systems are for that. do not leave dead or irrelevant code around. be tidy, man! :p

besides, if your comments start with "start of" or "end of", chances are they are irrelevant too. do not document 'what' or 'how', document 'why'. 'what' and 'how' are already in the code and folks already know how to read code, so don't clutter it up (and if they don't, they shouldn't be touching it) :D
 
4 spaces per indent I use, no tabs.

I hate mixing because if your editor isn't setup the same as the "mixer" the code can look a mess.

Tabs and spaces mixed in python is my favourite ;)
 
We mostly use python, so it's auto-conversion of tabs to spaces all the way. Oh, and cuddly braces ofc... have to spread the love. :)
 
Allman for me (I used to use write in Pascal / Delphi).

I come from Amiga and DOS where code file size was important and each new line was one or two bytes extra so it was K&R lol.


Back in the good(?) old days, indentation (along with anything else that might actually make a program readable, like only having one statement per line) was shunned, in the interests of making the darned thing run faster:

https://s9.postimg.org/p7vendtnz/Loc_Bas.png


An example of Locomotive BASIC (for Amstrad CPCs) I've just found at random, to illustrate the way we used to do things. Careful scrutiny of the code reveals this little gem of 'structured programming':

230 ...FOR n=1 TO 10:IF n>3 AND n<8 THEN 250
240 LOCATE citypos(n),25: PRINT"[]";
250 NEXT...

(THEN 250' is shorthand for 'THEN GOTO 250'). Why write two for-next loops to do something, when you can replace them with a single one that does the same thing, and as a bonus does nothing at all for the hell of it...

Ah yes the old basic's another time when memory and space was limited I remember coding on a zx81 with 1Kb RAM (yes 1024 bytes) machines by today's standards are behemoths.
 

Robert Maynard

Volunteer Moderator
I come from Amiga and DOS where code file size was important and each new line was one or two bytes extra so it was K&R lol.

Ah yes the old basic's another time when memory and space was limited I remember coding on a zx81 with 1Kb RAM (yes 1024 bytes) machines by today's standards are behemoths.

Ah yes - the joys of storage poverty.... ;)

On PCs, in my early days of programming, I used to occasionally write whole programs in ASM.

.... the ZX81 - when the entirety of system storage could be less than a modern e-mail and the CPU clockspeed is less than the magnitude of fluctuations in CPU clockspeed in a modern CPU.
 
Thank you nerds (I mean that with affection), your responses have made me smile this morning. Oh, and Aasgard ... jeez dude, get yourself a version control system like sccs or cvs. LOL
 
Last edited:
stick to spaces or tabs but don't mix them.

This lol.

I personally preferred tabs because they're always consistent and - let's face it - much simpler and quicker to use, but I can't imagine a reason to berate anyone on preference provided they can stick to what the rest of the team is doing in a multi-man job.

Ah yes - the joys of storage poverty....
wink.png

I'm not exactly a vet here, but my father did make a point that he used to deal with multi gigabyte storage solutions that would happily take the space of a few rooms.
 
Last edited:
Thank you nerds (I mean that with affection), your responses have made me smile this morning. Oh, and Aasgard ... jeez dude, get yourself a version control system like sccs or cvs. LOL

This is thread will probably go the same way as the open/solo/pg one ;)
 
Spaces only, 4 chars indent. Enforced in Eclipse Save Actions & Formatter ruleset, accompanied by strict CheckClipse and SonarCube validations. Any tab you enter will automatically be converted to spaces. Pure Tabs may be viable today, but consistency is king. There's really no worse thing than having both mixed, back in the days, it took an entire month to reformat a legacy module some fancy coder had left behind.

O7,
[noob]
 
Back
Top Bottom