Skip to content
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

Clarify we mean UpperCamelCase, not lowerCamelCase #2389

Merged
merged 1 commit into from
May 30, 2018

Conversation

shepmaster
Copy link
Member

@shepmaster shepmaster commented Apr 4, 2018

Because it looks like a camel with a single hump in the middle: 🐪

@shepmaster
Copy link
Member Author

Corresponding PR has been made to the api-guidelines repo

@petrochenkov
Copy link
Contributor

Wait, what about this guy?
default

At least wiki says both camelOne and CamelTwo are camel case and we also have long-stable non_camel_case_types lint - something that we can't change.

@shepmaster
Copy link
Member Author

Wait, what about this guy?

That would be equivalent to reallyLongIdentifier; two humps in the middle: 🐫. There are no emoji for higher-order-camels, so please don't ask about that case 😉

At least wiki says both camelOne and CamelTwo are camel case

Yes, many people misuse the terms, so this is an uphill battle on my part. However, I hope we'd agree that one of those is an idiomatic Rust type name and the other is not. We could choose to say "no, not that camel case, use the other camel case", or we could choose to use a distinct term that only means the one we want.

One interesting thing that I've been mulling about regards WASM. In the JS ecosystem, camelCase and PascalCase are both used (in different contexts). If more JS developers come to Rust and we tell them to use "camel case", they might be needlessly confused.

we also have long-stable non_camel_case_types lint

A good point, but we've previously deprecated / renamed lints that had names we no longer felt were appropriate. I hadn't thought of this case before, but I believe it could fit into the same category. We certainly wouldn't ever get rid of support for the existing lint name.

@Zarenor
Copy link

Zarenor commented Apr 4, 2018

In terms of prior art, I think it's also worth mentioning that the C# capitalization guidelines also make the distinction between PascalCase and camelCase. Oracle's Java recommendations dodge the issue by not naming the conventions.

I think it's thoroughly more clear to have more-distinct names, too. I realize that we're not recommending the camelCase option for any identifiers in Rust, but it's certainly out there in other languages. I think having distinct terms that are shared across ecosystems is a win.

@Ixrec
Copy link
Contributor

Ixrec commented Apr 5, 2018

FWIW, I personally prefer to call these "lower camel case" and "upper camel case" since it's hard to imagine how anyone could manage to misinterpret those terms, and the term "PascalCase" is significantly less famous than camel case.

@loganfsmyth
Copy link

I'll just throw in that when I came across SomeWord being described as camel case, I legitimately thought it was a typo/mistake. Explicitly calling out upper camel vs lower camel would certainly go a long way to helping that. That said, I was entirely unaware that anyone considered capitalized-first-word as a potential form of camel case. I don't know that I would have known the word PascalCase off the top of my head, but it's quite easy to search for, so it seems like the most practical description in my mind.

@sgrif
Copy link
Contributor

sgrif commented Apr 5, 2018

We should probably get @killercup's permission

Copy link
Member

@killercup killercup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice PR. I have nothing against camels, and they regularly show up in the names of my variables in other languages, but something about this PR makes me smile.

@Centril Centril added the T-libs-api Relevant to the library API team, which will review and decide on the RFC. label Apr 5, 2018
@mark-i-m
Copy link
Member

mark-i-m commented Apr 6, 2018

There are no emoji for higher-order-camels

My favorite out-of-context quote for the month.

@eddyb
Copy link
Member

eddyb commented Apr 6, 2018

FWIW, I personally prefer to call these "lower camel case" and "upper camel case"

I've seen them called lowerCamelCase and UpperCamelCase for many years in both C++ and JS projects before a single PascalCase reference (which confused me at first). YMMV of course.

@elahn
Copy link

elahn commented Apr 13, 2018

As a former Delphi programmer, I strongly support PascalCase. Solidarity! I've always found camelCase ugly and I'm so glad we don't have it in Rust (thank Graydon!), biting my fingers when I type. When I see CamelCase I have horrible 🐪 flashbacks. 😉

@varkor
Copy link
Member

varkor commented Apr 17, 2018

FWIW, I personally prefer to call these "lower camel case" and "upper camel case"

Might be worth adding that the Swift guidelines refer to this as UpperCamelCase (vs lowerCamelCase), which I think is directly clearer because it requires no explanation (I could see some people having to look up PascalCase just to be sure).

@shepmaster
Copy link
Member Author

Please merge or close this PR. I don't want it to remain in limbo forever.

@mark-i-m
Copy link
Member

Personally, my vote is for 🐫 case, which has been what I have always heard it called...

@sgrif
Copy link
Contributor

sgrif commented Apr 24, 2018

@alexcrichton @BurntSushi This is a pretty low effort RFC to nominate, either of you care to bring it up at the next libs team meeting?

@alexcrichton
Copy link
Member

Ah we actually discussed this at the last triage meeting and forgot to comment! We concluded that good names for this would be UpperCamelCase and lowerCamelCase from a libs perspective, so this was largely turning into a docs issue and I'll reclassify to reflect that.

@alexcrichton alexcrichton added T-doc Relevant to the documentation team, which will review and decide on the RFC. and removed T-libs-api Relevant to the library API team, which will review and decide on the RFC. labels Apr 25, 2018
@joshtriplett
Copy link
Member

I don't think we should call this "PascalCase"; informally, I'd say that I don't think that term has nearly the name recognition. And even "UpperCamelCase" doesn't seem clear except insofar as being self-documenting. We should just explain and/or define the terms we use in detail the first time we use them, which will make it clear even to people who haven't heard any of the terms before. We give examples in a table, but I don't think we have an explanation anywhere that actually says "capitalize the first letter of each word".

@varkor varkor mentioned this pull request May 11, 2018
@shepmaster shepmaster force-pushed the pedantry-abounds-in-all-places branch from e55b330 to 633de5f Compare May 30, 2018 17:02
@shepmaster shepmaster changed the title PascalCase has leading capitalization, camelCase does not 🐪 Clarify we mean UpperCamelCase, not lowerCamelCase May 30, 2018
@shepmaster
Copy link
Member Author

I may have forgotten about this PR for a while. I've removed all PascalCase and replaced with UpperCamelCase. When this is merged, I'll fix the api-guidelines repo to match.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Libs team has discussed this in a previous meeting -- #2389 (comment) -- so this looks good to me. Thanks!

@dtolnay dtolnay merged commit cdd0053 into rust-lang:master May 30, 2018
@shepmaster shepmaster deleted the pedantry-abounds-in-all-places branch June 2, 2018 02:51
@Centril Centril added the A-formatting Proposals relating to formatting of Rust code. label Nov 23, 2018
tcullum-gpsw added a commit to tcullum-gpsw/rust that referenced this pull request Jan 4, 2019
Rust structs should be named in upper camel case aka PascalCase. "Upper camel case" was decided upon as the preferred phrase over PascalCase per: rust-lang/rfcs#2389
tcullum-gpsw added a commit to tcullum-gpsw/rust that referenced this pull request Jan 4, 2019
Rust structs should be named in upper camel case aka PascalCase. "Upper camel case" was decided upon as the preferred phrase over PascalCase per: rust-lang/rfcs#2389
tcullum-gpsw added a commit to tcullum-gpsw/rust that referenced this pull request Jan 4, 2019
Rust structs should be named in upper camel case aka PascalCase. “Upper camel case” was decided upon as the preferred phrase over PascalCase per: rust-lang/rfcs#2389
tcullum-gpsw added a commit to tcullum-gpsw/rust that referenced this pull request Jan 4, 2019
Rust structs should be named in upper camel case aka PascalCase. “Upper camel case” was decided upon as the preferred phrase over PascalCase per: rust-lang/rfcs#2389
tcullum-gpsw added a commit to tcullum-gpsw/rust that referenced this pull request Jan 4, 2019
Rust structs should be named in upper camel case aka PascalCase. “Upper camel case” was decided upon as the preferred phrase over PascalCase per: rust-lang/rfcs#2389
tcullum-gpsw added a commit to tcullum-gpsw/rust that referenced this pull request Jan 12, 2019
Rust structs should be named in upper camel case aka PascalCase. "Upper camel case" was decided upon as the preferred phrase over PascalCase per: rust-lang/rfcs#2389
carols10cents added a commit to rust-lang/book that referenced this pull request Jan 23, 2023
Brings the terminology in line with the rest of the project, see
<rust-lang/rfcs#2389>.

Connects to #2194.
@ghost
Copy link

ghost commented Feb 14, 2023

Rust is the first time I've heard of UpperCamelCase in 500 years of coding. I'm sad it's not called PascalCase here too.

@shepmaster
Copy link
Member Author

@nodingneu that's wonderful! I'm glad that we got to be a small part of your learning today. I hope that when I am 500 years old I am still able to learn something new every day as well. Have an enriching learning journey!

HimoriK added a commit to HimoriK/bookedit that referenced this pull request Feb 2, 2024
* Typo

Typo, filename is now file_path.

* rst 

restore `value`

* Fix broken nostarch URL

* Change CamelCase to UpperCamelCase

Brings the terminology in line with the rest of the project, see
<rust-lang/rfcs#2389>.

Connects to rust-lang#2194.

* Update to Rust 1.66.1

* Update to Rust 1.67.1

* Removed "," typo on ch03-01 line 85

Removed extra comma on line 85.

We’ll cover types and type annotations in the next section, “Data Types`,`”, so don’t worry about the details right now.

* simplify COPYRIGHT file

* Fix grammar

Add the word 'of' to fix the grammar.

* Update copyright in LICENSE-APACHE

Looks like we forgot to fill this in when we added the license file. ;)

* Correct `i32` formatting in ch19-05

* Remove adjective about what kind of number this is

* Improve sentence

* Small wording changes

* redirects: change link for `#![no_std]` tutorial

* Fix cargo doc links

* Prepare for removal of compiler plugin support.

rust-lang/rust#116412 will remove support for
compiler plugins from rustc, which includes the entry in The Rust
Unstable Book. This commit removes a link to that entry so it won't be
broken when that PR merges.

* Fix mdBook links

* Fixed 'troubleshooting' link

* Update ch01-02-hello-world.md

* Update ch01-02-hello-world.md

---------

Co-authored-by: abiphone <[email protected]>
Co-authored-by: printfn <[email protected]>
Co-authored-by: Carol (Nichols || Goulding) <[email protected]>
Co-authored-by: Mateus Rodolfo <[email protected]>
Co-authored-by: Pietro Albini <[email protected]>
Co-authored-by: Vishal Lama <[email protected]>
Co-authored-by: Jason Walton <[email protected]>
Co-authored-by: Shinya Fujino <[email protected]>
Co-authored-by: Jaime Terreu <[email protected]>
Co-authored-by: Mike Krisher <[email protected]>
Co-authored-by: kadiwa <[email protected]>
Co-authored-by: Eric Huss <[email protected]>
Co-authored-by: Nicholas Nethercote <[email protected]>
Co-authored-by: Marcus Stollsteimer <[email protected]>
Co-authored-by: Aryan Malik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-formatting Proposals relating to formatting of Rust code. T-doc Relevant to the documentation team, which will review and decide on the RFC.
Projects
None yet
Development

Successfully merging this pull request may close these issues.