Live data from Hacker News

CamelCase vs underscores: Scientific showdown (2011)

whatheco.de

21–30 of 138 posts

Re: CamelCase vs underscores: Scientific showdown (2011)

#21
post #9

I find snake case so much easier to read, breathing space between words is there for a reason.

IAgreeThatSnakeCaseIsEasierToRead,ThoughIfWeWereToUseCamelCaseMoreWeWouldBeSavingAGoodAmountOfSpace,WhichMightBeUsefulForNarrowBlocksOfText.I'mSuprisedItHasn'tCaughtOnInProse.Actually,LookingAtThis,MaybeIt'sAGoodThingItHasn'tCaughtOnForProse.

Classical Latin used all caps no spaces, so rather than caught on we moved away from it.

https://en.wikipedia.org/wiki/Scriptio_continua

Re: CamelCase vs underscores: Scientific showdown (2011)

#22
post #12

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

So that the compiler or interpreter knows the extent of the variable token. Without spaces allowed you would need some other way to tell it where they start and end, like quotes or a special declaration, which would be harder for the brain to parse. If you know a better way please share it.

I am not picturing why this is true, if you cannot use key words as parts of variables (alone separated by a space) and lines end with a newline or semicolon (some symbol)

The first restriction might make this a problem. I am not saying it is a good idea, but it is not obvious to me.

Re: CamelCase vs underscores: Scientific showdown (2011)

#24
post #12

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

In languages without infix function calls, that should be possible, but I'm not sure how readable it would be.

    var initial factory = abstract configuration factory factory. configure new factory()

Re: CamelCase vs underscores: Scientific showdown (2011)

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

In Unicode there's the non-breaking space character. It's even easy to type, at least on Mac: just press Option+Spacebar.

Re: CamelCase vs underscores: Scientific showdown (2011)

#28
post #12

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

PowerShell yet again proves itself to be an enlightened language:

    PS> ${Valid characters for an identifier? Eh, ¯\_(ツ)_/¯ whatever (`}) you want.} = $True
    PS> ${Valid characters for an identifier? Eh, ¯\_(ツ)_/¯ whatever (`}) you want.}
    True
Jesting aside, I have actually used that syntax before to prefix variable names with '&' and '@' to differentiate between virtual and physical addresses in some code for patching a binary.
Post reply on HN