7 ms·
Whenever this old debate comes up, I am reminded of this quote “There's a good part of Computer Science that's like magic. Unfortunately there's a bad part of
by j_m_b 9y ago
Whenever this old debate comes up, I am reminded of this quote
“There's a good part of Computer Science that's like magic. Unfortunately there's a bad part of Computer Science that's like religion.” - Hal Abelson
I don't worry about indentation because emacs does it for me. However, if this is your personal pet peeve then you should provide all of your developers / contributors with a plugin, script or other utility that formats their code to your standards. This issue has long been solved programmatically and it is a waste of mindspace to deal with it any other way.
- leggomylibro 9y agoThat quote reminds me of one of Joseph Campbell's - "computers are like Old Testament gods; lots of rules and no mercy." And to go along with that, some things like GNU Make still requires tabs, which is definitely annoying when you have your editor set to autoconvert. And some sects like Go or Python don't technically REQUIRE one or the other, but still try to aggressively purge the heretics.
- na85 9y agoIs that a limitation in GNU Make or is it an inherited limitation of m4? In my experience, m4 is an arcane bit of software that surprisingly few people know about and one that frankly should have been replaced years ago. Personally, I try to never use autoconf because of this.
- dasyatidprime 9y agoTab as the prefix for command lines is a property of all Makefile formats I'm aware of (though not of many other build script formats). Make itself (including GNU Make) does not generally use M4, though both Autoconf and Automake use it, often in conjunction with Make, as part of the Autotools suite which is also published by GNU. So, none of the above, in itself. It is a historical anomaly which has been preserved.
- khedoros1 9y agoI haven't dug into it, but Wikipedia claims that Make is actually about a year older than M4 (obviously not GNU Make).
- linkregister 9y agogo fmt Controversy solved for one language ;)
- rjeli 9y agoAnd clang-format[0] for C/C++, google-java-format[1] for Java, YAPF[2] for Python, rustfmt[3] for Rust... [0]: https://clang.llvm.org/docs/ClangFormat.html https://clang.llvm.org/docs/ClangFormat.html [1]: https://github.com/google/google-java-format https://github.com/google/google-java-format [2]: https://github.com/google/yapf https://github.com/google/yapf [3]: https://github.com/rust-lang-nursery/rustfmt https://github.com/rust-lang-nursery/rustfmt
- mjevans 9y agoThe parent post's point wasn't about add-on formats. The point was that the language spec it's /self/ has an included lint tool to eliminate controversy. The go language has /a/ (single) correct formatting syntax.
- eternauta3k 9y agoTIL vim has been hiding this problem from me.
- knome 9y agoemacs' makefile-gmake-mode, loaded automatically for makefiles, also hides this. I've set indent-tabs-mode to nil in my .emacs for years, but the mode knows it's needed, and will indent the line with a highlighted tab ( until you begin writing in the command to follow it, when it unhighlights it ).
- Sean1708 9y ago> which is definitely annoying when you have your editor set to autoconvert Is this actually a problem? Every editor I've ever used has detected that I'm writing a makefile and has changed the indentation to tabs automatically.
- TekMol 9y agoThis issue has long been solved programmatically and it is a waste of mindspace to deal with it any other way. I beg to differ. Aligning code is an art form. And different people like different styles. Your "whatever" approach is one. And there are many others.
- mmrezaie 9y agoArt or whatever it is subjective to decide which code formatting is better. As long as a single "code format actor" can transform different styles automatically then why one should care. I think most communities are having an agreement on which one they would like to choose and most of the times they chose the best style but doesn't mean one has to limit themselves into those formats anyway. Something like git push --code-style somestyle would be a relaxing.
- aequitas 9y agoLike programming itself aligning code is not an art form, at least not in where productivity and consistency is required, it's just a means to an end. In my opinion the art is in documenting your code and explaining what your code does (what you intend it to do not how it does it).
- Spivak 9y agoSure, and writing the rules to feed to your linter and formatter is where the art takes place now.
- KGIII 9y agoI don't really care if you use tabs or spaces. Just please, for the sake of humanity, don't mix them.
- mwfunk 9y agoSeriously, this is the heart of it. The one thing about Emacs that I just can't forgive is its insistence over the decades on mixing tabs and spaces in its auto-indentation. Ultimately, the spaces vs. tabs debate really comes down to which policy is less likely to result in mixed tabs/spaces. If people use tabs, it seems inevitable that some spaces will sneak in there as well. If people use spaces, tabs are unlikely to sneak in. Obviously that's a combination of common default editor configs and human behavior, but that's just how it works out in practice.
- iak8god 9y agoThis tabs vs spaces thing is a recurring joke and source of conflict on HBO's Silicon Valley, and I always thought having a raging debate over tabs and spaces was one of the less realistic things about the show. But what I'm hearing now is that my use of emacs has just left me out of touch with the really tedious stuff other people sometimes have to deal with.
- adambyrtek 9y agoAny proper IDE/editor has auto-indentation nowadays, so there's really nothing special about Emacs anymore. Obviously even with auto-indentation you still have to agree on the right convention for a given project. As with most code style debates, it usually doesn't matter that much one way or another as long as you make a call and keep it consistent across the project.
- dgfgfdagasdfgfa 9y agoEhh, I'd say emacs has a minor edge in that tab is a command to indent to the correct level, not to insert characters. I.e., you can also use a single `tab` on an over-indented line to correct indentation. Your point stands, of course.
- terminalcommand 9y agoMost emacs users would use ctrl-i instead of tabs or spaces I imagine, at least I do it like that. It is much easier to type. Emacs still has a quirk that stands out :)
- marcus_holmes 9y agoOnly an Emacs veteran would say that ctrl-i is easier to type than Tab ;)
- abritinthebay 9y ago> I'd say emacs has a minor edge in that tab is a command to indent to the correct level, not to insert characters. I've had this in basic code editors for... 10 years or so? It's hardly an emacs thing.
- Sivart13 9y ago> I don't worry about indentation because emacs does it for me. The problem is, everyone's editor "does it for" them, but everyone wants to use a different editor. And there are interoperability issues when one person's editor produces tabs and another produces spaces. It's a relatively minor tower of babel situation.
- khedoros1 9y agoWell...the team tends to learn pretty quickly which editors don't follow the project's coding standards by default, and comes up with configuration files for those editors. If that doesn't happen, then inconsistent indentation probably isn't the first thing that needs to be addressed.
- pyre 9y ago> However, if this is your personal pet peeve then you should provide all of your developers / contributors with a plugin, script or other utility that formats their code to your standards. http://editorconfig.org/ http://editorconfig.org/
- pm215 9y agoInteresting idea and it would certainly help to alleviate the "how many editors do we need to provide code style config for" problem, but it looks rather limited in scope at the moment (for instance it doesn't even try to address "brace on current line or line of its own", let alone more odd things like GNU coding style brace indent).
- apetresc 9y agoIt's only really targeting text-editor-level settings, things like encoding, EOLs, and "what characters does the tab key emit". It doesn't attempt to solve every formatting/linting/style issue, that would make the editor plugins really hard to keep compatible.
- chongli 9y agoYou don't even have to do that. Just use whatever format is in the main repository. Then use git smudge and clean filters[0] to convert to your preferred format whenever git checks out the files. This way your editor does not need to care about the format everybody else uses. [0] https://stackoverflow.com/a/2318063 https://stackoverflow.com/a/2318063
- mercer 9y agoFor js (at least?) we now have Prettier [1]. It's already a must-have editor plugin for myself and any underlings. It's real nice. [1]: https://github.com/prettier/prettier https://github.com/prettier/prettier
- tonyhb 9y agoWhich itself is based off of gofmt and facebook's Reason. More languages should provide standardized ways of writing and formatting code. It makes everything easier - from diffing to subjectivity.