Live data from Hacker News

Ruby 3.0 Preview 1

ruby-lang.org

81–90 of 207 posts

Re: Ruby 3.0 Preview 1

#81

I really wish Ruby would grow up and deprecate method_missing

> I really wish Ruby would grow up and deprecate method_missing method_missing is a deliberate and principled part of a message-passing approach to object orientated programming that gives you powerful options for composition and delegation. You can say you don't prefer this style of programming, but it's not well-informed to say it's down to immaturity or ignorance of alternatives on their part.

What do you mean by "powerful". Meaning you can type less code. You can still do delegation by writing it out yourself. Or you can also use the Delegator or Forwardable classes to save some typing. I'm not sure what meta programming they use under the hood. Probably define_method or method_missing.

Also, people always forget to throw NotImplemented errors which can lead to some fun to track down bugs if you make a typo sending a message. Which I guess is why you pretty much have to write tests for everything in ruby. This kind of stuff would be caught by a compiler in other languages.

Disclaimer: I don't buy into the idea of "message passing" or a lot of OOP. They're the microservices of programming languages.

Re: Ruby 3.0 Preview 1

#82
It looks like the link they provide for comparing the source of 3.0 and 2.7 is busted on Github, but you can get a sense for the scope of this on GitClear's Open Repos https://www.gitclear.com/open_repos/ruby/ruby/releases. Looks like about 4x more repo evolution has gone into this version than previous.

See also: list of the biggest tickets tackled in 3.0: https://www.gitclear.com/open_repos/ruby/ruby/release/pendin...

Re: Ruby 3.0 Preview 1

#83
post #81

Earlier quoted context omitted.

> I really wish Ruby would grow up and deprecate method_missing method_missing is a deliberate and principled part of a message-passing approach to object orientated programming that gives you powerful options for composition and delegation. You can say you don't prefer this style of programming, but it's not well-informed to say it's down to immaturity or ignorance of alternatives on their part.

What do you mean by "powerful". Meaning you can type less code. You can still do delegation by writing it out yourself. Or you can also use the Delegator or Forwardable classes to save some typing. I'm not sure what meta programming they use under the hood. Probably define_method or method_missing. Also, people always forget to throw NotImplemented errors which can lead to some fun to track down bugs if you make a ty…

> I don't buy into the idea of "message passing" or a lot of OOP. They're the microservices of programming languages.

Then this probably was never the right language for you in the first place.

But let's not say that people with different opinions about language design to you own need to 'grow up'.

Re: Ruby 3.0 Preview 1

#84
Much as I would love to believe Ruby 3.0 delivers some kind of speed bump my simple test of doing what Ruby supposedly does best - parsing a log file with a regex - shows Ruby 16% slower than the Python equivalent.

  Ruby
  puts IO.foreach('logs1.txt').grep /\b\w{15}\b/

  Python
  from re import compile

  with open('logs1.txt', 'r') as fh:
      regex = compile(r'\b\w{15}\b')
      for line in fh:
          if regex.search(line): print(line, end='')
On my MacBook Pro (2013) running Catalina Ruby averaged 1.49 secs and Python 1.27 secs. The file `logs1.txt` is a 20Mb Apache log file. Pre-compilation with:

   reg = Regex.compile /\b\w{15}\b/
   puts IO.foreach('logs1.txt').grep reg
... slowed Ruby down to 1.57 secs.

Using --jit didn't change Ruby's overall time but considering it adds 700ms to Ruby's startup time execution time was faster.

Re: Ruby 3.0 Preview 1

#85
post #75

Earlier quoted context omitted.

It's also not supposed to be used unless you have another method with the same name. Also, what kind of danger are we talking here? I consider mutation dangerous. Danger could also mean it has side effects or that it can raise an error. I wouldn't call it inconsistent but I would call it arbitrary. I would rather just name the method "#{base_method}_#{why_its_dangerous}". For example take ActiveRecord::Base#save and…

Original source here, by the way: https://www.ruby-forum.com/t/conventions-in-ruby-and-the-pri... All of those things are "dangerous" in this sense. It is arbitrary, but that's how Ruby works; there's a gray area shared understanding of concepts. The "principle of least surprise" is literally about Matz, and Matz alone. Yes, something may be surprising to you, or not, but it's not about you. This shared taste/underst…

I have also strayed away from Ruby so I'm out of touch too. The arbitrariness helped get me into Ruby and helped get me out. It's cool if that's your sort of thing but as I get older I'm starting to dislike arbitrary things more and more.

Anyway, I didn't realize who I was replying to when I replied to your first comment. I've seen a few of your presentations and read a lot of your work and I'm a fan.

Re: Ruby 3.0 Preview 1

#86
post #66

This is all great stuff. I’m rather meh on RBS, mainly because separating types from code is less than ideal but I like the potential here. But the right hand assignment operator. What on earth. Nobody asked for that and nobody wants it. Why.

The examples given were all things that would be nice to do in the REPL. What I don’t understand is why not just define it in the repl, then, like ‘_’.

Re: Ruby 3.0 Preview 1

#87
post #59

Earlier quoted context omitted.

Ruby has been referred to as Smalltalk meets Perl, and the problem of dealing with other people's code is one of the main things that kept me in the past from using Perl on text processing projects. The problem of collaborating in Perl was lessened a lot by adhering to Damian Conway's Perl Best Practices. Is there anything similar for Ruby?

Rubocop and you're done. It's the first thing I'd add to any team project just because life's too short for an inconsistent codebase.

This. Rubocop is first class. I'm just flat out done bikeshedding in code. If I'm writing JS, it's an ESLint + Prettier combo — or whatever your taste is, I just don't care. Let's write code and let the machine deal with making sure it isn't too ugly.

Re: Ruby 3.0 Preview 1

#88
post #85

Earlier quoted context omitted.

Original source here, by the way: https://www.ruby-forum.com/t/conventions-in-ruby-and-the-pri... All of those things are "dangerous" in this sense. It is arbitrary, but that's how Ruby works; there's a gray area shared understanding of concepts. The "principle of least surprise" is literally about Matz, and Matz alone. Yes, something may be surprising to you, or not, but it's not about you. This shared taste/underst…

I have also strayed away from Ruby so I'm out of touch too. The arbitrariness helped get me into Ruby and helped get me out. It's cool if that's your sort of thing but as I get older I'm starting to dislike arbitrary things more and more. Anyway, I didn't realize who I was replying to when I replied to your first comment. I've seen a few of your presentations and read a lot of your work and I'm a fan.

I think we followed similar paths; I still love Ruby but my tastes have changed. Rails is still really hard to beat in its area though.

Thank you!

Re: Ruby 3.0 Preview 1

#90

>Rightward assignment statement is added. >fib(10) => x This is exactly the kind of stuff I hated when I had to work with ruby in my last gig and why I will never accept a job using it again - soo many pointless and inconsistent ways to do the same thing ... they have method aliases for collection operations like map/filter in standard library ! .NET went with non-standard SQL-like names (select/where) and I'm not a…

I love all that stuff in Ruby to-date (used in it's appropriate place, following convention, etc) but the rightward assignment feels useless to me.

I have no idea why the few languages that allow it do so. I've never wanted it and I can't imagine it makes parsing simpler in a language where you are sometimes compiling code at runtime and where parsing is already pretty wild.

I've said this before and been wrong so let's hope this turns out to have excellent use cases.

Post reply on HN