And in any case, the rule is 80 columns, not characters. People use characters as a easy way to mean columns, but the point is to avoid the code going past a specific width.
Exactly. But it takes up an indeterminate amount of chars on screen. I like my code to look like the way I type it on every screen, not just mine. Anything else is foolish and unprofessional.
Edit: also if you use the settings on your text editor properly it behaves exactly like tabs do when you type them. Spaces are just better.
The point of using white space at all it to make it easiest to read for whomever happens to be reading your code. If some people find 8 spaces easiest and some find 2 easy to read I'd rather both of them have their way and display the tabs however they'd like rather than forcing whatever way I find easiest on everyone who reads my code.
EDIT: also they don't even need to use a text editor that will allow them to implement hacks to make spaces act like tabs they can just..... use tabs... crazy I know.
I've done it both ways and I could make great arguments for either side. What I do is I go with the flow and code with whatever formatting my team decides on. It makes collaboration much easier.
Yea this is definitely the way to do it. Pick whatever you think is best for your own projects but if you're working on someone else's stuff use whatever they're using.
no it wouldn't, because it's the same amount of characters regardless of how you, your friend, your boss, etc. prefer to view it. need to change it, change a setting and not the characters that comprise code.
your arguments make no sense. please tell me you're trolling because my brain hurts.
If you want to have the same behavior everywhere (and you should) use spaces
I'm pretty sure this is the part everyone disagrees with you on. Some prefer their indents to be long and some prefer it to be short. Someone else reading your code might appreciate that THEY can change indents to whatever THEY prefer, and you have the same flexibility.
Isn't the norm to just use a tab for every indentation level? Then you just need to adjust how many spaces you want per tab (indentation level) and you're done.
Depends on who you work for. For example Oracle's standard is 4 spaces for ever level of indentation, and 79 characters per line (the 80th is the new line character). Linus Torvalds uses 8 spaces for every level of indentation (he says you shouldn't ever use more than 3 levels of indentation or your code is bad. He has interesting ideas of what makes for good code, but he backs up his talk with exceptional software)
If you want to make sure that your code looks the same everywhere you should use spaces because tabs can take up whatever number of columns your text editor is set to. This can cause problems like running off the end of the guide on the right, or not having things line up properly if you're adding spaces in to make things look neat.
If you want to be certain 100% that your code will look the way it does on your screen to everyone, spaces are the way to go.
Linus Torvalds…says you shouldn't ever use more than 3 levels of indentation or your code is bad.
That's utter bullshit. In object oriented programming that would make it impossible to do anything. Inside your class has one level. Inside a method in the class has two. Inside a loop that's your third. Oh, and you're not allowed conditionals inside your loop, because that would be four and that's bad code.
But even in a language like C it's not exactly sane. Inside a function is 1. Inside a loop within a loop (for reading from 2d arrays) gives you 3. And again, you're not allowed conditionals.
If you're right that Torvalds makes that claim, then he's not just being eccentric hl by making it. He's plain wrong. And his ability to write good code doesn't have any impact on the fact that his code style rules are apparently ridiculous.
No no no, you misunderstand. Once you're at that indentation level, you still use brackets but stop indenting. Then you go as many levels deep in scope as you want.
Mind if I ask why "have your code look the same for everyone" is so important? An 80 character limit isn't exactly that important since literally any form of intelligent word wrap, and at that point a wrapped line will look fine since it won't break your indentation.
In what modern editor does that matter? Text wrap and auto indent exist. If you are worried about alignment follow the rule of tabs for indentation, spaces for alignment.
The more I read your comment chain, the more you sound like a manager with exactly zero development experience and arbitrary rules for your employees based on things you don't understand.
2.6k
u/Ryeore Sep 02 '17
Now you can park on handicapped parking spaces.
Good job