2. Who am I
Josh Moore
www.codingforrent.com
twitter.com/codingforrent
http://github.com/joshsmoore
Ruby
Watir at work
Rails on the Google App Engine for hobby
maintain rails_dm_datastore gem
3. Contents
What is JRuby?
Quick compare to MRI 1.8.7 and 1.9.1
Gem Compatibility
Java Integration
Performance
JRuby on Rails
Short comings
Google App Engine
4. What is JRuby
Ruby interpreter on top of the JVM
Started in 2001
Runs rails in 2006
Compatible syntax
1.8.7/1.9.1(mostly)
5. Quick Comparison
MRI 1.8.7 MRI 1.9.1 JRuby
Gems Compatible Fairly Compatible Fairly Compatible
Rails yes yes (Rails3) yes
Speed slow fast medium to fast
Green threads native threads native threads
Pros Compatibility Fast medium Fast
Better syntax? Java integration
Ruby 1.8.x and 1.9
syntax
Cons Slow ruby compatibility C extension with
problems compatibility problems
6. Ruby Gems
Pure Ruby gems, no problem
Gems with C extensions, have problems
C extensions can work if invoked using
the Foreign Function Invocation interface.
Nokogiri
Switch to using Java instead of C
Hpricot
Some gems are JRuby only
Jemini
8. Java Integration - Libraries
Any library in the classpath can be accessed
Maven is a Build/depedency management to for Java, acts
like gems in ruby
Similar to rake and gems put together
Gemcutter - 10,467 gems
Maven - 158,643 archives, thats a lot
Coming with JRuby 1.5.0
9. Java Integration - Code
nil == null
self == this
Java interfaces mapped to modules
to_java converts ruby objects to Java objects
Closer Convention
Implement Java interfaces as blocks
b = JButton.new('click me')
b.add_action_listener do |event|
JOptionPane.show_message_dialog nil, "Clicked"
end
10. Java Integration - Code
Getters and Setters
Java Java in JRuby
getA and setA a and a=
Object Creation
Java Java in JRuby
new Object(1) Object.new 1
15. Rails
It just works (like most pure ruby libraries)
Only deployment is different
you can actually deploy and test in MRI and then deploy
using JRuby
deploy using warbler
16. Deploying Rails
Packaged into WAR (Web Application Archive)
Deployable on any Java Application server, or any Java
hosting service.
Including cloud hosting like Google App Engine
19. What is it?
Cloud hosting solution provided by Google.
Even more "cloudish" (ie less control and even
easier scaling) then heroku
All you do is submit your code and it runs you have no
control over where it runs or what it is running on or even
how many instances are running.
Getting lots of request GAE simply starts up more
instances of your app automatically.
Computer resources scaled 100% dynamically
Built for scalability, including sharding of data
21. Persistence - Datastore
No RDMS
Datastore
Fast
Not a relational database
No SQL, GQL instead
Some fast SQL operations are slow
Sums/counts are not really efficient so it is best to
keep running totals.
Joining can be very inefficient
All these differences can be overcome, it just requires a
paradigm shift.
22. Strengths
Fluid scalability
no configuration required
Fairly complete API set
Persistence designed for scalability
Everything designed for dynamic scalability
No need to worry about or configure anything on the server
side
23. The Downsides/Restrictions
Officially Java and Python
Ruby support not official
Restrictive
Only 30 seconds per request (spin up time)
Only one set of rules
Cannot write to file system from app
Code restrictions
No Threads and other API restrictions
Absolutely no C code
24. JRuby on GAE
Tools - http://code.google.com/p/appengine-jruby/
Project Run by John Woodell (Google employee)
Also wraps the local development environment
Work from MRI 1.8.7
no need to mess with jruby
Provide API wrappers for google services
Rack adapter - Rails, Sinatra, or custom
Rails patches provided
Datamapper adapter
No ActiveRecord
25. Rails
Some Modification required
Datamapper based
TinyDS based
27. Why do I use JRuby and GAE
I Learned Java in College
Like to atleast have a chance of knowing what is going
on under the hood
GAE
Still in its infancy so still lots of work to be done