Reputation: 880
I would very much like to know what exactly makes Crystal faster than Ruby while code is so similar. The short answer could be that it is compiled, and Ruby is interpreted, yet I would like to understand more about the language specifications.
Upvotes: 24
Views: 1210
Reputation: 2926
I guess it's a combination of things:
to_s(io)
writes to an IO instead of converting the object to a string in memory. Or we have tuples for fixed-sized arrays that are allocated on the stack. Or you can declare a type as a struct to avoid heap allocations.Probably there are many more reasons, but they are related.
Upvotes: 45