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

Maybe I'm in a minority, but I genuinely dislike conditions placed afterwards.

They feel great to type out when you're in the flow, but coming back and reading them grates on my nerves. Seeing the condition first means I load a logical branch into my mental context. Seeing the condition after means I have to rewrite the context of what I just read to become part of a logical branch, and now the flow of reading is broken.



Try thinking of it as prefix if and infix if?

And in any event it’s a very natural language pattern if you know what I mean.


Ostensibly, code is read more than it is written. I'd rather stick to forms that favor staying in a flow.

Natural language patterns are conversational, and / or use pacing to create emphasis and imply meaning.

With code, we aren't reading a natural language. Injecting natural language conventions amongst things like some_string.chars.each { |c| ... } Is entirely unnecessary and unhelpful in my not very humble opinion.


I’m not really sure what you mean. Both prefix and infix if are both based on natural language conventions. So, for that matter, is reading code from left to right and any other number of patterns.

The infix if form is as if not more readable than the prefix if in cases where only a single statement is guarded.

I mean we could code without any pesky natural language at all by using some kind of lambda calculus with de Bruijn indices, but I think most people would find that considerably less readable.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: