CrystalRuby: Embed Crystal Code Directly in Ruby

Saw this in the Ruby Weekly but hadn’t seen it mentioned here. Seems pretty slick.

CrystalRuby: Embed Crystal Code Directly in RubyCrystal is a Ruby inspired programming language that boasts a lot of great features and is well worth a try IMHO. One benefit is performance, and this gem lets you write Crystal code, inlined in Ruby, giving you a potential performance boost without a huge shift in syntax. New and YMMV!
Wouter Coppieters

7 Likes

HN thread: Embed Crystal code directly in Ruby | Hacker News

I wonder if this project avoids the famous limitation of Crystal’s shared libraries that only one library can be used at a time?

But it is good that more people will have the opportunity to learn about the Crystal language. Hopefully someday the conflicting function names in the shared library will be mangled so that we can freely call libraries written in Crystal from other languages such as Ruby.

this project compiles all crystallized procedures into single library, so it avoids the problem because well, only one library is used.

1 Like

I am wondering about a way to make Crystal’s shared libraries available to Ruby.

When multiple Ruby Gems containing Crystal code are added to the Gemfile, a mechanism to compile them into a single shared library at first runtime, rather than compiling them at install time, might make using Crystal with Ruby a bit more practical.

In addition to that, it would be nice to be able to raise an obvious runtime error, such as MultipleCrystalLibraryError, when multiple Crystal libraries are loaded. Currently it would be a segmentation fault.