Live data from Hacker News

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

jesseduffield.com

1–10 of 326 posts

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

#3

I had to read the title five times to decide if I was supposed to read it. I'm sold.

I’m one of those weirdos who can inline a double negative instantly so, I didn’t read it yet but I probably will because I’m curious about the title anyway

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

#4
I don’t disagree with the essay, and I do generally dislike “unless” as it’s a cutesy statement which does not pull its weight (it would probably be better if there was no “else” clause at all).

However I find some of the examples / justifications unfortunate e.g.

> I find the second option less readable because it suggests that raising the error would be the normal thing to do, when in fact it’s the exceptional thing to do.

It’s not tho. The normal thing to do is to reject access, being an admin is exceptional. A restricted endpoint should absolutely assume the user is not authorised.

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

#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.

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

#6

I had to read the title five times to decide if I was supposed to read it. I'm sold.

I’m one of those weirdos who can inline a double negative instantly so, I didn’t read it yet but I probably will because I’m curious about the title anyway

Oh my dear lord I didn’t think I’d actually disagree with the f’ing article but I had like 8 cases today that made me wish I had a built in if-not keyword! I mean, every language with the billion dollar mistake probably needs a language feature designed to pay back some of that.

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

#7
post #4

I don’t disagree with the essay, and I do generally dislike “unless” as it’s a cutesy statement which does not pull its weight (it would probably be better if there was no “else” clause at all). However I find some of the examples / justifications unfortunate e.g. > I find the second option less readable because it suggests that raising the error would be the normal thing to do, when in fact it’s the exceptional thin…

Fair enough argument for that particular example, but I think the author's point still stands for the other example (if !user.suspended do send_email end)

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

#9
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.

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

#10
The visual difference between a ! and an l is not that great,

    send_email if !user.suspended?
or

    send_email if luser.suspended?
The latter could easily be an aggressive dev sending abusive emails to users they dislike enough to call lusers, at first glance at least ...
Post reply on HN