graalvm

mauricio.szabo 2024-04-15T16:02:12.194049Z

I'm writing about my experience with GraalVM and exposing the code to a Ruby library. Is this a good channel to share the posts, or even are people interested in this? 🙂

Karol Wójcik 2024-04-15T16:29:09.819089Z

Sure! I’m doing other way around. Taking JS lib and adapting it to Clojure. Can’t wait to see your post

borkdude 2024-04-15T16:32:48.655669Z

no, totally off topic....

borkdude 2024-04-15T16:32:54.463659Z

of course! :)

mauricio.szabo 2024-04-15T16:54:40.414629Z

So, here's part 1 of "Porting Clojure Libraries to Ruby": https://mauricio.szabo.link/blog/2024/04/15/porting-clojure-libraries-to-ruby/

👀 1
borkdude 2024-04-15T18:01:05.739329Z

I just started reading but it immediately popped my mind: have you considered running both Ruby and Clojure within the same JVM and/or the using the polyglot capabilities of GraalVM?

borkdude 2024-04-15T18:05:10.127219Z

That's what I would miss from this article, now having read it entirely. There's more options, so the question is why did you choose this specific option, perhaps you're locked in on Ruby MRI?

mauricio.szabo 2024-04-15T18:55:27.330219Z

Well, basically because nobody uses JRuby 🤣. Most projects are MRI only, and in all my years with Ruby I only saw two projects that ran under JRuby. In most cases, they don't even install (meaning there's a bunch of dependencies that don't run, nor have any equivalent). In fact, in most cases even different versions of MRI Ruby are not guaranteed to run the project 😞

mauricio.szabo 2024-04-15T18:55:46.270029Z

It's a sad world out there were backwards compatibility is non-existent

borkdude 2024-04-15T19:05:08.527029Z

Ok, the other option would be to run Ruby on GraalVM polyglot

borkdude 2024-04-15T19:05:20.606559Z

it's actually much much faster than MRI or Jruby

borkdude 2024-04-15T19:05:33.734479Z

https://www.graalvm.org/ruby/

mauricio.szabo 2024-04-15T19:10:56.535929Z

Well, last time I used it didn't run half of the core Ruby code necessary to run Rails, and it was insanely slow so I didn't even consider it... thinking-face

borkdude 2024-04-15T19:11:32.371729Z

ah ok. they use it as shopify a lot to save resources

mauricio.szabo 2024-04-15T19:32:30.856859Z

Interesting, I'll check it later. Tried to check on an old project, but it doesn't even boot anymore... facepalm

lread 2024-04-15T20:04:16.652729Z

Fwiw (maybe not much!) https://github.com/asciidoctor/asciidoctorj uses JRuby.

mauricio.szabo 2024-04-15T20:22:38.348219Z

Well, here's my test suite running side-by-side with MRI, Truffle, and JRuby. In my own experience, Truffle was never faster than Ruby, or even JRuby. I don't know if it need a higher "warm up time", or things like that, but unfortunately I never got into a situation where I could make something run with TruffleRuby, because there was always some core functionality missing, like some OpenSSL extension that I depended on, etc... Also, isn't it amazing that in this 4-year old project, half of my code is broken just because I had to upgrade Ruby and that caused a cascade of gem upgrades that changed APIs? laughcry

borkdude 2024-04-15T20:33:04.371439Z

Interesting. Their philosophy is: when TruffleRuby is slower than Ruby, they consider it a bug. So might be worth sharing this (and some of the test failures, if you can manage to reproduce which can be hard in the case of spaghetti Rails)