Your First Day with JRuby on Rails Your First Day with JRuby on Rails Charles Nutter and Thomas Enebo Charles Nutter and Thomas Enebo Except where otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License (http://creativecommons.org/licenses/by-sa/3.0/us/).
102
Embed
Your First Day with JRuby on Rails - s3.amazonaws.com Day with... · Migration – Steps, Gotchas, and Pitfalls Beyond Rails – Creating Your Own Chimera. 3 Your Humble Hosts Charles
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Your First Day with JRuby on RailsYour First Day with JRuby on Rails
Charles Nutter and Thomas EneboCharles Nutter and Thomas Enebo
Except where otherwise noted, the content of this presentation is licensed under the Creative Commons AttributionShare Alike 3.0 United States License (http://creativecommons.org/licenses/bysa/3.0/us/).
2
Welcome!
What will we cover:JRuby 101 – Fluff 'n StuffJustification! (or: Dear god, why?)JRuby on Rails – The BasicsDeployment Options – How Easy Can They Be?Migration – Steps, Gotchas, and PitfallsBeyond Rails – Creating Your Own Chimera
3
Your Humble Hosts
Charles Oliver Nutter and Thomas EneboLongtime Java developers (10+ yrs each)Shorttime engineers at Sun MicrosystemsFull-time JRuby developersAlso working to build out JVM dynlang supportWide range of past experience
C, C++, C#, Perl, Python, Delphi, Lisp, SchemeJava EE and ME, JINI, WS
4
Off We Go!
JRuby 101
5
A Floor Wax and a Dessert Topping
JRuby is:Ruby (1.8ish)A non-Java language for the Java platformA new way to look at Ruby and the JVMHelping to expand Ruby's reachHelping the world better understand RubyReally cool
6
A Floor Wax and a Dessert Topping
JRuby is not:An attempt to pollute or fork RubyAn admission that Java sucksThe answer to every problem with RubyAn attempt to alter Ruby or add incompatible featuresSlow
SESAM/SQL-Server, SOLID Embedded Engine, SOLID SynchroNet, SQL/DS, SQLLite, SUPRA Server SQL, SearchServer, Sequential, Solid Server, Sybase, Teradata RDBMS, Text (CSV, Tab separated etc.), ThinkSQL, TinySQL, TurboIMAGE, UNIFY, VFP, VSAM,
XML, YARD-SQL, dBase, kdb, mSQL, xbase, xbase
42
Does JDBC Support Mean Rails Support?
ActiveRecord-JDBC doesn't support all of themJDBC has no schema management APIDifferent databases quote differentlySome databases are missing features
We focused on databases close to Rails, JRubyMySQL passes 100% of ActiveRecord tests (yay!)Derby 34F, PostgreSQL, 17F (out of 1000+ tests)Others at varying levels, but coming along
43
Differentiation
Big Difference #2: No Native Extensions*
*At least, not until ports are available
44
Native Extensions
Some ports done, some in progressMongrel: doneHpricot: doneDatabase support: some done, some in progressRMagick: in progress
~/work/jruby/testapp $ gem install glassfish-rails~/work/jruby/testapp $ jruby script/server glassfish=> Starting GlassFish=> Rails application at http://localhost:8080=> Admin services at http://localhost:4848=> Clustering enabled=> Connection pooling enabled=> Load balancing enabled=> Server Ready.
67
Tease!
Not Yet.But Soon :)
68
Making a Move
Migration
69
Migration
It can be done!(it's basically just Ruby, after all)
70
Migration
The areas of concern arethe (currently) unsupported features.
71
Migration
Case Study: Mephisto
Mephisto is a kick ass web publishing system. It’s a blog engine with some simple CMS-ish concepts (sections, pages), a very flexible templating system, and an aggressive caching
scheme that takes advantage of your web server’s best traits.
72
Migration
Step One: Database Support
73
Migration
MySQL
Well-supportedNo known issues
ActiveRecord tests 100%Included in our continuous integration
74
Migration
Derby (JavaDB) and HSQLDB
Working well (fewer failures every week)Embeddable and shippableGood target for small apps
Included in our continuous integration
75
Migration
PostgreSQL
Down to a few failuresIncluded in our continuous integration
76
Migration
Oracle
Being used by some in communityStarting to get our attention
May be in continuous integration now
77
Migration
MS SQL, DB2, others
Used in communityHave not started to investigate
Not part of continuous integrationLooking for folks to help here
78
Migration
Migrations
Working well, because they're part of Rails testsTricky on some DBs that don't have all features
79
Migration
Fixtures
Also working well, part of Rails testsUsually bugs are YAML rather than DB issues
80
Migration
Step Two: Native Extensions
You have a few options...
81
Migration
Option #1Use something else
82
Migration
Option #2Use an equivalent Java library
83
Migration
Option #3Port the library yourself (sometimes pretty easy)
84
Migration
Option #4 (our favorite!)Port by wrapping a Java library
(often even easier)
85
Example Extensions
Hpricot – Ragel generator supports JavaMongrel – DittoRMagickJr – Wraps builtin Java graphics supportJParseTree – Pure Ruby, but uses JRuby ASTOpenSSL – Complete port of OpenSSL (really!)YAML – Complete implementation in Java
86
Ship It!
Step Three: Choosing a Deployment Option
87
Ship It!
Two real options, a third in development.
88
Choosing a Deployment Option
You must balance features with convenience.
89
Choosing a Deployment Option
And we want to help build a better way.
90
Tried and True: Mongrel
MongrelYou know the good reasons, they still applySome community use, but little testingYou thought n Ruby processes took up memory!Not utilizing best of JRuby and JVM
91
A Taste of the Old World
Web Archive in App ServerMulti-app, multi-request concurrencyMost servers support transparent clusteringResource pooling
Java EE has a lot of bathwater, but a lot of babyJava Message ServiceJava Persistence API (good riddance Entity Beans)Java Transaction APIEasy deployment, clustering, failover, managementScales great
Though Java's complexity makes it tricky
93
Coming Soon
A Grizzly/GlassFish v3 optionLightweight, gem-installable like MongrelConcurrency, pooling, multi-app like WARCompletes the deployment story for JRubyLooking for suggestions and help!
94
Demo
Putting it all together with Mephisto
95
The Transformed Man
Beyond Rails
Creating your own Chimera
96
There's a Whole Platform Out There
Billions of lines of Java code out thereTens of thousands of deploymentsThousands of librariesThe Java platform is mature, trusted, reliable
...and often boring!
So why not combine two greats?Ruby as the programming languageJava for the platform and libraries
97
Our Chimera
Best of all worldsRuby or Rails as the application layerJava libraries, alone or as ported gemsJava-based services...legacy integrationThe JVM
Acceptable to today's enterprise“Enterprise-ready” without losing the Ruby WayTo them: “it's just Java”, to you: “It's just Ruby”
98
Demo
Calling Java from Rails
99
Building a Better Toolset
You all have your tried and true toolsTextmate, Emacs, VI(M), plus command lineYou know them and you love them
But you're missing somethingCode completion?Jump to declaration?Rename variables?Pop-up RDoc?
100
NetBeans Ruby Support
Best Ruby IDE availablecode completion in dozens of wayssmart syntax highlightingmore and more refactoringsjump to method, variable, class declarationspop-up RDocfull project support for Ruby or Rails appseverything else IDEs do: version control, etc