Live data from Hacker News

Ruby vs. Crystal Performance

ptimofeev.com

1–10 of 151 posts

Re: Ruby vs. Crystal Performance

#2
I'm excited to see Crystal grow - I think it has a lot to offer. I know it's not an intended consequence or a goal of Crystal's development, but you'd be surprised how easily plain Ruby maps to Crystal's syntax and method name choices. It can come in handy when you're looking for an easy performance boost.

Re: Ruby vs. Crystal Performance

#4
post #3

Crystal is quite interesting, but a fib benchmark?

I mean it's kinda trivial but it does have the added benefit of also showing off that it's statically typed. For a more real world example check out the website of Kemal (Crystals Sinatra equivalent) at https://kemalcr.com/, where it benchmarks at ~46k requests per second in a HTTP benchmark vs 4k in Ruby.

Re: Ruby vs. Crystal Performance

#5
The recursively written Fibonacci benchmark is terrible for comparing a interpreted language to a compiled language. When compiling with optimizations in C, for example, the compiler significantly transforms the program. [1] It's possible Crystal does too.

[1] https://godbolt.org/z/vaESBG

Re: Ruby vs. Crystal Performance

#7
post #5

The recursively written Fibonacci benchmark is terrible for comparing a interpreted language to a compiled language. When compiling with optimizations in C, for example, the compiler significantly transforms the program. [1] It's possible Crystal does too. [1] https://godbolt.org/z/vaESBG

Recursive fibonacci is highly artificial, but the fact that a compiler can greatly transform the program is an important advantage of compilers over interpreters.

Re: Ruby vs. Crystal Performance

#9
post #8

What’s the elevator pitch on Crystal? Seems like typed Ruby with performance considerations.

Exactly, it's basically statically typed, compiled Ruby with really good performance.

Also it has really powerful type inference, which allows you to write really Ruby-like code while maintaining your static typing. The downside of that is that it makes the compiler kind of slow.

Re: Ruby vs. Crystal Performance

#10
post #4
post #3

Crystal is quite interesting, but a fib benchmark?

I mean it's kinda trivial but it does have the added benefit of also showing off that it's statically typed. For a more real world example check out the website of Kemal (Crystals Sinatra equivalent) at https://kemalcr.com/ , where it benchmarks at ~46k requests per second in a HTTP benchmark vs 4k in Ruby.

Or something like Sidekiq in Crystal [1], which was 7 times faster. But now I wonder how much faster would Sidekiq run on TuffleRuby.

[1] https://github.com/mperham/sidekiq.cr

Post reply on HN