Live data from Hacker News

Ruby delights built into the language

technology.doximity.com

11–20 of 89 posts

Re: Ruby delights built into the language

#11

Earlier quoted context omitted.

Someone submitted it and people voted on it.

Quoted post unavailable.

From the guidelines: Please don't post shallow dismissals, especially of other people's work

There are tons of examples, with links to the code, I think it's fairly informative.

Re: Ruby delights built into the language

#12
This article is kind of niche... My favourite Ruby delights are among others, methods provided by the Enumerable mixin https://rubyapi.org/3.1/o/enumerable. There's a pile of functionality there that helps with tedious tasks. E.g. here's a solution to this year's AOC challenge #6 using Enumerable's each_cons method:

    File.read('input6.txt').chars.each_cons(4).find_index { _1.uniq == _1 } + 4

Re: Ruby delights built into the language

#13
This almost reads more like a list of cruft which should be removed from the stdlib (obviously not benchmark.rb though). For delegation it is probably better to use forwardable and be explicit about delegated methods--delegate.rb smells like it uses method_missing magic.

Re: Ruby delights built into the language

#14

This almost reads more like a list of cruft which should be removed from the stdlib (obviously not benchmark.rb though). For delegation it is probably better to use forwardable and be explicit about delegated methods--delegate.rb smells like it uses method_missing magic.

I mean, no one's making you use this functionality, why should it be removed?

Re: Ruby delights built into the language

#15

This almost reads more like a list of cruft which should be removed from the stdlib (obviously not benchmark.rb though). For delegation it is probably better to use forwardable and be explicit about delegated methods--delegate.rb smells like it uses method_missing magic.

I mean, no one's making you use this functionality, why should it be removed?

Not the parent, but my usual response to this is always "well someone's going to use it in the codebase, which means I'm going to have to end up using it too".

Re: Ruby delights built into the language

#16

This article is kind of niche... My favourite Ruby delights are among others, methods provided by the Enumerable mixin https://rubyapi.org/3.1/o/enumerable . There's a pile of functionality there that helps with tedious tasks. E.g. here's a solution to this year's AOC challenge #6 using Enumerable's each_cons method: File.read('input6.txt').chars.each_cons(4).find_index { _1.uniq == _1 } + 4

I struggle with code like this (also, complicated piped shell statements). How do you debug/reason about this? I know this specific example may be an exercise, but still.

Re: Ruby delights built into the language

#18

This almost reads more like a list of cruft which should be removed from the stdlib (obviously not benchmark.rb though). For delegation it is probably better to use forwardable and be explicit about delegated methods--delegate.rb smells like it uses method_missing magic.

I mean, no one's making you use this functionality, why should it be removed?

Once things are in the standard library, they're basically impossible to remove, unless you want to break everyone's code and prevent them from updating.

If you're making a new programming language today, the standard library is a place where you should think very carefully about everything you add. Every programmer learning the language will have to be familiar with the standard library, so keeping it small is good. But too small, and programmers will always have to reach for third-party packages without maintenance or stability guarantees. For example, you don't want to have to choose among 5 different libraries to write and run unit tests; the language should define that and it should meet everyone's needs (or be extensible with a small third-party library).

I think the Rubys and the Perls of the world probably choose too much to add to the standard library, and that's where the comment you're replying to comes from. But, while it's easy to overdo the standard library, it's also bad if you underdo the standard library. Tough and sometimes under-considered aspect of language design.

Re: Ruby delights built into the language

#19

Earlier quoted context omitted.

I mean, no one's making you use this functionality, why should it be removed?

Not the parent, but my usual response to this is always "well someone's going to use it in the codebase, which means I'm going to have to end up using it too".

Yeah, code maintenance isn't actually free.

Re: Ruby delights built into the language

#20

Earlier quoted context omitted.

Someone submitted it and people voted on it.

Quoted post unavailable.

People that write ruby usually do so because they like ruby (as opposed to just doing it for a job, etc). Therefore, people who write ruby are probably going to upvote submissions about the cool quirks of ruby -- and there are a lot of people who write ruby.
Post reply on HN