My view on this is very much along the line of discussions about whitespace. While I have opinions about these matters, for the most part I don't want to think about it--I have more pressing concerns. What's important to me is consistency within a code base. Just like with whitespace, I don't want to introduce spurious changes into all my diffs when working with other people. I also don't want to customize 50 editor variables to get sane defaults which I have to tweak for various environments (work, home, contributing to open source projects).Supporting different styles is a laudable goal, but I hope we can agree that the defaults should be similar in all editors to reduce friction when working with others. Using a style guide maintained by the community for those defaults make a lot of sense to me.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I recently browsed parts of that guide and was surprised how many bits I disagreed with. Especially around the "one space in these rare cases" bits. Not that that is a bad thing it's just my personal opinion that everything should always use two space indentation.
And on a client project recently, it was decided (when I wasn't around) that the arguments to a function should always be on a newline:
(defn foo
[x]
(+ x x))
Instead of:
(defn foo [x]
(+ x x))
I disagree with this idea also, but whatever, it's just style. It's not like I suddenly can't read Clojure code since it's in the wrong style.
And on a client project recently, it was decided (when I wasn't around) that the arguments to a function should always be on a newline:
(defn foo
[x]
(+ x x))
Instead of:
(defn foo [x]
(+ x x))
--
Does anyone here know why in Clojure it was decided to move the docstring from its traditional-in-Lisp location after the argument list?
It's not a docstring then, just the first expression in the body.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
Bozhidar clearly sees himself as the steward of a community style guide, something he's done to great success with the Ruby style guide. However it seems that there is a significant part of the community that didn't see it that way, and had seen it more as his personal style guide that he happened to put out there. I'm interested in starting a discussion around this because I do think it's valuable to have some degree of community consensus around these issues, specifically so that tools can have consistent defaults.Hi everyone,There's been a bit of discussion recently on a couple of clojure-mode tickets that I thought were worth discussing here. The tickets are #265 and #266, and they later led to PR #96 on Bozhidar Batsov's Clojure Style Guide. The part of the discussion I wanted to raise starts here, where there's some discussion around the nature of the style guide itself.
I do not agree with everything on the guide on a personal level, which is a clear indication this is not a reflection of my personal preferences. On the other hand every such document needs an editor (or a few editors), otherwise chaos is bound the ensue. When I work on open-source projects I follow the style guide pretty closely, but on personal projects I do whatever pleases me. Even if people/teams/etc don’t agree with everything in a style guide, there’s lots of value in maintaining a consistent code base (which is the same as having a style guide). Forking the existing community guide is one of the easiest ways to quickly set up an internal project/company style guide.
I believe that having at least some level of community-wide adopted standards simplifies the lives of everyone involved, because we spent less time dwelling on details (e.g. code layout) and more time thinking about solving the problems at hand. I actually want to talk about the value of style of at either Clojure/West or EuroClojure. We’ll see if this will actually happen.
That said, one of the defining features of lisps in general is that they permit essentially unlimited flexibility, and in my experience programmers in general really don't like being told what to do, especially around indentation. So, I'd like to ask the obvious initial question - do we as a community think that there is value in having a style guide like this? If so, to Marshall's point on the list, do we think it should try to mandate what people should be doing, or should it describe what they actually currently do in real code, even if that's the result of historical accidents?
I feel that we should promote the “best” (meaning most robust/sensible practices over those that are historical accidents). What qualifies as a historical accident, however, is rarely clear-cut. I’d argue that the `cond` 1-space indentation was one such case, but few other examples come to mind.
While I realise that people always have personal preferences regarding code style, we should keep in mind that we rarely work by ourselves on a particular project and someone will always have to put their personal preferences aside. When we started the Ruby style guide there was little consensus regarding anything in the Ruby world. Pretty much every project I encountered had a style of its own, which introduced a certain cognitive burden on the readers of its source code. 4 years later there’s widespread consensus on a lot of basic stuff and that’s clearly visible. Sure, there are many aspects on which there will never be a consensus (often for a good reason), but having some baseline definitely beats having none at all. After all - making choices is pretty hard, so the less we have to make the better.
For what it's worth, from my point of view I definitely think that a guide like this is useful, and I've referred to Bozhidar's guide myself from time to time when trying to decide what to do for a particular feature in Cursive. However I do think that it needs more flexibility than it currently has - there are some things marked in there as "bad" that I'd like to see downgraded to "prefer the other way unless you have a good reason", which of course I always feel like I have. In particular, some of the reasoning behind the linked changes above I think needs to be more flexible - there are good use cases for customising indentation for some functions, for example.
The use of the words “good” and “bad” is somewhat unfortunate I guess; lately we’ve also been using “acceptable” and “preferable” as well. The guide ends with something like “use common sense”. The rules are mostly prescriptive - if you know Clojure well enough and you feel you have to violate some of them you should probably do so.
Cheers,Of course, if we decide that we do want a guide like this then we can spend many happy years arguing about what should go in it, but first things first :-)
Colin
I recently browsed parts of that guide and was surprised how many bits I disagreed with. Especially around the "one space in these rare cases" bits. Not that that is a bad thing it's just my personal opinion that everything should always use two space indentation.
Can you elaborate on “one space in these rare cases”. I can think of just one case (arguments following function/macro name on the next line) of such indentation and this is something rooted in Lisp’s DNA. :-)
And on a client project recently, it was decided (when I wasn't around) that the arguments to a function should always be on a newline:
(defn foo
[x]
(+ x x))
Instead of:
(defn foo [x]
(+ x x))
I disagree with this idea also, but whatever, it's just style. It's not like I suddenly can't read Clojure code since it's in the wrong style.
With so many different views, I think it's unwise to lock any editor into any style. Instead give users options, and update the Clojure Style Guide with the following (paraphrased) quote from Pirates of the Caribbean: "this Code of Styling is more what you'd call "guidelines" than actual rules."
This is the final rule https://github.com/bbatsov/clojure-style-guide#common-sense :-)
That said, we should probably mention something similar in the overture. PEP-8 has something similar https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds
Thanks for bringing this up here and linking to the issue I raised on GH. I wanted to start a discussion here as well but have not yet found time.My concerns and worries are less about the style-guide in general and more about the indentation change regarding assoc introduced as default in clojure-mode 4.0.0.At this point in the discussion (bbatsovs reply here) I don't think there is another way to change his mind than more people in the community trying to convince him otherwise.
TLDR is that bbatsov has decided with release 4.0.0 that indenting assoc in the way introduced more than 6 years ago is not so much of a good idea anymore because it "defies an extremely strong Lisp tradition ".
I believe I presented a bit more arguments than that. :-)
Since bbatsov was so kind to fix threading macros yesterday, I guess he can be convinced about assoc, too.
Regarding the discussion in general: How about agreeing to an EDN structure with indentation hints which can be loaded into any Clojure IDE? This would offer library authors to provide indentation hints for their macros themselves. They could also be added as meta-data to the vars so that during an active nrepl connection the correct indentation for e. g. om/dom forms would be pulled automatically...Best regards,Leon.
On Saturday, December 20, 2014 10:14:18 AM UTC+1, Colin Fleming wrote:Cheers,That said, one of the defining features of lisps in general is that they permit essentially unlimited flexibility, and in my experience programmers in general really don't like being told what to do, especially around indentation. So, I'd like to ask the obvious initial question - do we as a community think that there is value in having a style guide like this? If so, to Marshall's point on the list, do we think it should try to mandate what people should be doing, or should it describe what they actually currently do in real code, even if that's the result of historical accidents?Bozhidar clearly sees himself as the steward of a community style guide, something he's done to great success with the Ruby style guide. However it seems that there is a significant part of the community that didn't see it that way, and had seen it more as his personal style guide that he happened to put out there. I'm interested in starting a discussion around this because I do think it's valuable to have some degree of community consensus around these issues, specifically so that tools can have consistent defaults.Hi everyone,There's been a bit of discussion recently on a couple of clojure-mode tickets that I thought were worth discussing here. The tickets are #265 and #266, and they later led to PR #96 on Bozhidar Batsov's Clojure Style Guide. The part of the discussion I wanted to raise starts here, where there's some discussion around the nature of the style guide itself.For what it's worth, from my point of view I definitely think that a guide like this is useful, and I've referred to Bozhidar's guide myself from time to time when trying to decide what to do for a particular feature in Cursive. However I do think that it needs more flexibility than it currently has - there are some things marked in there as "bad" that I'd like to see downgraded to "prefer the other way unless you have a good reason", which of course I always feel like I have. In particular, some of the reasoning behind the linked changes above I think needs to be more flexible - there are good use cases for customising indentation for some functions, for example.Of course, if we decide that we do want a guide like this then we can spend many happy years arguing about what should go in it, but first things first :-)
Colin
--