-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lowercase_underscore everything #1435
Comments
Interesting research paper! It seems to come to somewhat different conclusions than the 2009 paper it's inspired by that finds "camel casing leads to higher accuracy among all subjects regardless of training, and those trained in camel casing are able to recognize identifiers in the camel case style faster than identifiers in the underscore style". The two studies had quite different sets of participants -- the 2009 paper having 135 participants (half programmers, half not), and the 2010 paper having 15 programmers -- and somewhat different methodologies, so I think we'll need a deeper dive into these two papers to decide what we can learn from them. |
I am a little leery of putting too much faith in a study of only 15 participants. |
The "15 participants" paper was a response to the "135 participants" paper, apparently, the authors have faith in their method :) Among the 135 subjects in the 2009 paper, half received 1-4 years of CS study in one particular school (called "training" in their paper) had an increasing "preference" for camel case over underscore already. In other words, the bias is built-in. What figure. 2 really tells you is that:
And the 2010 paper was trying to reduce the bias and test the body reaction, which is less likely to be different considering the evolution. |
As someone who uses various languages utilizing both styles, I much prefer working with |
same story here, |
JavaIsATestamentToPascalCaseGettingOutOfHand whereas_cpp_is_a_stark_contrast_and_shows_enhanced_readability |
@zeroxs spot on! Another example is google test. It doesn't allow underscore in test names, so I have to deal something like |
I literally stared at the "Javal" for 1 second and thought, "what this word is." Is that a kind of "Gravel?" Sure, the "I" is indistinguishable from "l" in my browser, and maybe I should inject some CSS, but I don't think I can solve the problem on colleagues' machines. And then I stared at the "ATest" for another second and thought, "what this test is." I know there is an AP Test; what is "ATest?" |
I think there's a significant readability benefit in having different styles for types vs non-types, like in Rust (PascalCase for types, snake_case for everything else). |
I totally agree with you, I prefer snake_case by far. |
New posts with individual preferences on this topic aren't really adding new information. Please help minimize the redundant content here, you can always thumbs-up something. =] This is obviously something that different people will have different preferences around. But we need to make a decision for Carbon and can't make it perfect for everyone. The studies are really interesting, and thanks for surfacing those. While I have some questions about how significant the difference is and the sample size, it still seems like an interesting factor to consider. However, I think there is specific benefit to having visually distinct styles for highly different constructs. That is a significant factor in the existing decision. Moving from 2 styles to 1 style, even if the 1 style is demonstrably better, is a trade-off where we give up the distinction to get the human-preferred format in more places. As I think that is the question, its probably best asked to the leads for a decision. They can always come back with "we would like to see analysis of the studies", etc. Personally, my stance is that even if there is a difference, I don't think it is enough of a difference to make the tradeoff of having only a single style the right one. CamelCase is widely enough used in enough programming languages (and now even non-programming contexts like |
A naming scheme that doesn't use a token separator sigil, such as '_', has couple downsides in my experience. Token boundaries takes some effort to distinguish for both humans and programs. Admittedly humans can often do it easy-enough if they have some level of familiarity with the project, the domain and the names which relate to the domain. For programs it's doable by special casing bunch of domain specific names. As an example I've written a bindings generator for Vulkan based on their xml specification. Vulkan for various parts doesn't use a token separator sigil: a) Another example where even humans will have problems is when the names are formed in such way that the capitalization does not represent token boundaries. Rather the naming scheme used maintains the all-caps nature of acronyms: |
Carbon already differentiates different constructs using And CamelCase reminds me of the Java bloat. Yes, the bloat starts from styles. |
When modelling I prefer that type names ThatCarryWeight has to do with the domain I am modelling and things_that_have_a_supporting_technical_role are in lower case. E.g: User, Budget, AnnualBudget, MonthlyBudget vs array, string, map… I don't want to be forced to add verbosity such as Model.User, Model.Budget, Model.AnnualBudget and so on to make the code clear. I'd rather fork the language… :-) As far as I am concerned, C++ got this right, and even if they didn't; C++ programmers are already conditioned to this preference. You need to consider the multitude of practices in the culture you are appealing to as practitioners have already adapted their practices to the look-and-feel of C++ over decades, and they are predictably reluctant to change practices for no good reason. (In this context, what other languages than C++ do is not particularly relevant, other than «fashion» or «opinion», for which there are no objective arguments) If uptake is a goal then staying close to C++ where the usability is not significantly improved by being different from it should be a priority. Unless, of course, the goal is to appeal primarily to devs who cannot stand C++. If so, maybe make that a stated goal? Becoming a successor to C++ is quite different from being an alternative to C++… |
If you want 2 styles but you also like underscores and you like consistency, you could possibly do:
Just an idea. Not necessarily a good one. |
At the moment, there doesn't appear to be much in the way of compelling technical argument about exactly which style to use. The leads (excluding me) are deferring this to the painter (me), and I think the current paint is fine -- we'll not switch to This doesn't preclude revisiting this if/when we can gather really good data or other new information comes up. |
If there is no compelling technical argument for either style, wouldn't it make sense to not change what has already been established, and start from there? Ignoring the fact that |
@chandlerc Below there are a few questions for the Carbon team.
So, it's the Carbon team that must explain the decision to abandon the well-established style of C++. |
I "think" you missed to give a reason :) No offense, i'm kinda blind, I may have missed it, but I cannot find a technical reasoning on why CamelCase is favored against all the odds described above and below. 😢
@doganulus that was my very first thought when seeing Carbon language examples. I am in fact glad I wasn't the only one having a not too positive feeling about it. :) |
The whole point about "leaving it to the painter" is that there doesn't really need to be a reason. There are a pile of options, all basically as good as each other; choosing among them is personal preference or a flip-a-coin. If there was a powerful argument that would convince everyone about a particular choice, then that would be chosen. But you need to make a choice even when all the options are pretty much the same, with some people preferring each option. When we agreed to defer to the painter that means we agreed there really is no strong argument for or against the various casing choices being considered. In this particular case, a choice has already been made, and now to change it would take work (updating documentation, redoing examples, etc) and there just isn't a compelling reason to take on that effort. As you've said, there isn't much technical reasoning one way or the other. |
Changing something for the sake of changing something is not good practice. Especially if you're trying to appeal to the former crowd. Therefore, a reason would be expected for changing the style from what has been established in C++ since this is supposed to be C++'s "successor". |
Well I guess it's here that I (and evidently the majority of the people participating in this thread) feel like your dodging the obvious: Edit: |
There is no "always use snake case" rule in C++. I've been using C++ since the mid 80s (and have never worked for Google) and have used a wide variety of casing styles in that almost-four-decades. I've worked places where underscores were banned anywhere in a name, for example. During the time before Carbon was public, some decisions were made which are just not a very big deal. This is one of them. We wanted different styles for different constructs. Most naming guides I've used in C++ have had a similar rule (even if it was as minimal as doing macros in all-caps.) Some people here are arguing for a single style for everything saying that it's "better". The leads decided that there's no compelling reason to change what has already been done for Carbon. It's not a case of "change it now because the work to change it later will be much much more." People feel very strongly about names and styles. That doesn't make this a big deal. We can change it later for the same effort as changing it now, and we have, to be frank, bigger fish to fry. As the rest of the design settles into place, we may want more (or less) contrast with built-in type names (i32) introducers (fn, let, var), as well as possible keywords. Many of those are the subject of other issues, discussions, and PRs. Would your opinion on naming case change if the introducers changed? If lambdas had a keyword introducer vs a punctuation introducer? Some people's would. So the lead decision is that for now, the naming case in our examples and documentation is up to the painter, who has decided that it isn't going to change. This can be revisited. |
A conscious decision was made to go against the established style of C++'s stdlib and other widely used and impactful libraries and people are asking what the reasoning was. "Just because" leaves a bad taste in the mouth. |
Thanks for the lengthy reply, but unfortunately I think you read me wrong: Either way, I'm just stating what I'm sensing from this discussion and the summary is to "put the lid on it". Given that attitude I'm just certain it will come up over and over again. |
As a friendly reminder, it's OK to disagree with people, but it's not OK to claim they have hidden motivations. See the code of conduct, especially the section on "When we disagree, try to understand why". |
Given the variance observed in practice and the lack of solid evidence that one style is better than another, we don't have a clear objective rationale to pick one convention over another in order to best help Carbon achieve its goals, and I don't believe this issue has provided us with one. In the Carbon project, we want questions that are purely matters of taste to be decided consistently, and not by community consensus, in order to give the language a consistent look and feel. That's why we have the painter role, to which this question should be, and has been, delegated. |
I think you have failed to see that it is the unobtrusive style of the C++ standard that allows catering to the different tastes of the vast C++ community. A language to replace C++ must be like water...
The standard library has done it for years. You are just calling trouble by changing it unnecessarily. We are not talking about the style of company projects, we are talking about the style of the language. And it's |
Everything, including type parameters.
A 2010 study shows that
lowercase_underscore
significantly improves the speed of reading:SICP says, "Programs must be written for people to read, and only incidentally for machines to execute." Speed of reading should be something we optimize.
In addition, the entire C++ standard library is in
lowercase_underscore
. Seamless, bidirectional interoperability should take coding style into consideration.Last but not least,
CamelCase
had never overcome the difficulty of spelling acronyms.The text was updated successfully, but these errors were encountered: