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

Wrong is what with Yoda conditions?


Nothing wrong there is. To understand and read them quickly difficult it is.

Subject verb noun, to process, is easier.


For native speakers of English and other Subject-Verb-Object (SVO) languages, anyway; it sounds like a weird variant of passive voice. There are also SOV, VSO, etc. human languages, though.


Dakota has some combos that sound different to English speakers (e.g. phrase: "Mazaska wacin", Mazaska = money, wacin = 'I want').

// my choice of example phrase is based on what I valued as a teenager (and can still remember), not some weird social commentary


Japanese is SOV (subject-object-verb).

I yoda conditions very much hate!! Crazy they me drive!

But I Japanese like.


I really dislike post-statement ifs, like "do_something() if condition?". They seem to be used particularly often in Ruby. I don't know how dependent clauses ("if x then y" vs. "y if x") work in Japanese, but Ruby coming from Japan may be a factor.

"if (3 == x)" doesn't bother me so much, I tend to think of it like unification in Prolog.


    post-statement ifs, ... used particularly often in Ruby. ... Ruby coming from Japan may be a factor.
I think Ruby borrowed them from Perl's Statement modifiers (http://perldoc.perl.org/perlsyn.html#Statement-Modifiers). I like them and use them when I want the focus to be on the body rather than the conditional.


Japanese conditionals come (AFAIK) before statements.

They can come after statements, just like in English, "Tell me if you see him".

I don't use Ruby but I actually like this idea.

Often when reading code, I'm looking for what's being done, not the condition under which it's done. I only look for the condition after I've found the statement.


I got into the habit of writing literals first from being bitten one too many times by the (absolutely insane!) semantic difference between "=" and "==".

In my day job (working with Java) it's less of a problem, but I switch languages so much in my spare time that it has served me well.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: