Anzeige
Anzeige

Más contenido relacionado

Anzeige

Why JRuby?

  1. Why JRuby? Fiona Tay @msfionatay Engineer, Pivotal Labs
  2. This is for the person who just wants to make web apps.
  3. This is about the Good, The Bad, and The Ugly.
  4. I’m a Rubyist 4
  5. I’m also a JRubyist http://github.com/GreenplumChorus/chorus 5
  6. An Introduction
  7. It’s a Ruby implementation 1. Install it 2. Write Ruby code 7
  8. It’s a Ruby implementation 8
  9. Ruby implementations Interchangeable to an extent Popular implementations: • MRI • JRuby • Rubinius • MacRuby 9
  10. Under the hood   10
  11. Under the hood   secret sauce 11
  12. Interchangeability 1+1 should be 2 in all implementations 12
  13. Implementation differences Some implementations are more equal than others Differences: • Speed of execution • Support for libraries • Implementation bugs 13
  14. History of JRuby Around since 2002 Has 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 libraries Incredibly powerful tool Everyone and his/her dog writes Java 18
  19. Java libraries: NLP Stanford Parser is the NLP library of choice 19
  20. Java libraries: Email JavaMail is a better alternative to ActionMailer 20
  21. Access to Java libraries JRuby has deep integration with Java Directly call Java code from Ruby 21
  22. Directly calling Java code 22
  23. Using other languages Other languages built on the JVM • Scala - special support • Clojure • Groovy 23
  24. Using Ruby gems If you’re lucky, someone has made a Ruby gem that wraps the Java library Also wrapping a gem is a good idea 24
  25. Easier app deployment Not easier than git push heroku master Only relevant if you’re deploying to large server system 25
  26. Easier app deployment Leverage existing Java-based deployment infrastructure 26
  27. Leverage infrastructure Warbler packages everything into a single WAR file Standard file format for Java deploys 27
  28. Other deployment options TorqueBox provides additional services 28
  29. Better performance Better compiler than MRI Benefits from improvements to JVM 29
  30. Better performance Access to highly optimized Java libraries 30
  31. The Bad
  32. Gem availability 32
  33. Gem availability Gems written in pure Ruby work with JRuby Gems with C extensions don’t work with JRuby Typically, these are older, less-maintained gems 33
  34. Fixing gems Sometimes, you can fix the existing gem Could be as simple as replacing its dependencies Or could be complex 34
  35. Fixing gems Patched a job queueing system Took more work than we expected YMMV 35
  36. Long app startup time Inhibits test-driven development Due to Rails startup time Difficult to set up Spork with JRuby 36
  37. Long app startup time C’est la vie 37
  38. Less mature technology MRI still the default Though JRuby has matured Libraries developed against MRI 38
  39. The Ugly
  40. Concurrency “Concurrency is when several computations are executing simultaneously, and potentially interacting with each other.” - Wikipedia 40
  41. Concurrency JRuby has real threads MRI Ruby has threads with Global Interpreter Lock 41
  42. Concurrency and Ruby Threads are a major innovation But MRI has never really had a focus on concurrency 42
  43. Concurrency is great Cheaper to scale Good multi-threaded web servers 43
  44. More bang for your buck One server: MRI runs two Ruby processes One server: JRuby runs two Ruby processes with 4 threads each Can use JRuby on Heroku 44
  45. Concurrency is not free Bugs in non-thread safe libraries • Rails • Airbrake Libraries developed without a focus on concurrency 45
  46. Concurrency is not free Writing thread-safe code is difficult Even for Java developers with experience But concurrency is the new sexy 46
  47. Concurrency is worth it Huge performance improvements Some features would be much easier with threads Threads 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 deployment infrastructure? 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 later Lots of people switch for performance reasons 54
  55. Getting started with JRuby jruby-lint checks how ready your code is to run on JRuby 55
  56. Acknowledgments Pivotal Labs JRuby team 56
  57. Thanks! @MsFionaTay
Anzeige