Live data from Hacker News

Read this post ‘unless’ you’re not a Ruby developer

jesseduffield.com

91–100 of 326 posts

Re: Read this post ‘unless’ you’re not a Ruby developer

#91
post #13
post #5

The worst thing about `unless` and double negatives, is having been raised in a culture with different double negative rules than English. In Italian a double negative is still negative. I know boolean logic pretty well, but `unless !something` still trips me up to this day.

There are two different kinds of double negatives and English actually has both. E.g. `I can't get no satisfaction` is structurally equivalent to French `ne ... pas`, i.e the second `no` is a reaffirmation, not a negation. On the other hand `read this unless you're not a developer` is a logical double negation and thus equivalent to `read this if you're a developer`. In practice of course there are usually implied su…

The phrase for what's going on in that Rolling Stones lyric is "Negative concord" and yes, it's normal in many languages and that includes a lot of non-prestige English variants.

"Ain't nobody got time for that" is clear, likewise "I didn't go nowhere" and "He ain't take nothing from nobody" and when something is not clear ("That ain't nothing" could mean it is, or it is not, something) context usually suffices.

Re: Read this post ‘unless’ you’re not a Ruby developer

#93

I don't have a problem with double negation but I hate ruby for this kind of design - pointless aliases for everything. It's the exact opposite of pythons "There should be one– and preferably only one –obvious way to do it" - they intentionally create solutions that have zero practical benefit - it's just fuels arguments based on preferences and introduces mental overhead due to inconsistency.

I love Ruby for this kind of stuff. You don't have to have arguments about which syntax you prefer, you can just use the one you prefer and let your coworkers use theirs.

However, a lot of developers love very strict style guidelines. I've never understood why, but it's a discussion I get into very very often.

Re: Read this post ‘unless’ you’re not a Ruby developer

#94

I really don’t understand the author’s point about adding extra conditions. They admit that many people will find a single condition with `unless` more readable. They then complain that it becomes unreadable when adding another condition. OK, so swap it out for an `if` at that point. No one is forcing you to keep using `unless` if the requirements change. “You should use a suboptimal solution to cater for unknown fut…

To be fair, he makes the point that

> there’s this bizarre quirk of human psychology where developers retain the unless against all odds

I have refactored a number of unwieldy `unless` statements written by colleagues so maybe there’s something to that.

Re: Read this post ‘unless’ you’re not a Ruby developer

#96
post #15

I don't have a problem with double negation but I hate ruby for this kind of design - pointless aliases for everything. It's the exact opposite of pythons "There should be one– and preferably only one –obvious way to do it" - they intentionally create solutions that have zero practical benefit - it's just fuels arguments based on preferences and introduces mental overhead due to inconsistency.

To be fair, Ruby inherited "unless" from Perl. And Perl literally has the opposite design principle, TIMTOWTDI or "there is more than one way to do it". I'm not arguing here -- I prefer the "one obvious way" principle. But you can design a beautiful programming language without regard for the long-term learnings of software engineering. I always liked Perl's "unless", and I always made sure to not abuse it with doubl…

[deleted]

Re: Read this post ‘unless’ you’re not a Ruby developer

#97

I don't have a problem with double negation but I hate ruby for this kind of design - pointless aliases for everything. It's the exact opposite of pythons "There should be one– and preferably only one –obvious way to do it" - they intentionally create solutions that have zero practical benefit - it's just fuels arguments based on preferences and introduces mental overhead due to inconsistency.

People can prefer the "one obvious way" and you can use a language that has that as its motto. Ruby was built with "developer happiness" as an objective and I don't see it changing any time soon.

I'll never understand these sorts of articles because they criticize the subject for not being what they explicitly aren't.

"I hate spoons because they can't cut like knives"

Re: Read this post ‘unless’ you’re not a Ruby developer

#98

I really don’t understand the author’s point about adding extra conditions. They admit that many people will find a single condition with `unless` more readable. They then complain that it becomes unreadable when adding another condition. OK, so swap it out for an `if` at that point. No one is forcing you to keep using `unless` if the requirements change. “You should use a suboptimal solution to cater for unknown fut…

I believe this is somewhat prevalent in the Ruby community as of late where people try as hard as possible to "lock down" the language and limit the ways you can get to a solution in the name of the proverbial "ease of understanding".

I wholeheartedly disagree and believe we should instead grow the developers to understand these different approaches as opposed to labeling half of the language "bad practice".

As I said in another comment. Ruby was built to have multiple ways of doing the same tasks and criticizing it for this is... pointless.

Yes people can create monstrosities with all of these variations, but that's true with any powerful tool. If you dislike Ruby for being Ruby, pick another language.

Re: Read this post ‘unless’ you’re not a Ruby developer

#99
This is a useful feature to have when writing one liners e.g.

    % cat words
    all
    these
    worlds
    are
    yours
    
Which I believe is one of the reasons Perl allows it:

    % perl -ne 'print unless /^a/' words
    these
    worlds
    yours
And Ruby does too:

    % ruby -ne 'print unless /^a/' words
    these
    worlds
    yours

Re: Read this post ‘unless’ you’re not a Ruby developer

#100
Ruby is not the only language with "unless", actually. For example it exists in GNU Guile as well (https://www.gnu.org/software/guile/manual/html_node/Conditio...). However, due to the usual structure of functions and the last expression being the return value, one always expects a return value (why else call the function?). So "when" and "unless" are only seen inside procedures, which have side effects.
Post reply on HN