• Like

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

RubyConf Uruguay 2010 - JRuby

  • 3,852 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,852
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
60
Comments
0
Likes
10

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide





















































Transcript

  • 1. JRuby The Best of Both Worlds
  • 2. Me • Charles Oliver Nutter • JRuby Architect at Engine Yard • Java developer since 1997 • JRuby developer since 2005 • @headius, headius@headius.com
  • 3. JRuby • Ruby on JVM • Latest release: 1.5.3 • Ruby 1.8.7 compat, 1.9.2 coming • It’s Just Ruby! • (It’s Not Just Ruby!)
  • 4. If you... ...want or need to run on JVM... ...JRuby is the answer!
  • 5. If you... ...need to use a Java library... ...JRuby is the answer!
  • 6. If you... ...want the best GC(s) in the world... ...JRuby is the answer!
  • 7. If you... ...hate dealing with native libraries... ...JRuby is the answer!
  • 8. If you... ...need to develop or deploy on Windows... ...JRuby is the answer!
  • 9. If you... ...need to develop or deploy on zLinux... ...JRuby is the answer!
  • 10. If you... ...need to develop or deploy on AS/400... ...JRuby is the answer!
  • 11. If you... ...need to develop or deploy on OpenVMS... ...JRuby is the answer!
  • 12. If you... ...want to build Android apps in Ruby... ...JRuby is the answer!
  • 13. If you... ...want to integrate with other languages like Clojure, Scala, Mirah... ...JRuby is the answer!
  • 14. Boring Stuff • Trivial install: unpack, run (only prereq: Java) • Performance is great, ~1.9 • Rails etc run great • Production users since 2007 • Most mature, most stable alternative Ruby
  • 15. Installation • Step 1: unpack JRuby
  • 16. Installation • Java (easy on any platform) • Download, unpack JRuby • Or use rvm, pik, apt-get, yum, etc • Add bin/ to PATH • Done!
  • 17. Installation (alternative) • Download an IDE • NetBeans • Eclipse (RadRails) • IntelliJ (main product or RubyMine)
  • 18. Cool Stuff • Java/JVM integration • Deployment • Native threads (real concurrency!) • Tooling and maturity • New frontiers
  • 19. Platform Integration • Use any Java library like it’s a Ruby library • No-compile, single-file deployments • Cross-platform GUI libraries
  • 20. Fun With JRuby
  • 21. Deployment • Typical Ruby servers work • Thin, Mongrel • GlassFish, Trinidad, Aspen, Jetty-Rails, ... • Java WAR file deployment • Any Java app server can run Rails!
  • 22. Rails in a WAR File ~/projects/jruby/testapp ➔ gem install warbler Successfully installed warbler-1.2.1 1 gem installed Installing ri documentation for warbler-1.2.1... Installing RDoc documentation for warbler-1.2.1... ~/projects/jruby/testapp ➔ warble rm -f testapp.war Creating testapp.war ~/projects/jruby/testapp ➔ ls -l testapp.war -rw-r--r-- 1 headius staff 17812893 Oct 30 13:08 testapp.war
  • 23. Command-line Server ~/projects/jruby/testapp ➔ gem install trinidad Successfully installed trinidad_jars-0.3.2 Successfully installed jruby-rack-1.0.3 Successfully installed trinidad-0.9.12 3 gems installed Installing ri documentation for trinidad_jars-0.3.2... Installing ri documentation for jruby-rack-1.0.3... Installing ri documentation for trinidad-0.9.12... Installing RDoc documentation for trinidad_jars-0.3.2... Installing RDoc documentation for jruby-rack-1.0.3... Installing RDoc documentation for trinidad-0.9.12...
  • 24. Command-line Server ~/projects/jruby/testapp ➔ trinidad -e production Oct 30, 2010 1:15:26 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-3000 Oct 30, 2010 1:15:26 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Tomcat Oct 30, 2010 1:15:26 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.2 Oct 30, 2010 1:15:26 PM org.apache.catalina.startup.ContextConfig webConfig INFO: No global web.xml found Oct 30, 2010 1:15:28 PM org.apache.catalina.core.ApplicationContext log INFO: Info: using runtime pool timeout of 30 seconds Oct 30, 2010 1:15:28 PM org.apache.catalina.core.ApplicationContext log INFO: Info: received min runtimes = 1 Oct 30, 2010 1:15:28 PM org.apache.catalina.core.ApplicationContext log INFO: Info: received max runtimes = 5 Oct 30, 2010 1:15:36 PM org.apache.catalina.core.ApplicationContext log INFO: Info: add application to the pool. size now = 1 Oct 30, 2010 1:15:36 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-3000
  • 25. Native Threads • Ruby Thread :: Native Thread • Thread.new # real system-level thread • One process can saturate all cores • One Rails instance for a whole site
  • 26. Threadsafe Mode ~/projects/jruby/testapp ➔ trinidad -e production --threadsafe Oct 30, 2010 1:17:05 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-3000 Oct 30, 2010 1:17:05 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Tomcat Oct 30, 2010 1:17:05 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.2 Oct 30, 2010 1:17:05 PM org.apache.catalina.startup.ContextConfig webConfig INFO: No global web.xml found Oct 30, 2010 1:17:15 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-3000 No pool of JRuby runtimes!
  • 27. A “Slow” Action class TestController < ApplicationController def slow # simulate a blocking call sleep 1 render :text => 'All done!' end end
  • 28. No Concurrent Requests ~ ➔ ab -n 50 http://localhost:3000/test/slow This is ApacheBench, Version 2.3 <$Revision: 655654 $> ... Requests per second: 0.96 [#/sec] (mean) Time per request: 1037.188 [ms] (mean) Time per request: 1037.188 [ms] (mean, across all concurrent requests) Transfer rate: 0.30 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 0 Processing: 1005 1037 116.3 1008 1705 Waiting: 1005 1037 116.2 1008 1705 Total: 1006 1037 116.3 1008 1705 ...
  • 29. 5 Concurrent Requests ~ ➔ ab -c 5 -n 50 http://localhost:3000/test/slow This is ApacheBench, Version 2.3 <$Revision: 655654 $> ... Requests per second: 4.95 [#/sec] (mean) Time per request: 1010.680 [ms] (mean) Time per request: 202.136 [ms] (mean, across all concurrent requests) Transfer rate: 1.54 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 1 Processing: 1005 1010 5.6 1007 1029 Waiting: 1004 1009 5.5 1007 1029 Total: 1005 1010 5.6 1007 1029
  • 30. Tooling and Maturity • Editor/IDE support with bonuses • Debugging tools • Profiling, memory tools • Commercial JVM environments • Richest tools of any Ruby
  • 31. VisualVM
  • 32. CPU Monitor
  • 33. Heap Monitor
  • 34. Heap Dump
  • 35. CPU/Memory Profiling Live results!
  • 36. New Frontiers • Google AppEngine • Java or Python only (...or JRuby!) • Android • “Java”-mostly (...or JRuby!) • Anywhere with a Java server • Deploy like any other application
  • 37. Ruboto!
  • 38. Ruboto: Ruby for Android • Ruboto IRB • ruboto-core • Ruby Summer of Code • Daniel Jackoway • App generator, utilities • More to come, you can help!
  • 39. ruboto-core gem ~/projects ➔ gem install ruboto-core Successfully installed ruboto-core-0.0.2 1 gem installed Installing ri documentation for ruboto-core-0.0.2... Installing RDoc documentation for ruboto-core-0.0.2...
  • 40. Generate App ~/projects ➔ ruboto gen app --name RubyConfUY --target android-8 -- package org.headius.demo.rubyconfuy --activity RubyConfUY --path rubyconfuy_demo Generating Android app RubyConfUY in /Users/headius/projects/ ruboto-core/rubyconfuy_demo...Done Copying files: Rakefile...Done .gitignore...Done assets...Done JRuby jars...Done Ruboto java classes...Done Adding RubotoActivity and RubotoDialog to the manifest...Done Setting the package name in ruboto.rb...Done Generating the default Activity and script...Done Hello, RubyConfUY
  • 41. Build App ~/projects ➔ cd rubyconfuy_demo/ ~/projects/rubyconfuy_demo ➔ rake (in /Users/headius/projects/rubyconfuy_demo) Android SDK Tools Revision 6 Project Target: Android 2.2 API level: 8 WARNING: No minSdkVersion value set. Application will install on all Android versions. Importing rules file: platforms/android-8/ant/ant_rules_r2.xml mkdir -p generated_libs ...
  • 42. Deploy App ~/projects/rubyconfuy_demo ➔ adb install -r bin/RubyConfUY-debug.apk 788 KB/s (2718474 bytes in 3.367s) pkg: /data/local/tmp/RubyConfUY-debug.apk Success
  • 43. Ruboto
  • 44. Your Turn • Just try it! • Tell everyone • Let us know what you need
  • 45. JRuby Book!
  • 46. For The Managers • Three fulltime devs at Engine Yard • Support, professional services • And OSS-style IRC/email support • Engine Yard Cloud (soon!) • Well-established, mature, stable • Enterprise-ready!
  • 47. Production Users • Oslo Airport refueling terminals • LinkedIn’s “Signal” social aggregator • BankSimple • Oracle Mix, Kenai • Thoughtworks • Github FI (Firewall Install)
  • 48. More? • Madness: 3D game in JRuby • Redcar: JRuby-based textmate clone
  • 49. JRubyMonkeyEngine • JRuby wrapper around JMonkeyEngine • 3D scenegraph and physics engine • Write 3D games entirely in Ruby • Deploy on multiple platforms • No recompile...just ship the JME libs!
  • 50. Madness!
  • 51. Redcar • Clone of textmate using JRuby + SWT • Almost entirely Ruby • Easy to hack, improve • gem install redcar • sudo redcar install
  • 52. Redcar
  • 53. Thanks! • http://jruby.org • http://wiki.jruby.org • http://bugs.jruby.org • http://engineyard.com/jruby • http://blog.headius.com