Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

JRuby is a great idea.

It has one pitfall which consistently stops me from using it though : poor support with newer releases of Rails, usually due to the Active Record stack not working well with the AR JDBC adapter.

I know some work was being done on a JRuby version of the standard pg gem (without the need for JDBC) which would be fantastic if it was completed and working.



This is really an unfortunte side effect of every Rails AR adapter being a one-off piece of code. In JRuby, there's not much code different between the databases, but in Rails they're all completely different. That means we basically have to emulate N different codebases just to be compatible. If they settled on a common database layer, our job would be done. Write your congressman.


Coyld an alternative be to simply add a single jdbc adapter to rails instead of pretending to have a lot of different interfaces in parallel?


If you're open to alternatives, I highly recommend using Sequel. It integrates fairly well with Rails, optimizes extremely well on JRuby, has a consistent update schedule, and has a real API for developing plugins against. I realize it's not part of the standard Rails stack, but it actually makes upgrading Rails easier because you're not constantly chasing a non-standard API that changes release to release (even on MRI, ActiveRecord "plugins" break with almost every release).

Disclaimer: I now work on JRuby full time. But prior to this I ran Mogotest and switched to Sequel successfully on that project.


As far as I'm aware, the port of pg 0.17.1 is alive and well: https://github.com/headius/jruby-pg


Is there any guidance out there about when to use activerecord-jdbc-adapter vs this gem (for postgres)?


In general everything ActiveRecord does should be supported by JDBC. The pg port is for cases where you need features the JDBC driver does not support but the C driver does, like geocoding etc.


Define "newer" and define "poor"? The JRuby team has done a fantastic job of keeping things working. Do you have any specific problems other than vague grumblings?

Anyone married to the MRI ecosystem because of dependencies on modules with no JVM equivalent may have problems, but new projects usually have no such issues.


Rails 4.2 was released 7 months ago.

When I last experimented with creating a standard Rails 4.2 app with the AR JDBC adapter and a database model a few weeks ago, it still didn't work. I haven't looked at things since then.

The workaround some people will suggest is "replace ActiveRecord with Sequel" but for existing projects a migration to a less standard Rails stack may not be viable.

I agree the JRuby team is doing a great job - however Rails is a big use case for any Ruby implementation, so my comment was not intended as a criticism, more in the line of a bug report and something it would be nice to have working now the new JRuby release is out the door.


Yeah; but at the same time when you're building and scaling an app you run into all sorts of issues like this. JRuby is almost a platform of its own: you get the scalability and benefits of the JVM with the flexibility of Ruby. IMO it's a decision you make pretty early in the product lifecycle. If you're already on Rails, there are other solutions that give you many of the same benefits with an easier migration path (i.e. app containers like Docker).


I don't want to complain because it is a free product. But there is no doubt a big lag with activerecord. Rails 4.2 is still not supported: https://github.com/jruby/activerecord-jdbc-adapter/issues/59...


I've used JRuby on a Rails 4.2 project and everything turned out fine on it. Many projects may not use what's not yet supported.


Currently, there's $1700 in store for whoever does support it: https://www.bountysource.com/issues/5831191-tasks-to-finish-...


Yep, I've put up money for it myself, and regularly be on twitter for other folks to do the same. I wish a big company that uses jRuby would step up and support the tools they use :/


Agreed.


Know anyone? ;)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: