top | item 15998892

Ruby 2.0 Works Hard So You Can Be Lazy (2013)

63 points| thibaut_barrere | 8 years ago |patshaughnessy.net

11 comments

order
[+] geraldbauer|8 years ago|reply
If you're interested in ruby and the upcoming ruby 2.5 release on Dec/25th - may I highlight the Ruby Advent Calendar 2017 [1] incl. Ruby 2.5 news and highlights 25 ruby libraries / gems. Happy holidays / christmas and hacking w/ ruby. [1]: https://planetruby.github.io/advent2017
[+] izietto|8 years ago|reply
I love this thing that Ruby publishes a new release on Christmas. I usually don't like Christmas, but this is an appreciated present.
[+] iddan|8 years ago|reply
Relevant to Python 3 as well: a lot of methods has updated to use iterators when they can making the lazy and much more efficient
[+] kevin_thibedeau|8 years ago|reply
Iterators on small lists aren't always more efficient.
[+] trop|8 years ago|reply
Hence the first lazy evaluation example becomes something like

  import itertools
  list(itertools.islice(itertools.count(),10))
Though perhaps there is a more elegant (if not more efficient) way to do this?
[+] stevebmark|8 years ago|reply
Does optimizing Ruby have diminishing returns? It doesn't have a JIT and it's all late method lookups, seems like that would be a much higher performance win, to remove the runtime metaprogrammed nightmare soup. I also wonder if that's even compatible with the language at all.
[+] rubystallion|8 years ago|reply
Would be nice to have an implementation in pure ruby of this to play around with. In the meantime it's good the article is well illustrated.