Live data from Hacker News

CamelCase vs underscores: Scientific showdown (2011)

whatheco.de

91–100 of 138 posts

Re: CamelCase vs underscores: Scientific showdown (2011)

#92
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.

Just NBSP instead.

It makes sense, you would never want your variable to be line wrapped anyway, right?

The challenge is that _some_ languages define the space to be unicode whitespace, not the space character.

Re: CamelCase vs underscores: Scientific showdown (2011)

#93
post #12

Why can't we just have spaces in our variable names? These are both work arounds.

What about other identifiers? For example class names.

ThisClass thisVariable = null

The above is "obvious", as is the below:

this_class this_variable = null

However what is

this class this variable = null

Is it a variable named "variable" of type "this class this"? Is it a variable named "this variable" of type "this class"? Is it a variable named "class this variable" of type "this"?

Re: CamelCase vs underscores: Scientific showdown (2011)

#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"?

Re: CamelCase vs underscores: Scientific showdown (2011)

#95

Earlier quoted context omitted.

> Yeah no thanks. Soo `a-b` and `a - b` are both potentially valid and different? Like what the sibling comment said: `-b` should be illegal. And I don’t think this would be a big deal in practice for experienced users (used to these rules). For beginners you could build in an error check: give a dedicated error message if you write `a-b` but you happen to have both variables `a` and `b`. Then the compiler can tell t…

> `-b` should be illegal Sure... but I didn't use `-b`. Maybe I've misunderstood. > give a dedicated error message if you write `a-b` but you happen to have both variables `a` and `b` I guess, though the idea of having mutually exclusive sets of identifiers sounds like a nightmare. You can have `a` and `a-b`, or `a` and `b`, but not `a`, `b` and `a-b`... Maybe it wouldn't come up much in practice but it's still a pre…

They’re only mutually exclusive as far as getting a good error message is concerned.

Re: CamelCase vs underscores: Scientific showdown (2011)

#96
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.…

I've gone for tabs ever since I realized it helps with accessibility https://gomakethings.com/tabs-are-objectively-better-than-sp...

Every developer can control how those tabs are rendered to their preference.

Re: CamelCase vs underscores: Scientific showdown (2011)

#98

Earlier quoted context omitted.

> `-b` should be illegal Sure... but I didn't use `-b`. Maybe I've misunderstood. > give a dedicated error message if you write `a-b` but you happen to have both variables `a` and `b` I guess, though the idea of having mutually exclusive sets of identifiers sounds like a nightmare. You can have `a` and `a-b`, or `a` and `b`, but not `a`, `b` and `a-b`... Maybe it wouldn't come up much in practice but it's still a pre…

They’re only mutually exclusive as far as getting a good error message is concerned.

I don't really follow you. If `a = 1; b = 2; a-b = 3; foo = a-b; bar = a - b;` is legal then there would be no error message. Do you mean a warning?

Re: CamelCase vs underscores: Scientific showdown (2011)

#99
IMO, with underscores it is not immediate recognizing the elements of an expression like

    some_var.some_fun(some_param, another_param)
Instead with CamelCase, they are immediately visible:

   someVar.someFun(someParam, anotherParam)

But my preferred syntax is Lisp:

   (some-fun some-var some-param another-param)

   (when this-looks-appealing
      (setf you-like-lisp-syntax true)
      (vote-poll 'camel-case-formatting))
IMO, "this-looks-appealing" is more readable than "thisLooskAppealing", but "-" is more space friendly respect "_".
Post reply on HN