Why JRuby?

  • 10,017 views
Uploaded on

When should you choose JRuby, a JVM-based implementation of Ruby, over MRI, the default C-based implementation? JRuby offers access to Java libraries, better performance, and can be deployed on …

When should you choose JRuby, a JVM-based implementation of Ruby, over MRI, the default C-based implementation? JRuby offers access to Java libraries, better performance, and can be deployed on Java-based infrastructure.

More 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
10,017
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
31
Comments
0
Likes
12

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. Why JRuby?Fiona Tay@msfionatayEngineer, Pivotal Labs
  • 2. This is for theperson who justwants to make webapps.
  • 3. This is about theGood, The Bad, andThe Ugly.
  • 4. I’m a Rubyist 4
  • 5. I’m also a JRubyisthttp://github.com/GreenplumChorus/chorus 5
  • 6. An Introduction
  • 7. It’s a Ruby implementation1. Install it2. Write Ruby code 7
  • 8. It’s a Ruby implementation 8
  • 9. Ruby implementationsInterchangeable to an extentPopular implementations:• MRI• JRuby• Rubinius• MacRuby 9
  • 10. Under the hood   10
  • 11. Under the hood   secret sauce 11
  • 12. Interchangeability1+1 should be 2 in all implementations 12
  • 13. Implementation differencesSome implementations are more equal than othersDifferences:• Speed of execution• Support for libraries• Implementation bugs 13
  • 14. History of JRubyAround since 2002Has had traction in real projects since ~2005 14
  • 15. JRuby in the real world 15
  • 16. JRuby in the real world 16
  • 17. The Good
  • 18. Access to Java librariesIncredibly powerful toolEveryone and his/her dog writes Java 18
  • 19. Java libraries: NLPStanford Parser is the NLP library of choice 19
  • 20. Java libraries: EmailJavaMail is a better alternative to ActionMailer 20
  • 21. Access to Java librariesJRuby has deep integration with JavaDirectly call Java code from Ruby 21
  • 22. Directly calling Java code 22
  • 23. Using other languagesOther languages built on the JVM• Scala - special support• Clojure• Groovy 23
  • 24. Using Ruby gemsIf you’re lucky, someone has made a Ruby gem thatwraps the Java libraryAlso wrapping a gem is a good idea 24
  • 25. Easier app deploymentNot easier than git push heroku masterOnly relevant if you’re deploying to large server system 25
  • 26. Easier app deploymentLeverage existing Java-based deployment infrastructure 26
  • 27. Leverage infrastructureWarbler packages everything into a single WAR fileStandard file format for Java deploys 27
  • 28. Other deployment optionsTorqueBox provides additional services 28
  • 29. Better performanceBetter compiler than MRIBenefits from improvements to JVM 29
  • 30. Better performanceAccess to highly optimized Java libraries 30
  • 31. The Bad
  • 32. Gem availability 32
  • 33. Gem availabilityGems written in pure Ruby work with JRubyGems with C extensions don’t work with JRubyTypically, these are older, less-maintained gems 33
  • 34. Fixing gemsSometimes, you can fix the existing gemCould be as simple as replacing its dependenciesOr could be complex 34
  • 35. Fixing gemsPatched a job queueing systemTook more work than we expectedYMMV 35
  • 36. Long app startup timeInhibits test-driven developmentDue to Rails startup timeDifficult to set up Spork with JRuby 36
  • 37. Long app startup timeC’est la vie 37
  • 38. Less mature technologyMRI still the defaultThough JRuby has maturedLibraries developed against MRI 38
  • 39. The Ugly
  • 40. Concurrency“Concurrency is when several computations areexecuting simultaneously, and potentially interactingwith each other.” - Wikipedia 40
  • 41. ConcurrencyJRuby has real threadsMRI Ruby has threads with Global Interpreter Lock 41
  • 42. Concurrency and RubyThreads are a major innovationBut MRI has never really had a focus on concurrency 42
  • 43. Concurrency is greatCheaper to scaleGood multi-threaded web servers 43
  • 44. More bang for your buckOne server: MRI runs two Ruby processesOne server: JRuby runs two Ruby processes with 4threads eachCan use JRuby on Heroku 44
  • 45. Concurrency is not freeBugs in non-thread safe libraries• Rails• AirbrakeLibraries developed without a focus on concurrency 45
  • 46. Concurrency is not freeWriting thread-safe code is difficultEven for Java developers with experienceBut concurrency is the new sexy 46
  • 47. Concurrency is worth itHuge performance improvementsSome features would be much easier with threadsThreads is the future 47
  • 48. The Decision
  • 49. JRuby is a non-standard choice.
  • 50. Should you use JRuby?Do you want to use Java libraries? 50
  • 51. Should you use JRuby?Do you want to leverage Java-based deploymentinfrastructure? 51
  • 52. Should you use JRuby?Do you need good performance? 52
  • 53. Should you use JRuby?Otherwise, no 53
  • 54. Should you use JRuby?Not to worry - you can always switch to JRuby laterLots of people switch for performance reasons 54
  • 55. Getting started with JRubyjruby-lint checks how ready your code is to run onJRuby 55
  • 56. AcknowledgmentsPivotal LabsJRuby team 56
  • 57. Thanks!@MsFionaTay