CamelCase vs underscores: Scientific showdown (2011)
91–100 of 138 posts
Re: CamelCase vs underscores: Scientific showdown (2011)
#92I 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.
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)
#93Why can't we just have spaces in our variable names? These are both work arounds.
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)
#94Underscores are harder to type, at least on a US keyboard layout. To me, that's the single largest tag against underscore_separation.
Re: CamelCase vs underscores: Scientific showdown (2011)
#95Earlier 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…
Re: CamelCase vs underscores: Scientific showdown (2011)
#96I'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.…
Every developer can control how those tabs are rendered to their preference.
Re: CamelCase vs underscores: Scientific showdown (2011)
#97 foo
modified_foo
foo
modifiedFoo
With underscores, "foo" looks the same whether it stands alone or not.Re: CamelCase vs underscores: Scientific showdown (2011)
#98Earlier 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.
Re: CamelCase vs underscores: Scientific showdown (2011)
#99 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 "_".Re: CamelCase vs underscores: Scientific showdown (2011)
#100Why can't we just have spaces in our variable names? These are both work arounds.