Live data from Hacker News

CamelCase vs underscores: Scientific showdown (2011)

whatheco.de

71–80 of 138 posts

Re: CamelCase vs underscores: Scientific showdown (2011)

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

Very reasonable but, changing func name for sake of code style sounds like a step too far. Also (i = i ; i Whoever does that do not change it, they are probably a psychopath. Dont risk your life correcting them.

> Whoever does that do not change it, they are probably a psychopath

French generally adds a space before punctuation.

Re: CamelCase vs underscores: Scientific showdown (2011)

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

I generally agree but there are two problems:

1. You're writing C++. You've really lost half the battle laready :) and

2. Writing correct templated code is difficult and should generally be reserved for when you're writing a library; and

3. For complicatred types like this, one should strive to increase readability by using type aliases, assuming your language supports it (eg C++ and Hack do). It's not always possible.

Re: CamelCase vs underscores: Scientific showdown (2011)

#74

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…

We are already not allowed to use keywords as variables, this wouldn't change that.

I've never written a compiler, but I don't see how the last lines are harder to parse:

  if ( thisLooksAppealing )
  {
      youLikeCamelCase = true;
      votePoll( camelCaseFormatting );
  }
  else if ( this_looks_appealing )
  {
      you_like_underscores = true;
      vote_poll( underscore_formatting );
  }
  else if ( this looks appealing )
  {
      you like spaces = true;
      vote poll ( space formatting );
  }

Re: CamelCase vs underscores: Scientific showdown (2011)

#75

Earlier quoted context omitted.

Very reasonable but, changing func name for sake of code style sounds like a step too far. Also (i = i ; i Whoever does that do not change it, they are probably a psychopath. Dont risk your life correcting them.

> Whoever does that do not change it, they are probably a psychopath French generally adds a space before punctuation.

So I was right!

Re: CamelCase vs underscores: Scientific showdown (2011)

#76

Earlier quoted context omitted.

var search result = users. find all by name (name); if (search result. is present()) { return ok(search result. get()); } else return not found(); It’s weird and syntax highlighting is absolutely necessary to read this.

Using something else than a dot is better, same as using a slightly different syntax: search result := users @ find all by name (name) if search result @ is present() { return ok(search result @ get()) } else { return not found() }

I still think the space adds more readability than the dot dectracts. If you don't like the dot though, I would use a comma. We have been writing for a couple centuries now, and the comma is well known and used.

   search result := users, find all by name (name)

   if search result, is present() { 
      return ok(search result, get())
   } else {
     return not found()
   }

Re: CamelCase vs underscores: Scientific showdown (2011)

#78
post #76

Earlier quoted context omitted.

Using something else than a dot is better, same as using a slightly different syntax: search result := users @ find all by name (name) if search result @ is present() { return ok(search result @ get()) } else { return not found() }

I still think the space adds more readability than the dot dectracts. If you don't like the dot though, I would use a comma. We have been writing for a couple centuries now, and the comma is well known and used. search result := users, find all by name (name) if search result, is present() { return ok(search result, get()) } else { return not found() }

I have to confess I rather like that comma!

Re: CamelCase vs underscores: Scientific showdown (2011)

#79
post #49
post #21

Earlier quoted context omitted.

Classical Latin used all caps no spaces, so rather than caught on we moved away from it. https://en.wikipedia.org/wiki/Scriptio_continua

From the article: "paleographers today identify the extinction of scriptio continua as a critical factor in augmenting the widespread absorption of knowledge in the pre-Modern Era. By saving the reader the taxing process of interpreting pauses and breaks, the inclusion of spaces enables the brain to comprehend written text more rapidly."

I_suppose_causality_would_be_difficult_to_establish_here_but_it_is_intriguing_nonetheless._A_little_space_between_words_helps_the_eye_quickly_see_word_boundaries_which_is_helpful_because_in_the_English_language_words_roughly_correspond_to_units_of_meaning.

Re: CamelCase vs underscores: Scientific showdown (2011)

#80
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…

> 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 that you probably meant `a - b`.

> Also allowing hyphens generally leads to issues when interoperating with other languages that don't support hyphens.

Make underscore illegal in the language. It’s not like you need them anymore. In turn you have a bidirectional translator.

Post reply on HN