Live data from Hacker News

Ruby 2.5.0 Released

ruby-lang.org

51–60 of 113 posts

Re: Ruby 2.5.0 Released

#51

i loved ruby and i still do but my focus has now shifted to scheme/clojure and lisp family dialects like racket, and i don’t see a reason to return or move to anything else it feels like my search is over.

If your "search is over", you're doing it wrong. Something sucks about everything you are using, no matter what it is. There is a better thing, even if you must make it.

Re: Ruby 2.5.0 Released

#52
post #46

When I discovered Ruby 12 years ago, it was an amazing moment. All the features I loved from my previous favorite languages Perl, Smalltalk, and Scheme in one place, but with a much more reasonable syntax, a far more robust standard library, a complete and dead-simple packaging system, and a practical and portable runtime. The fact that it still feels magical, fun, practical, and pragmatic all at the same time while…

I started a new contracting gig a couple of months ago, in Ruby. I had used it briefly years before in another project, but it was so long ago that I had to learn it again basically from scratch. Although I don't really think the language is anything special (i.e. it's a standard dynamic OO language), what really turns me off Ruby is this dogmatic, almost religious aspect of its community. Take POODR - it's more or l…

I'll pile on here with another counter data point to say that having written Ruby (both Rails and otherwise) for 7 years, and having read POODR, I do not understand where you're getting this dogma idea from. I have yet to experience a single instance of "It's POODR's way or the highway."

Re: Ruby 2.5.0 Released

#53

Was waiting for this!! Super happy about this. I’ve come to expect this every year now at this time. Ruby is still one of the most productive languages out there. I just love it. It gives me great joy that 10 years ago I chose Ruby to be the language for my future. My wish this coming year is to be able to contribute more to the Ruby ecosystem. Btw I’ve also built something using MRuby this year. The whole ecosystem…

I've really wanted to find a good use for MRuby (probably to noodle around with game development, as an embedded language) but figuring out where to start is really hard. Any tips?

Re: Ruby 2.5.0 Released

#54
post #32

Earlier quoted context omitted.

What would the elegant Ruby version look like, and what was inelegant about the Python version? In Python I imagine you could just do something like this: from time import sleep sleep_increment = 1 sleep_time = 0 success = False while not success: sleep(sleep_time) success = try_thing() sleep_time += sleep_increment

def backoff(wait = 5, exponent: 1.5) yield rescue BackoffError sleep(wait) wait = wait ** exponent retry end backoff { connect_to_a_thing } This is trivially composable with any other control flow you might want to write in Ruby. Personally I find the Python approach inelegant. Can it be composed? Why am I having to work with low-level looping constructs instead of higher level control flow constructs that map more c…

It looks like the Ruby-specific elements here are (1) the 'retry' statement, and (2) the ability to yield a block twice (Python's equivalent `with` syntax explicitly prohibits re-yielding a block).

(1) might just be a matter of taste -- that 'retry', to me, makes me now have to step back and think "oh, I'm retrying something now? what exactly is being retried here?" Having it all wrapped up in a 'while' loop makes the intent explicit right from the get-go.

(2) I agree is nice. It would be great if you could do this:

    with backoff():
        connect_to_a_thing()
but you're not allowed to 'yield' twice inside a context manager. However you can get damn close (and fully composable) by wrapping the connection logic and the retry logic in functions:

    def connect_to_a_thing(url, access_token):
        ...

    def backoff(connector, wait=5, exponent=1.5, *args, **kwargs):
        success = False
        while not success:
            try:
                connector(*args, **kwargs)
            except BackoffError:
                sleep(wait)
                wait = wait ** exponent
            else:
                success = True

    backoff(connect_to_a_thing, url, access_token)
Or you could be even more explicit with recursion:

    def backoff(connector, wait=5, exponent=1.5, *args, **kwargs):
        try:
            connector(*args, **kwargs)
        except BackoffError:
            sleep(wait)
            backoff(connector, wait ** exponent, exponent, *args, **kwargs)
As for your point about loop indices, Python generally has wonderful support for not worrying about loop indices and counters. I'm also not sure how that applies in this case; you still need to increment the value of 'wait'. Then again...

    def exponentiate_forever(value, exponent):
        while True:
            yield value
            value = value ** exponent

    def backoff(connector, wait=5, exponent=1.5, *args, **kwargs):
        for wait in exponentiate_forever(wait, exponent):
            try:
                connector(*args, **kwargs)
            except BackoffError:
                sleep(wait)
            else:
                break
But please don't do that.

Re: Ruby 2.5.0 Released

#56
post #7

I started using Ruby only in April this year due to starting at a new job. Having used and/or dabbled in C, Java, Python and Haskell before (amongst others), I find it super interesting to see how Ruby manages to take some interesting parts from each and manages to integrate it into a very pleasant programming experience. Also the rspec testing library is nothing short of magic, none of the compiled languages have an…

While rspec is indeed nice, I don't get why most projects don't use minitest more. Minitest ships with the Ruby standard library and I much prefer the assert syntax over the rspec DSL.

Rails also uses minitest with fixtures by default, I migrated to it recently and I really like the simplicity.

Re: Ruby 2.5.0 Released

#57
post #46

When I discovered Ruby 12 years ago, it was an amazing moment. All the features I loved from my previous favorite languages Perl, Smalltalk, and Scheme in one place, but with a much more reasonable syntax, a far more robust standard library, a complete and dead-simple packaging system, and a practical and portable runtime. The fact that it still feels magical, fun, practical, and pragmatic all at the same time while…

I started a new contracting gig a couple of months ago, in Ruby. I had used it briefly years before in another project, but it was so long ago that I had to learn it again basically from scratch. Although I don't really think the language is anything special (i.e. it's a standard dynamic OO language), what really turns me off Ruby is this dogmatic, almost religious aspect of its community. Take POODR - it's more or l…

I've been writing Ruby for 4 years, and I had never heard of POODR before.

I've also never come across any particular dogma in the Ruby community -- there are established best practices for formatting code, but individual projects vary widely style and design decisions. Most Ruby codebases I've worked on come with a custom `.rubocop.yml`, and that's it.

Re: Ruby 2.5.0 Released

#58
Oh, it looks like Bundler didn't make it into the standard library for the 2.5 release. The commit to bring it in was reverted just before the release, with very little explanation. I mean, it's not like `gem install bundler` is that hard to do, but I'd be curious to hear why.

Re: Ruby 2.5.0 Released

#59
I absolutely love ruby and its community :) My software goals for next year: - Start a new platform built on Ruby/Rails. - Contribute to the ruby eco-system. - Enjoy it.

Re: Ruby 2.5.0 Released

#60
post #46

Earlier quoted context omitted.

I started a new contracting gig a couple of months ago, in Ruby. I had used it briefly years before in another project, but it was so long ago that I had to learn it again basically from scratch. Although I don't really think the language is anything special (i.e. it's a standard dynamic OO language), what really turns me off Ruby is this dogmatic, almost religious aspect of its community. Take POODR - it's more or l…

I've been writing Ruby for 4 years, and I had never heard of POODR before. I've also never come across any particular dogma in the Ruby community -- there are established best practices for formatting code, but individual projects vary widely style and design decisions. Most Ruby codebases I've worked on come with a custom `.rubocop.yml`, and that's it.

On that note, I'll just plug that http://relaxed.ruby.style is a great starting point for most folks' less...idiosyncratic...Rubocop rules than come with the default.
Post reply on HN