Live data from Hacker News

Ruby 2.5.0 Released

ruby-lang.org

111–113 of 113 posts

Re: Ruby 2.5.0 Released

#111
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…

Not too familiar with Rspec but I know Groovy (a compiled language) has testing frameworks like Spock that I believe are based on Rspec.

> Groovy (a compiled language)

Because of its use in scripting on the JVM(e.g. glue code and Gradle builds), Apache Groovy files are usually stored in the file system as text. Each time they're run, they are "compiled" into JVM bytecode. Although you can get pre-compiled .class and .jar files for Groovy, it's not common for people to build large systems with it.

Re: Ruby 2.5.0 Released

#112

Earlier quoted context omitted.

See, expressive I totally get. Absolutely. But elegance? Don’t understand that one. Ruby is a cluster of inelegant and over concise cludges in the name of expressivity. The fact that it was once most famous for one of the most inelegant hacks - monkey patching - as a core feature speaks to that. So I totally understand that it’s quick, it’s expressive, and it’s easy to prototype in. Agreed. It’s lost a lot of it’s sh…

What's an example of one of those kludges? "Ruby concise" at least looks elegant, whereas, say, "Perl concise" is hideous.

I disagree it even looks elegant. Short? Yes. Better than Perl? Sure, but even Perl fans wouldn’t call it a pretty language.

Re: Ruby 2.5.0 Released

#113
post #69

Earlier quoted context omitted.

Nothing precludes a similar approach in Python: def backoff(wait=5, exponent=1.5): while True: yield sleep(wait) wait = wait ** exponent for backoff(): connect_to_a_thing() Here's the question: do you need exponential backoff in more than one place? Because if you don't, bundling all of that doesn't buy you anything and the original works just fine. > This is trivially composable with any other control flow you might…

Your solution is much cleaner to me, except (not really knowing Python) it looks like it might have a bug, in that the `while True` will never terminate.

> the `while True` will never terminate

The iterator is infinite on purpose (it has no reason to be finite).

You'd terminate it from outside, either when the operation succeeds, so the example loop should more properly be something along the lines of:

    for _ in backoff():
        try:
            c = connect_to_a_thing()
            break
        except ConnectionError:
            pass # retry
or you'd use composition to e.g. stop after a set number of tries:

    for _ in itertools.islice(backoff(), 5):
        # do stuff
most likely a combination of both.
Post reply on HN