Crystal could be a really powerful tool for enhancing existing Ruby code. Imagine a world where you write your code in Ruby, but farm out the expensive operations to a Ruby-like Crystal extension (similar to what is commonly done with C or Rust). I think this is possible already (just after a quick Google search[1]), just not friendly for the average Ruby dev to implement. [1] https://www.slideshare.net/AnnaKazakova/…
This is definitely possible-- I've done even more than basic PoC (Anna's slide deck was one of my starting points in fact). https://github.com/phoffer/crystalized_ruby
From Ruby to Crystal: A Quick Look
11–20 of 44 posts
Re: From Ruby to Crystal: A Quick Look
#1270x faster? If Crystal gets its own port of Ruby on Rails, oh boy.
70x faster, with the caveat that the way that Ruby code is written really does not lend itself to speed. E.g. using method calls inside the class instead of accessing instance variables instantly springs to mind, as does the "unsorted priority queue" which is basically a horrible abuse of Array but wrapped in a class that makes it even slower by adding additional method calls for every operation. That's not to dimini…
Re: From Ruby to Crystal: A Quick Look
#13My biggest takeaway from reading this is that Crystal is much more divergent from Ruby than I expected.
Re: From Ruby to Crystal: A Quick Look
#14My biggest takeaway from reading this is that Crystal is much more divergent from Ruby than I expected.
Re: From Ruby to Crystal: A Quick Look
#1570x faster? If Crystal gets its own port of Ruby on Rails, oh boy.
70x faster, with the caveat that the way that Ruby code is written really does not lend itself to speed. E.g. using method calls inside the class instead of accessing instance variables instantly springs to mind, as does the "unsorted priority queue" which is basically a horrible abuse of Array but wrapped in a class that makes it even slower by adding additional method calls for every operation. That's not to dimini…
The point of the article was merely "How much work does it take to port Ruby to Crystal" The performance differences were just fun to see, not the intent.
If I get time, maybe I'll run this through jRuby+Truffle as a comparison, that would be interesting to see.
Re: From Ruby to Crystal: A Quick Look
#16My biggest takeaway from reading this is that Crystal is much more divergent from Ruby than I expected.
In fact being similar to or compatible with Ruby is not a language goal at all.
Re: From Ruby to Crystal: A Quick Look
#17My biggest takeaway from reading this is that Crystal is much more divergent from Ruby than I expected.
In fact being similar to or compatible with Ruby is not a language goal at all.
Re: From Ruby to Crystal: A Quick Look
#18Earlier quoted context omitted.
70x faster, with the caveat that the way that Ruby code is written really does not lend itself to speed. E.g. using method calls inside the class instead of accessing instance variables instantly springs to mind, as does the "unsorted priority queue" which is basically a horrible abuse of Array but wrapped in a class that makes it even slower by adding additional method calls for every operation. That's not to dimini…
Crystal does the same as ruby for instance variable access, it's just that such methods are such an easy target for inlining by LLVM there's practically no performance penalty. The flexibility of gets and sets simply being method calls is very awesome and very worth it.
Re: From Ruby to Crystal: A Quick Look
#19My biggest takeaway from reading this is that Crystal is much more divergent from Ruby than I expected.
I'm confused by why there's so many small things that appears to be pointless differences. E.g. "property" vs "atter_accessor". It'd seem that ease of converting Ruby code is the major selling point, and especially with things like TruffleRuby + Substrate, it seems like it's about to face more serious competition that doesn't depend on rewriting your code nearly as much.
As for the effect on porting code, it's still very easy to port code. I ported over ActiveSupport's Inflector module(s), and approximately 75% of the code was untouched, 20% was minor tweaks (i.e. single to double quotes), and 5% required actual changing. It was a rather quick process.
If curious, https://github.com/phoffer/inflector.cr
Re: From Ruby to Crystal: A Quick Look
#20My biggest takeaway from reading this is that Crystal is much more divergent from Ruby than I expected.
I'm confused by why there's so many small things that appears to be pointless differences. E.g. "property" vs "atter_accessor". It'd seem that ease of converting Ruby code is the major selling point, and especially with things like TruffleRuby + Substrate, it seems like it's about to face more serious competition that doesn't depend on rewriting your code nearly as much.
Crystal should feel familiar to ruby developers in it's syntax and stdlib, but we have absolutely no problems with throwing away ruby's ideas when they are deemed substandard.
Crystal doesn't aim to draw in as many ruby developers as possible, it aims to create the best programming language possible. It just happens to have ruby as a conceptual starting point.