4 ms·
+1 for the kernel coding style I can understand (grudgingly) 4 spaces for Python But for C/C++ 4 spaces are awful. Maybe because C lines end up being longer?
by raverbashing 13y ago
+1 for the kernel coding style
I can understand (grudgingly) 4 spaces for Python
But for C/C++ 4 spaces are awful. Maybe because C lines end up being longer?
Tabs, they exist. Use them
- sdoering 13y agoMy editor automatically converts [TAB] to four spaces. Works just fine for me.
- raverbashing 13y agoAnd? Every editor can do it, I'm not complaining about pressing the space bar 4 times. I'm complaining about the appearance of code indented with 4 spaces.
- redwall_hp 13y agoWell, it shouldn't be a problem if you keep your source files clean and properly use tabs for indentation. Then everyone can set their editor to render tabs at their desired width, whether it's 2, 4, or 8 spaces. It's ludicrous that these space-wielding heretics (to borrow from the kernel style guide) are keeping everyone from having that.
- klibertp 13y agoEvery editor, or at least every good editor for programmers, can convert 4 (or whatever) spaces to tabs. If it bothers you that much, you can set up your editor so that it tabifies files when opening them and untabifies when saving. This way you won't even know if the file used spaces or tabs - and that's how it should be. In short: configure your editor to display to your tastes and save to whatever style guide you use in your organization. Problem solved.
- sesqu 13y agoYou might be shocked by how many editors can't convert indentation spaces to tabs. You might also be surprised by how many source files with indentation spaces have off-by-one indentation errors.
- Shorel 13y ago> You might also be surprised by how many source files with indentation spaces have off-by-one indentation errors. I will add that to my list of arguments against using spaces for indentation. It is so true.
- MichaelMoser123 13y agoUps. good luck then; that is bound to conflict with other editors; I think the Visual studio editor (or eclipse?) used to have 4 characters for tabs, if everybody is on Visual studio then you are fine. Of course if everybody in the shop has the same editor / editor settings then life is easier. vim has 8 spaces for tabstop and that's what its docs say: "Note: Setting 'tabstop' to any other value than 8 can make your file appear wrong in many places (e.g., when printing it)."
- pjmlp 13y agoTabs should be abolished, it is a pain to edit source code full of spaces and tabs characters mixed everywhere. Then the additional issue that everyone maps tabs to a different amount of space characters. Only spaces can give a proper consistency without relying on external tools.
- diminoten 13y agoWhat external tool can't interpret a \t character correctly? To me, the problem is consistency. I'm a 4 space man myself, but tabs don't outright offend me, as long as they're everywhere. I'd rather commit edits with tabs than attempt to convert the whole project to spaces, or worse, commit some spaces and some tabs to a single file/project.
- pjmlp 13y agoFor example when everyone has a different meaning how many spaces a tab represents, you end up with multiple amounts of tabs on your files. This fully breaks the indentation, which is exacerbated when multiple teams working on the same code basis use different editors and tab settings. So in the end one needs to rely on external tools that go over the source code to normalize the use of tabs.
- raverbashing 13y agoNo, that's what a coding style is for. Either specify tabs or spaces and you enforce it A tab means 8 spaces. If you want your editor to show something different that's up to you, but it's non standard.
- pjmlp 13y agoWhich only works on small hobby projects, startups and a few companies of the likes of Google, Facebook and friends. On the real corporation world, it is a whole different thing. Good luck enforcing coding styles across multi-site projects, with rotating developers and off-shoring subcontractors.