Live data from Hacker News

CamelCase vs underscores: Scientific showdown (2011)

whatheco.de

51–60 of 138 posts

Re: CamelCase vs underscores: Scientific showdown (2011)

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

wrap the standard library with your own convention obv

Re: CamelCase vs underscores: Scientific showdown (2011)

#52
post #30

I use both but camel case assumes capitalization doesn't have meaning other than as a sort of break indicator, which isn't always the case.

Behold this monstrosity: devDbUrl

Madness. The only thing worse that developers willingly tolerate is prettier's sacrilegious linebreaks [0].

0: https://prettier.io/playground/#N4Igxg9gdgLgprEAuc0DOMAEBXNc...

Re: CamelCase vs underscores: Scientific showdown (2011)

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

iNVERSEcAMELcASE of course.

Re: CamelCase vs underscores: Scientific showdown (2011)

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

Re: CamelCase vs underscores: Scientific showdown (2011)

#55

The most peeving to me is camel case conventions that preserves the capitalization of abbreviations. Convention that would require TCPIPQOSScore instead of tcpIpQosScore.

I think you can't really win here with camelCase. Both look bad to me.

Re: CamelCase vs underscores: Scientific showdown (2011)

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

> I think the only languages I've seen where it would matter are functional languages.

Yes, ML style function application is a problem and treating newlines as "normal" whitespace without having line separators (aka semicolons). And keywords used as infix operators, like another post reminded me of.

Re: CamelCase vs underscores: Scientific showdown (2011)

#57

Earlier quoted context omitted.

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.

Removing keywords from variables is a big sacrifice when they are often such common glue words, like `and`, `or`, `if`, etc. Say `and` is the keyword and you want a variable called foo_and_bar. To get such words back you would need to add something so that the parser knows if foo and bar == true means foo && bar == true or foo_and_bar == true ? You could fix it with ugliness like making the keyword `@and` or some suc…

Yes, it is, but it would also change the language, it is funny I forget c++ has “and” because && is so ubiquitous. Likely you will get changes so “if” is ? Or something. (Like we wee with ternary operator)

Like I said, I can’t picture the requirement, but am not sure it is a good idea.

Re: CamelCase vs underscores: Scientific showdown (2011)

#58
post #36

just•Give•Me•Extra•Kerning•Or•Ligatures I still don't understand how comes that in times of programming fonts with fancy ligatures there is not a single one that would attempt to make camelCase more legible by slightly separating lowerUPPER sequences (presumably by constructing a "anti-ligature" for each unique pair that would have still width of two glyphs). Or try to do anything similar to ease reading theseAnachro…

Emacs has GlassesMode, which displays (but not actually adds) an underline before every uppercase character https://www.emacswiki.org/emacs/GlassesMode

Re: CamelCase vs underscores: Scientific showdown (2011)

#59
post #3

hyphen-case is worth the grammar concessions (like making whitespace between binary operators mandatory).

Yeah no thanks. Soo `a-b` and `a - b` are both potentially valid and different? Also allowing hyphens generally leads to issues when interoperating with other languages that don't support hyphens. Probably the best example of this is CSS which does allow hyphens, and Javascript which doesn't. `background-color` in CSS gets translated to `backgroundColor` in JS. It's an annoying paper cut that trips up beginners and m…

> Soo `a-b` and `a - b` are both potentially valid and different?

You shouldn't be able to start a name with a hyphen, so `a -b` and `a - b` can be both valid.

But I mostly just came to acknowledge your fitting username ;)

Re: CamelCase vs underscores: Scientific showdown (2011)

#60

Earlier quoted context omitted.

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.

Removing keywords from variables is a big sacrifice when they are often such common glue words, like `and`, `or`, `if`, etc. Say `and` is the keyword and you want a variable called foo_and_bar. To get such words back you would need to add something so that the parser knows if foo and bar == true means foo && bar == true or foo_and_bar == true ? You could fix it with ugliness like making the keyword `@and` or some suc…

That's not necessary at all, even FORTRAN managed to parse

   DO 10 I = 1.100
as

   DO10I = 1.1
and

   DO 10 I = 1,100
as the beginning of a loop ;)
Post reply on HN