pragmatist
Patrick Joyce

May 17, 2007

Your First Day on JRuby on Rails: Notes Part 2

They're working on a stripped down version of GlassFish that gives the benefits of an app server without the whole JEE stack, and they're starting to work on it. GlassFish developers managed to put a gem together during JavaONE last week. ("this thing is two weeks old and it's already at version 10" laughter) Benefits of doing this is that you can use GlassFish as a dev server. If interested read GlassFish blogs, wiki, and JRuby extras project. Could be cool in the future, but I still think that the main benefit of JRuby is slipping ruby in the back door. So the WAR deployment is really useful, and if you're setting up your own servers I would lean towards doing it the native ruby way.

Talking about running Mephisto (what runs this blog) on JRuby.

MySQL has no known issues and passes 100% ActiveRecord tests and is hooked up to their CI server. If you use mySQL don't worry about it.

Derby (JavaDB) and HSQLDB are replacements for SQLLite and works really well but there are a few failures. Good target for small apps and are useful because they are embeddable and shippable. Mingle is using Derby. Unpack and run and your app is up. Doesn't require DB setup.

PostgreSQL has a few failures, but they haven't gone after it real hard yet. Failures are almost exclusively with migrations. The other buggy areas are quoting and rounding of BigDecimals.

Oracle focus is just starting. They haven't done much direct work with it, but some people are doing prod deployments with it. Progress is quick on the ActiveRecord-JDBC gem because it is .

SQL Server hasn't been examined at all. Some people are using it, but they JRuby developers aren't using Windows (shocking for Sun employees, I know) so they have trouble testing this.

Migrations work well, but some DBs lack required features. For instance Derby can't ALTER TABLE

Fixtures work well. Bugs are normally with the JRuby YAML implementation

Native Extensions. Option 1, don't use it. If you use pure ruby you can use out of the box. Option 2. Use a Java library. Option 3: port the library. sometimes pretty easy to translate. Option 4: Port by wrapping a Java library. basically create a facade. for example JRuby Digest was originally written in ruby by pulling in java crypto stuff into ruby code.

OpenSSL was completely reimplemented in Java for JRuby. Pretty impressive and about the worst case situation. YAML was originally written as a pure ruby implementation and then was rewritten in Java for the performance gains.

You can deploy with Mongrel. It works, but it isn't the best way to use JRuby bc you don't get the benefits of the JVM. WAR files are the best for eiting servers. this is what you're going to want to use in a big enterprise. Can take advantage of existing investment in infrastructure. Pool DB connections, cached results, pool execution threads and request handlers.

Good line: "Java EE has a lot of bathwater, but a lot of baby" i haven't used JEE enough to know, but I would imagine that they had to get some things right. ;) Good things are like (Java Message Service, Java Persistence API, Java Transaction API, Easy deployment, clustering, failover, management and it scales great (even though the complexity of the platform makes it tricky)

Eventually they wannt to have a Grizzly/GlassFish lightweight, gem installable version. You get the installation benefits of Mongel, and the managements and clustering benefits of an App Server.

Tom is demoing Mephisto in JRuby by packaging it as a WAR using GoldSpike. The WAR file will contain JRuby, all the Gems, and your application code. Benefit: each app within the app server is completely independent and can be running different . Wow. That deployment was easier than getting this blog running on DreamHost. They've also got Typo working recently and are moving all their blogs over to Typo on JRuby.

"Java is mature, trusted, reliable (and often boring)" but there are a lot of libraries out there. Another good line: "'To them: 'it's just jave', to you: 'it's just ruby'"

demo of using ROME to add Atom feed to demo app. automatically produces ruby style properties so that you don't have to use java getters and setters in Ruby code. this is really cool.

Demo of NetBeans Ruby support. Some really cool stuff: Integrated RDoc, code complete, go to definition. This is impressive and I'll have to check it out. I have had a post floating around the back of my head about tooling in dynamic versus static languages. I love textmate, but this would be really nice to have. Basically my argument is that these things would be great to have with ruby but you can live without them. In Java or .Net it would be unbearable to have to write code in a text editor. There also is a Swing based IRb built in to the code. It handles embedded grammars (eg. ruby in an rhtml file) I'm going to need to check out the tooling talk later in the week.

Someone is snoring. Jesus, I used to sleep in class in college, but this is actually useful, expensive, and brief. Unbelievably rude.

Questions: Discussion of compilation to bytecode. Approx 50% of the ruby syntax can be compiled. Currently done in a JIT manner.

DSLs in JRuby. Good idea, you can write Ruby based internal DSLs for ugly java APIs. Good point, the "rubyfication" of the java libraries makes much prettier apis. Not quite a DSL, but much more useable.

Exceptions: you can catch Java exceptions, to catch a specific one just import it.

Initialize in Ruby vs. constructors in java. They chain nicely.

More Articles on Software & Product Development

Agile With a Lowercase “a”
”Agile“ is an adjective. It is not a noun. It isn’t something you do, it is something you are.
How Do You End Up With A Great Product A Year From Now?
Nail the next two weeks. 26 times in a row.
Build it Twice
Resist the urge to abstract until you've learned what is general to a class of problems and what is specific to each problem.