CamelCase vs underscores: Scientific showdown

 6 months ago
source link: https://news.ycombinator.com/item?id=5224531
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

CamelCase vs underscores: Scientific showdown

I was surprised to see a 50:50 split for camelcase vs underscores, especially with a reasonably sized sample (~1500 votes)

My own preference is for underscores and judging by a lot of the javascript I read I was expecting a landslide in favor of camelcase.

I'm with you on preferring underscores.

I noticed that one of the 'benefits' of CamelCase was that it's easier (aka. faster) to type however I'm not convinced that's a benefit. In my mind, each line of code should involve spending some time thinking about its content and structure both as an individual line and within the context of the broader codebase. Underscores force you to slow down and consider your variables and to me that seems beneficial.

Maybe if you're hacking together some fast script that you want to rapidly test and debug then coding speed would be beneficial but I have always approached coding as a slower, more deliberate step-by-step process. This may however stem from my mainly doing code in Matlab, et. al. for computational analysis, where considering how the maths is performed is just as important as laying down variables.

(Disclaimer: Unless I'm doing a night-before homework assignment in uni, at which point my variable names become 'fuck', 'fuckfuck', 'fuckitall', etc.)

yeah, pretty much all recent languages seem to promote camelCase everywhere. I know pretty much all Java books say its good practice to use it.
Given the many views this blog post has gotten, I've decided to finally write up a short summary of some follow up studies which have been done: http://whathecode.wordpress.com/2013/02/16/camelcase-vs-unde...
I'd be okay with consistently using underscores, but a pet peeve of mine is that Python's PEP 8 underscoring rule is subjective; you're allowed to do things like "isinstance" because it's "easy" to read, so when you use some method you really have no idea if it'll be some_method(...) or somemethod(...) :/
Speed of reading is not a benefit; I prefer careful comprehension to quick comprehension.
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact


About Joyk

Aggregate valuable and interesting links.
Joyk means Joy of geeK