Live data from Hacker News

CamelCase vs underscores: Scientific showdown (2011)

whatheco.de

111–120 of 138 posts

Re: CamelCase vs underscores: Scientific showdown (2011)

#111
post #94

Underscores are harder to type, at least on a US keyboard layout. To me, that's the single largest tag against underscore_separation.

On a US keyboard, _ is shift + -. To do CamelCase it's shift + c. Isn't that the same about of "difficulty"?

All I can tell you is I find lots of underscores physically uncomfortable to type, and I have zero trouble with capital letters.

Re: CamelCase vs underscores: Scientific showdown (2011)

#112
post #29

I prefer to use a language's convention, whatever that might be. The language's standard library will expose names using the language's convention, and using a different convention for my own code's names would make for strange and confusing looking code.

> The language's standard library will expose names using the language's convention

Looking at you, C++ STL. Almost nobody names structs/classes all lowercase. This leads to silly style guidelines eg. in the Google c++ style guide:

- Name classes PascalCase (even if it's templated)

- Except if your class happens to be a templated container type, in which case name it all lowercase.

Re: CamelCase vs underscores: Scientific showdown (2011)

#113
post #20

I got the solution! Given that spaces in identifiers cannot be used because we need to please the language tokenizers (shouldn't be the other way around with humans vs machines?), let's use TAB as a word separator! Configure TAB width = 1 character, and there you go.

Would allowing spaces in identifiers even introduce any ambiguity in most languages? I think the only languages I've seen where it would matter are functional languages. e.g. I think it'd be possible to write a Python program using spaces instead of underscores, and be able to unambiguously parse it with a slightly modified parser?

The classic example of why whitespace in identifiers arguably causes more problems than it solves is https://www-users.york.ac.uk/~ss44/cyc/p/fbug.htm.

Since the space of valid syntax becomes so much larger, typos are more likely to result in valid but incorrect programs. Especially in dynamic interpreted languages like python.

Re: CamelCase vs underscores: Scientific showdown (2011)

#114
post #29

I prefer to use a language's convention, whatever that might be. The language's standard library will expose names using the language's convention, and using a different convention for my own code's names would make for strange and confusing looking code.

Issues arise when you're dealing with multiple languages. Say, if you're working on a Java app (which uses camelCase) backed by a Postgres database (which uses snake_case).

Postgres in particular has case-sensitivity quirks if you try to force the use of camelCase table names.

Re: CamelCase vs underscores: Scientific showdown (2011)

#115
post #34
post #29

I prefer to use a language's convention, whatever that might be. The language's standard library will expose names using the language's convention, and using a different convention for my own code's names would make for strange and confusing looking code.

What if you are creating a new language? Which one would you use?

CAmelCAse (not to be confused with DromedaryCase, which has one hump).

Re: CamelCase vs underscores: Scientific showdown (2011)

#117

Earlier quoted context omitted.

It's a joke. I made it up. Probably not a good idea to propagate it. ;) I think that there is an official name for lowercase-prefixed CamelCase, but I don't remember it.

That's camelCase. Uppercase would be PascalCase.

dromedaryCase has one hump. camelCAse has two humps. (I appreciated the joke; and biologists everywhere will thank you).

Re: CamelCase vs underscores: Scientific showdown (2011)

#118
post #4

Underscore is a double-pinky keystroke. As someone who has battled RSI, I stopped using snake case and underscore-prefixed member variables because of the added stress all those underscores place on the weakest fingers.

Why are you not bending the keyboard's will to your whims ?

Re: CamelCase vs underscores: Scientific showdown (2011)

#119
post #34
post #29

I prefer to use a language's convention, whatever that might be. The language's standard library will expose names using the language's convention, and using a different convention for my own code's names would make for strange and confusing looking code.

What if you are creating a new language? Which one would you use?

The objectively superior kebab-case of course :)

Re: CamelCase vs underscores: Scientific showdown (2011)

#120
post #35

I'm firmly in the camp that doesn't care what the rule/style is, I just want an unambiguous rule. I'll just use whatever the language conventions are. Snake case in Java, for example, would be a hate crime. So would camel case in C. My general preferences beyond that are: - Opening braces on the same line (I see the article has examples where it's on a new line); - Two space indent, no tabs - No trailing white space.…

> Don't put the return type on a separate line. Generally yes, but stuff like ReturnType , T>>, U, HmmLetsAdd > can be on a line of its own.

    ReturnType,
                T,
            >,
        >,
        U,
        HmmLetsAdd,
    >
Post reply on HN