Live data from Hacker News

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

jesseduffield.com

131–140 of 326 posts

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

#131
post #128

Unless seems to be pretty common in many languages. https://www.indifferentlanguages.com/words/unless In my mind the javascript community would do well to address the idiosyncrasies in its language standard before criticizing other languages for using common human language patterns. If you want to pick on ruby for being weird with conditionals, consider the following. if 0 puts 'true' end which will print true. I thi…

No post body was provided.

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

#132
Ruby is an interface between at least three realms: the human (typically English conversant), the machine (instruction-based), and logic.

Not unique and not the best, but popular and usable enough to be fascinating for anyone who's given more than passing thought to how difficult it is to communicate in any one realm separately (let alone across realms).

For example, I had a meeting with POs recently where it took an hour to communicate a concept in English and distill a logic diagram from it. I'm not placing blame on English (although some would [1]), POs, or myself. It's just common experience that communication is difficult.

Personally I always enjoy flexibility and expressiveness when writing (English or code), usually when reading (English or code), and sometimes when debugging (English or code). So I like Ruby pretty well. YMMV.

[1] https://news.ycombinator.com/item?id=33513666 & https://news.ycombinator.com/item?id=22689959

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

#133

I'd consider myself a writer more than a developer, but I've been working in Rails for over 15 years, and one of my absolute favourite things is "unless". Why? Because it allows you to express yourself more elegantly. The click-bait title is misleading. It's meant to ridicule "unless", but actually achieves the opposite. If you were to write the title of the post as code, it would be: unless !ruby_dev read article en…

I treat the 'if' statement and the '!ruby_dev' conditional as separate entities. That allows thinking of the conditional alone in boolean logic terms, instead of having to consider the outside prefix statement too.

Therefore, coming from a computer science background I don't like 'unless'.

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

#134
post #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 sai…

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

Agreed 100% with this take. If I only wanted 1 way to accomplish something no matter how inelegant it might be in that context, I would use Python. I choose Ruby specifically because of how expressive it is. It makes it a bit tougher when working in a team with 2 or more opinionated devs, ie. "should we use more functional or more OO approaches to solve a problem" but this is a culture and communication issue, not a language problem. Having a good rubocop setup and staying within the confines of your agreed upon ruleset is a good start.

For example you can use rubocop to enforce dissallowing `unless !condition`, then it's just not an issue anymore - these kinds of issues dissapear before code even makes it to review.

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

#135
post #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 sai…

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

Exactly the reasons I use C++. Well, after crazy performance, efficiency and single executable deployment.

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

#136

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…

Indeed. I personally never fail to avoid not using "unless", unless there isn't a lack of extra conditions such that not refraining from instead using "if" wouldn't avoid not being less clear.

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

#137
post #128

Unless seems to be pretty common in many languages. https://www.indifferentlanguages.com/words/unless In my mind the javascript community would do well to address the idiosyncrasies in its language standard before criticizing other languages for using common human language patterns. If you want to pick on ruby for being weird with conditionals, consider the following. if 0 puts 'true' end which will print true. I thi…

Only false and nil are falsey, and the language shines for it. There is nothing weird about zero being a truthy value.

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

#138
You can contrive bad usage of just about anything in any language. Nobody actually writes "unless ... else". The few times it's come up it's been shot down in code reviews. unless is still perfectly fine for simple one line statements though.

Do I think Ruby NEEDS unless? No. Does this keep me awake at night? No lol

Post reply on HN