Thread overview
Any comments about the new Ruby JIT Compiler
Jun 13, 2018
bauss
Jun 13, 2018
Anton Fediushin
Jun 13, 2018
bauss
Jun 23, 2018
Ecstatic Coder
June 13, 2018
The compilation is done by using the C compiler in the background.

https://www.ruby-lang.org/en/news/2018/05/31/ruby-2-6-0-preview2-released/

Could D be an better choice for that purpose?


Any comment?
June 13, 2018
On Wednesday, 13 June 2018 at 08:21:45 UTC, Martin Tschierschke wrote:
> Could D be an better choice for that purpose?
>

I would say yes. Especially if we're talking just replacing the C code with D (using betterC.)

See: https://dlang.org/blog/2018/06/11/dasbetterc-converting-make-c-to-d/
June 13, 2018
On Wednesday, 13 June 2018 at 08:21:45 UTC, Martin Tschierschke wrote:
> The compilation is done by using the C compiler in the background.
>
> https://www.ruby-lang.org/en/news/2018/05/31/ruby-2-6-0-preview2-released/
>
> Could D be an better choice for that purpose?
>
>
> Any comment?

Good news for Ruby community, I guess. IIRC jRuby had JIT for a while know and was beating the reference implementation in almost every test. I wonder how is it now?

Too bad they released it now and not, you know, five to seven years ago when ruby was really popular.

D is always a better choice. Somebody, tell them about DasBetterC.
June 13, 2018
On Wednesday, 13 June 2018 at 10:07:03 UTC, Anton Fediushin wrote:
> Too bad they released it now and not, you know, five to seven years ago when ruby was really popular.
>

Partially agrees, BUT it's still somewhat popular with rails.
June 23, 2018
On Wednesday, 13 June 2018 at 08:21:45 UTC, Martin Tschierschke wrote:
> The compilation is done by using the C compiler in the background.
>
> https://www.ruby-lang.org/en/news/2018/05/31/ruby-2-6-0-preview2-released/
>
> Could D be an better choice for that purpose?
>
>
> Any comment?

Wrong strategy...

https://blog.codeship.com/an-introduction-to-crystal-fast-as-c-slick-as-ruby/

"This is a naive Fibonacci implementation for Crystal (it’s also valid Ruby):

# fib.cr
def fib(n)
  if n <= 1
    1
  else
    fib(n - 1) + fib(n - 2)
  end
end

puts fib(42)

Let’s run it and see how long it takes!

time crystal fib.cr
433494437
crystal fib.cr  2.45s user 0.33s system 98% cpu 2.833 total

Since this is also valid Ruby, let’s run it with Ruby this time

time ruby fib.cr
433494437
ruby fib.cr  38.49s user 0.12s system 99% cpu 38.718 total

Crystal took 2.833 seconds to complete. Ruby took 38.718 seconds to complete. Pretty cool. We get 20x performance for free. What if we compile our program with optimizations turned on?

crystal build --release fib.cr

time ./fib
433494437
./fib  1.11s user 0.00s system 99% cpu 1.113 total

crystal-vs-ruby-benchmark

1.113 seconds. Now we’re nearly 35 times faster than Ruby."

Obviously this benchmark will have to be updated, but I don't know how the Ruby developer will manage to beat Crystal with their JIT compilation...