Live data from Hacker News

Ruby 2.5.0 Released

ruby-lang.org

31–40 of 113 posts

Re: Ruby 2.5.0 Released

#31

Ruby may not be the cool thing in town it once was, but it remains my preferred language for prototyping ideas - purely because of its elegance and expressivity. It truly delivers on its fundamental goal of "developer happiness". A lot of ideas from Ruby have gone to other languages (CoffeeScript, Elixir) and many web frameworks are modelled after Rails. Congrats and thanks to all the core devs! :-)

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…

Disagree 1000%.

Just because you can write a monstrosity in Ruby doesn’t make the language itself inelegant.

Ruby, of the many languages I’ve used, has by far the highest potential for code being poetry. You can find solutions that are incredibly simple and understandable due to so much boilerplate being remove from the syntax. Likewise you can write code that’s impressively concise without being inscrutable — I’m continually astonished by how readable Ruby can be.

One exercise in particular sticks out in my mind. Many years back, I implemented the first few dozen Project Euler problems in Ruby. However, I imposed a limitation: each solution had to be under 72 characters (library inclusions are fine), a single logical line, and readable. The end result was surprising at how naturally it ended up working — the solutions ended up being little more than the high-level conceptual approach, translated literally to code. Solutions ended up looking like the following:

    (2 ** 1000).digits.sum
    (2..10_000).amicable_numbers.sum
    1901.to_year.upto(2001.to_year - 1).select {|d| d.mday + d.wday == 1 }.count
Sure, these depended upon injecting new methods into core classes, but who cares? For this problem it led toward incredibly straightforward and readable solutions for these problems. If this were library code I wouldn’t dream of doing it this way, but for application code — why not?

I have yet to see any other language with Ruby’s capacity for readable conciseness.

Re: Ruby 2.5.0 Released

#32
post #26

Earlier quoted context omitted.

I think there's a lot about its expressiveness that's elegant. You can't pick one inelegant practice and define the entire language by that — nothing would pass that test. But for example, Ruby's method-based control flow allows for sophisticated ideas to be expressed in a way that's clear but doesn't demand undue attention. A while back I needed to implement a common structure in Python for basically "repeat this op…

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 closely to the task I’m actually trying to accomplish?

Same thing goes for any non-functional looping at this point. Why am I having to care about loop indices, incrementing counters, creating result arrays and inserting items into them, etc.? It’s (almost) 2018 and people are still writing low-level looping logic for the n-billionth time. Worse, people have to read it and parse it for the n-trillionth time to figure out which looping idiom is being used, instead of being able to see at a glance that something is being mapped, selected from, reduced, etc.

Re: Ruby 2.5.0 Released

#33

Nice to see the 3x3 work continuing to go well with that 5-10% speed up. For anyone who hasn’t seen it, Ruby declared a target for Ruby 3.0 to be 3x faster than 2.0. http://engineering.appfolio.com/appfolio-engineering/2015/11...

What particular speed improvements do we expect from 2.5.0 release? String interpolation speedup?

Among others, from the linked article:

    About 5-10% performance improvement by removing all 
    trace instructions from overall bytecode (instruction 
    sequences). The trace instruction was added to support 
    the TracePoint. However, in most cases, TracePoint is 
    not used and trace instructions are pure overhead. 
    Instead, now we use a dynamic instrumentation technique. 
    See [Feature #14104] for more details.

Re: Ruby 2.5.0 Released

#34
looks like we have some gem authors that need to update their stuff...

google-protobuf-3.5.0-universal-darwin requires ruby version = 2.0, which is incompatible with the current version, ruby 2.5.0p0

[update]

looks like this is resolved by forcing bundler to compile instead of grabbing the precompiled versions.

Re: Ruby 2.5.0 Released

#35
post #27
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…

I'd be very interested to know what you mean by "nothing short of magic". I've had a quick look at the rspec documentation and as a Python dev this looks very similar to what's in the Python standard library. Would that be considered magic as well or does rspec have some cool features that I have missed?

rspec’s internal DSL is based on Ruby’s multi-line anonymous functions. I don’t know how you achieve a similar design in Python where you don’t have those in the same way. How do you write the equivalent of ‘it ‘does something’ do ... end’ in Python syntax?

Re: Ruby 2.5.0 Released

#36

Ruby may not be the cool thing in town it once was, but it remains my preferred language for prototyping ideas - purely because of its elegance and expressivity. It truly delivers on its fundamental goal of "developer happiness". A lot of ideas from Ruby have gone to other languages (CoffeeScript, Elixir) and many web frameworks are modelled after Rails. Congrats and thanks to all the core devs! :-)

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…

I don’t think you can call monkey patching inelegant or a hack. Monkey patching is the absence of extra rules - not allowing a method to be defined more than once - and the prescence of consistency - all methods can be redefined.

It’s certainly problematic when used! But the feature itself is elegant and the opposite of a hack. Disallowing monkey patching requires extra conditions and rules, not less.

Re: Ruby 2.5.0 Released

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

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 want to write in Ruby.

And it is actually trivially composable with other Python control flow, it's just a backoff iterator, you can drive it however you want, or compose it with other iterators (e.g. enumerate() to know which instance you're on, islice to stop after a certain number of tries, …)

Re: Ruby 2.5.0 Released

#39

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’m continually impressed by how understandable golfed Ruby tends to be, especially when compared to Perl. Golfed Perl is completely inscrutable, whereas golfed Ruby is often times no less understandable than a longer version.

Re: Ruby 2.5.0 Released

#40
post #27

Earlier quoted context omitted.

I'd be very interested to know what you mean by "nothing short of magic". I've had a quick look at the rspec documentation and as a Python dev this looks very similar to what's in the Python standard library. Would that be considered magic as well or does rspec have some cool features that I have missed?

rspec’s internal DSL is based on Ruby’s multi-line anonymous functions. I don’t know how you achieve a similar design in Python where you don’t have those in the same way. How do you write the equivalent of ‘it ‘does something’ do ... end’ in Python syntax?

This seems a good starting point https://stackoverflow.com/questions/37334668/is-there-a-pyth...

TLDR: not as nice as RSpec but close.

Post reply on HN