5 ms·
I'm slightly conflicted about CamelCase. On the one hand it can be somewhat harder to read, on the other hand it does have a number of benefits: - Typing "ABC"
by layer8 4y ago
I'm slightly conflicted about CamelCase. On the one hand it can be somewhat harder to read, on the other hand it does have a number of benefits:
- Typing "ABC" Ctrl+Space gives me code completion for AsynchronousByteChannel (and the like), whereas "abc" Ctrl+Space gives me code completion only for what strictly starts with "abc". I.e. uppercase means "words starting with that letter". Of course you could have something equivalent for non-CamelCase naming conventions, but for CamelCase it is a very natural fit.
- It provides the two variants lowerCamelCase and UpperCamelCase (often used for variable names vs. type names), whereas lower-kebab-case & Upper-Kebab-Case or lower_snake_case & Upper_Snake_Case seem more awkward in comparison (more keystrokes for the "upper" variant).
- When lowerCamelCase is used for function names, the case distinction often maps nicely to verb + noun (`createFooBar()`, `validateBazQuz()`).
- You still have underscore available to occasionally "index" a name (`transmogrifyFooBar()`, `transmogrifyFooBar_unchecked()`) unambiguously.
- The fact that CamelCase does not match normal English spelling has the advantage that it can't clash with it. CamelCase can stand both for hyphenated-compound-words as well as for open compound words (or just a phrase), whereas other naming conventions may look like the one although the words really stand for the other.
- Minor advantage: You can fit slightly more words into a line.
Apart from that, I'm pro-kebab-case.
- m463 4y ago> typing "ABC" Ctrl+Space gives me code completion for AsynchronousByteChannel that's clever. I suspect you could add editor logic to do that with underscores too.
- pocketarc 4y agoIDEA does something similar - you just type, and as long as the characters are found in the string in the order you typed them, it doesn't matter what's separating them, it will find a match. So ABC would match AsynchronousByteChannel, and abc would match asynchronous_byte_channel. As would asyncbc or whatever else your brain comes up with. It's quite nice.
- moring 4y agoI think IDEA actually splits a CamelCase identifier and expects your input to be a concatenation of prefixes of these parts, in the correct order, but parts may be omitted. Though the latest version goes further and also detects flipped characters, so maybe levenshtein distance on top of that.
- brabel 4y agoOn Emacs, this is called "fuzzy" search and is easy to enable everywhere (autocompletion, file search, text etc).
- xlii 4y agoAnd just yesterday I started toying with “orderless” Emacs package which allows that (and more!) - both for underscores and camel case. Since such features often cross environments I wouldn’t be surprised if other editors/IDEs had similar stuff.
- forgotmypw17 4y ago- Typing CamelCase is also easier on the pinkies.
- Biganon 4y agoDoes kebab-case even work, generally speaking? Does it not clash with the subtraction operator?
- grose 4y agoKebab-case is used in languages that don't have subtraction operators in arbitrary locations (in the sense of C), like Lisp and CSS.
- ogoffart 4y agoThe language I designed for Slint [https://github.com/slint-ui/slint https://github.com/slint-ui/slint] uses kebab-case, so it mandates spaces around the minus sign. (If the lookup for `foo-bar` fails, it tries with `foo` and if that succeeds, the error message suggest the use of spaces)
- deleted 4y ago[deleted]
- vvillena 4y agoLike most esoteric language features in existence, Raku allows for it. Probably easier to support, as variables are prefixed with sigils.
- lizmat 4y agoThe rule for kebab-case (regardless of whether or not it has a sigil) in Raku is: - each part of the identifier must start with an alpha character - cannot end with - So, "foo-bar" would be legal, "foo-" would not, "foo-4" would be considered "foo" - 4. If you want to substract two sigilless identifiers, you *must* have whitespace between them. So "foo - bar" instead of "foo-bar".