Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I just don't think that forcing code to read like English necessarily makes the code any more readable. Sure, if you read it out loud it comes out sounding somewhat like a sentence. That's cool and everything, but when I'm reading code to, you know, understand it... I want it to be succinct and completely unambiguous.

Here's a great example from Ruby: `unless is_allowed == false`

Reads like English? Check. Sane code? No way. As @heycarsten put it: http://twitter.com/#!/heycarsten/status/28042439329

So I'm suggesting that 'reads like English' isn't the goal you should be aiming for. It's sane, readable code. Sometimes that's English-like (`return x if y`) and other times it's code-like (`list.map( func )`).

Obviously there's room for personal preferences to color where you fall on this (and most other things) :)



That's not really a non-irrelevant example - it isn't different from a double-negative, which isn't a good way to write non-confusing English.

I don't see a problem with something like `unless forbidden`, though.


Fair enough, I'm only saying that 'like English' isn't some kind of holy grail of understandable code. I like code, I can read code, not every line needs to be turned into a sentence.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: