Any comments about the new Ruby JIT Compiler
Ecstatic Coder
ecstatic.coder at gmail.com
Sat Jun 23 20:09:46 UTC 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...
More information about the Digitalmars-d
mailing list