pragmatist
Patrick Joyce

May 17, 2007

Your First Day on JRuby on Rails: Notes Part 1

Streaming notes:

Why they are doing it? expand java, expand ruby's reach. no better way to learn a language than to implement it. also it's just freaking cool.

they ask if java sucks. not many say it. they like ruby better (who doesn't)

jruby allows you to access java libraries. once pulling in java you can use ruby language features (enumerable, concatenation, etc.)

even converts ruby case "set_size" to java 'setSize" when calling java methods.

Thomas is demoing the install. Really simple. set the environment variable and that's about it. I've got to figure out how to slip this into LM. you can also check out from svn and build via ant. plug to help. I'm going to have to try this.

comes with gem. Mongrel supports JRuby. RDoc runs crazy slow. Rails "just works" because it is pretty much all ruby code. Thoughtworks is pushing mingle 1.0 on JRuby to calm "enterprises"

ruby unicode support sucks (my word, not theres) threadings, scaling Rails, and having to write in C to get performance. Good point. No one wants to write C they are trying to get the benefit of optimized JIT bytecode compiling

Unicode support: JRuby has their own identical ruby 1.8 striing implementation but also exposes java unicode strings and switch back and forth between java and ruby strings well.

Supports ruby thread api. They hate critical=, kill, raise because there is not a safe way to do this (I'm real rusty on this, bc it has been a while since I've written real multi threaded code) Make less assumptions about control of threads and you'll be fine.

JRuby threads generally equal system lhreads owing to JVMs being native threaded. This lets you use multiple cores out of the box. Also does thread pooling. Get true concurrent threading. You can screw it up (like any concurrent system) but the internals are good.

What is the biggest benefit of JRuby? My argument: you can convince your PHB to let you use it.

Pretty much all pure ruby code runs fine.

Tom demoing installing rails and bringing up an app. WebBrick boots up nicely. Installed mongrel, brought it up. They are emphasizing the same thing that strikes me, what is remarkable is how unremarkable it is. Everything looks really simple.

DB implementations. Pure ruby connectors (MySql, Postgres) run fine. jdbc adapters run fine and faster. You can use JNDI for connection pooling. Connection pooling important for licensing requirements if connecting to oracle (many connections = mucho dinero)

Classpath sucks. you can do the traditional, or you can just drop whatever you need in JRuby/lib directory.

Setting up JDBC is also really simple. Migrations work fine, but required a lot of db specific work under the hood because JDBC doesn't handle schema management. MySql passes 100% of ActiveRecord tests. Postgres has 17 failures out of over 1000 tests.

C Extensions don't work (unless they're ported to Java) Example RMagick doesn't work but is in progress.

Performance. Java isn't slow, but it is slow at startup. After startup about the same speed as the C implementation, some specific cases are faster. Command line performance still sucks.

Deployment.: Mongrel should work. A couple things like forking off subproccesses and process management don't work. JRuby deployments are normally done by deploying to a App server. Project is called GoldSpike, and is a rails plugin for ulding WAR files. One plugin in pure ruby, produces a deployable, server agnostic WAR file.Plug for Glassfish ("it's tiny for an app server, which means it's huge" laughs from the room)

Tom demoing deploying a rails app on an app server. one rake task, produces a war. Wow! that was really easy. I think that this is going to make bringing rails to big companies much easier.

Break

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.