Live data from Hacker News

CamelCase vs. underscores: Scientific showdown

whathecode.wordpress.com

1–10 of 60 posts

Re: CamelCase vs. underscores: Scientific showdown

#2
From the OP's list of "Pro CamelCase":

> Camel case is easier to type, and underscores are hard to type.

I'll grant it that, but in the context of programming, this does not seem to be a "pro". After all, don't we spend far more time reading code than we do writing code?

I'm old, but I'm still surprised at how I have to fight over my reluctance to do something in another language (such as Python) when I remember that it's conventionally camelCase...on the other hand, I try to use it as a personal advantage...I can immediately tell in a body of code what helper functions originated from me, as I'll habitually write them in underscore (though this probably annoys the shit out of anyone who then tries to read/use my code).

Conversely, my enthusiasm for using R jumped when I read Hadley Wickham's style guide and saw that he endorsed underscores (http://r-pkgs.had.co.nz/style.html)

Re: CamelCase vs. underscores: Scientific showdown

#3
As of right now the results are as follows:

- CamelCase 52.34% (4,493 votes)

- underscores 47.66% (4,092 votes)

Which kind of says it all. Use whatever style you want, stop worrying so much about what other people are doing. Variable names a far more important than the formatting you use with them.

Re: CamelCase vs. underscores: Scientific showdown

#6
I really like underscores for two word variable names. It only becomes a problem when you have variable names which are overly long, and your eyes have to move further.

     if(Accounts_Orders_Invoices_Table.Order_Invoice_Number == Order_Invoice_Number){ ...}    
     if(AccountsOrdersInvoicesTable.OrderInvoiceNumber == OrderInvoiceNumber){ ... }    
But I don't really care that much. I'll just do whatever everyone else is doing. At least camcelCase keeps me from reaching for the _ as much and allows me to stay on the A-Za-z more of the time...

Re: CamelCase vs. underscores: Scientific showdown

#7
Try choosing independently of (language) convention, habit or type of the identifiers.

That's the non-starter for me right there. I use whatever convention makes sense in the context of what I'm doing. Language, library and previous code in an existing project all dictate my choice in this matter.

Re: CamelCase vs. underscores: Scientific showdown

#9
post #2

From the OP's list of "Pro CamelCase": > Camel case is easier to type, and underscores are hard to type. I'll grant it that, but in the context of programming, this does not seem to be a "pro". After all, don't we spend far more time reading code than we do writing code? I'm old, but I'm still surprised at how I have to fight over my reluctance to do something in another language (such as Python) when I remember that…

Agreed, although python convention is for underscores also.

According to pep8 "Function names should be lowercase, with words separated by underscores as necessary to improve readability. mixedCase is allowed only in contexts where that's already the prevailing style"

Re: CamelCase vs. underscores: Scientific showdown

#10
Personal logic bugfix:

    if ( thisLooksLikeJavaOrJavaScriptOr/* ... */ )
    {
        youLikeCamelCase = true;
        votePoll( camelCaseFormatting );
    }
    else if ( this_looks_like_python )
    {
        you_like_underscores = true;
        vote_poll( underscore_formatting );
    }
Variable assignments for this particular piece of code:

    thisLooksLikeJavaOrJavaScriptOr/* ... */ = true;
    this_looks_like_python = false;
Post reply on HN