News for hackers. Stuff that matters.
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by pmontra on Wednesday November 10, 2021 @09:47AM (#29175139)
> Rewriting from Ruby to Go, some benchmarks for calculating long streaks showed going from ~5 sec to ~0.04 sec [2].

This is why sometimes it's worth looking for obscure methods in the core or standard library and use them instead of writing Ruby code, especially when iterating on Enumerables. Basically it's rewriting Ruby in C.

Entry level example: minmax_by [1] which does the obvious thing but it's not obvious that every Ruby developer knows about it (disclaimer: I went to the docs and looked for something with a fun name.)

[1] https://ruby-doc.org/core-3.0.1/Enumerable.html#method-i-min...

There are no comments on this comment yet.