Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Brian Kernighan on the Elements of Programming Style [video] (cheney.net)
105 points by extarial on Sept 16, 2018 | hide | past | favorite | 6 comments



For the first example, with the ternary operator, I think the original has an advantage that it does not mention `Armed` twice, unlike the improved version.

The presenter mentions that there are a few extra characters, I know, but my issue is not extra characters, but duplication.


When we talk about duplication we are usually talking about doing some work twice or defining something twice. Using a name twice is not the type of duplication we try to avoid.


I don't think you can simply assert that. People sometimes do try to avoid naming something twice, especially if it has an unwieldy name.

For example, to cube a quantity, I don't like to write "xxx". Imagine if x had another name, like "player_position.x".

Sometimes people try to avoid naming something even once! Such as in an anonymous function.


> https://video.ias.edu/PiTP2009-Kernighan

For some reason this appears as a completely blank page to me.


It's a rather large page with tons of JS, but whose only apparent purpose is to embed YouTube video 8SUkrR7ZfTA which a sibling comment here has already linked.




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

Search: