Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JRuby Everywhere! Bringing a world of opportuni...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for headius headius
September 13, 2025

JRuby Everywhere! Bringing a world of opportunities to the Ruby community

Delivered at RubyConf India 2025 on 13 September

Avatar for headius

headius

September 13, 2025

More Decks by headius

Other Decks in Programming

Transcript

  1. @headius headius.com नम स् ते ! • Charles Oliver Nutter

    • "headius" on all the socials! • JRuby core developer since 2005 • Founder of Headius Enterprises • "The JRuby Company" • Excited to be back at RCI!
  2. @headius headius.com What is JRuby? • Ruby on the Java

    Virtual Machine • Ruby implementation fi rst, JVM language second • Many bene fi ts from JVM ecosystem • Ruby code should "just work" • Try your code, your library • If something doesn't work, let us know!
  3. @headius headius.com JRuby Users Worldwide • Thousands of applications running

    JRuby • Production users since 2007 • Only alternative Ruby to see widespread production use! • I will showcase a few users for you today • Each user could not use Ruby without JRuby • Maybe your company will be a showcase next year!
  4. @headius headius.com JRuby = Opportunity • Ruby is hard to

    sell to the enterprise! • They don't want another runtime • C code is insecure, needs C compiler • Ruby ecosystem missing many libraries • Real world demands parallelism • JRuby is your ticket to the enterprise! • JVM is trusted, secure, parallel, scalable
  5. @headius headius.com $ java -version openjdk version "24" 2025-03-18 OpenJDK

    Runtime Environment (build 24+36-3646) OpenJDK 64-Bit Server VM (build 24+36-3646, mixed mode, sharing) $ ruby-install jruby-10.0.2.0 >>> Updating jruby versions ... >>> Installing jruby 10.0.2.0 into /Users/headius/.rubies/jruby-10.0.2.0 ... >>> Downloading https://repo1.maven.org/maven2/org/jruby/jruby-dist/10.0.2.0/jruby- dist-10.0.2.0-bin.tar.gz into /Users/headius/src ... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 32.1M 100 32.1M 0 0 7887k 0 0:00:04 0:00:04 --:--:-- 7887k >>> Verifying jruby-dist-10.0.2.0-bin.tar.gz ... >>> Extracting jruby-dist-10.0.2.0-bin.tar.gz to /Users/headius/src/jruby-10.0.2.0 ... >>> Installing jruby 10.0.2.0 ... >>> Symlinking bin/ruby to bin/jruby ... >>> Successfully installed jruby 10.0.2.0 into /Users/headius/.rubies/jruby-10.0.2.0
  6. @headius headius.com $ java -version openjdk version "24" 2025-03-18 OpenJDK

    Runtime Environment (build 24+36-3646) OpenJDK 64-Bit Server VM (build 24+36-3646, mixed mode, sharing) $ ruby-install jruby-10.0.2.0 >>> Updating jruby versions ... >>> Installing jruby 10.0.2.0 into /Users/headius/.rubies/jruby-10.0.2.0 ... >>> Downloading https://repo1.maven.org/maven2/org/jruby/jruby-dist/10.0.2.0/jruby- dist-10.0.2.0-bin.tar.gz into /Users/headius/src ... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 32.1M 100 32.1M 0 0 7887k 0 0:00:04 0:00:04 --:--:-- 7887k >>> Verifying jruby-dist-10.0.2.0-bin.tar.gz ... >>> Extracting jruby-dist-10.0.2.0-bin.tar.gz to /Users/headius/src/jruby-10.0.2.0 ... >>> Installing jruby 10.0.2.0 ... >>> Symlinking bin/ruby to bin/jruby ... >>> Successfully installed jruby 10.0.2.0 into /Users/headius/.rubies/jruby-10.0.2.0
  7. @headius headius.com [] ~ $ irb >> RUBY_VERSION => "3.4.5"

    >> JRUBY_VERSION => "10.0.2.0" >> runtime = java.lang.Runtime.runtime => #<Java::JavaLang::Runtime:0x64a896b0> >> runtime.available_processors => 10 >> runtime.free_memory => 385494344
  8. @headius headius.com User: Quantum Inventions • Software for intelligent transport

    systems, focusing on smart city mobility and fl eet mobility as a service. • Rails-based GUI apps deployed on- premises with Oracle DB and WebLogic • User-acceptance testing using packaged JRuby apps within customer environments • Ruby-based data processing packaged as JRuby apps run by customers • https://quantuminventions.com/
  9. @headius headius.com Ruby Compatibility • JRuby 10 supports Ruby 3.4

    • Language and core specs: 98% passing • Pure-Ruby standard library shared with CRuby • JRuby support for most native stdlib • JRuby 9.4 supports Ruby 3.1 • Maintained until April 2026
  10. @headius headius.com JVM Language • JRuby is a fi rst-class

    JVM language • Extensions are written in Java, not insecure C code • JVM can optimize Ruby code just like Java • JVM garbage collector is concurrent and ef fi cient • We write Java so you don't have to! • But you can if you want to! (or Scala, Clojure, Kotlin...)
  11. @headius headius.com JRuby Architecture Ruby (.rb) JIT Java Instructions (java

    bytecode) Ruby Instructions (IR) parse interpret interpreter interpret C1 compile native code better native code java bytecode interpreter execute C2 compile Java Virtual Machine JRuby Internals
  12. @headius headius.com User Focus: Poshmark • Leading social commerce marketplace

    with millions of users • High concurrency and heavy transaction volumes daily • Leveraging JVM ecosystem for resilience, growth, and scaling • Migrating to MongoDB Java driver reduced p50 by 30% and p95 by 35% • https://poshmark.com/
  13. @headius headius.com Poshmark says... "JRuby has been integral to Poshmark's

    stack for over a decade and remains a cornerstone of scalability and innovation"
  14. @headius headius.com A World of Libraries • JVM ecosystem has

    tens of thousands of libraries • Graphics, GUIs, servers, document formats, AI/LLM • One of the largest collections in the dev world • All available to JRuby users! • Easy integration into Ruby apps and code • "Magic" to make Java APIs look like Ruby
  15. @headius headius.com Example: 3D Bar Chart with JFreeChart • Chart-generating

    library with support for document output • Easily used from JRuby • https://blog.headius.com/ 2025/05/3d-charts-and-more-with- jruby-and-jfreechart.html
  16. @headius headius.com Dependencies • Jar fi le, like Gem fi

    le • Like Bundler's Gem fi le • Maven "coordinates" • lock_jars command • Like bundle install jar 'org.jfree:jfreechart:1.5.5' jar 'org.jfree:org.jfree.chart3d:2.1.0' $ lock_jars -- jar root dependencies -- org.jfree:jfreechart:1.5.5:compile org.jfree:org.jfree.chart3d:2.1.0:compile org.jfree:org.jfree.svg:5.0.6:compile org.jfree:org.jfree.pdf:2.0:compile Jars.lock updated Jar fi le
  17. @headius headius.com java_import org.jfree.chart3d.data.StandardCategoryDataset3D java_import org.jfree.chart3d.data.DefaultKeyedValues ... require 'json' data

    = JSON.load(File.read("data/app_monitoring_revenue.json")) dataset = StandardCategoryDataset3D.new data.each do |name, subset| values = DefaultKeyedValues.new subset.each { values.put(_1, _2) } dataset.add_series_as_row name, values end
  18. @headius headius.com Create a 3D Bar Chart chart = Chart3DFactory.create_bar_chart(

    "Quarterly Revenues", "Application & Performance Monitoring Companies", dataset, nil, "Quarter", "$million Revenues") chart.chart_box_color = Color.new(255, 255, 255, 127) chart.legend_anchor = LegendAnchor::BOTTOM_RIGHT
  19. @headius headius.com Generate PNG width, height = 600, 500 category_chart_image

    = BufferedImage.new(width, height, BufferedImage::TYPE_INT_RGB) category_chart_graphics = category_chart_image.create_graphics chart.draw(category_chart_graphics, Rectangle.new(width, height)) category_chart_file = File.open("category_chart.png", "w") ImageIO.write(category_chart_image, "PNG", category_chart_file.to_outputstream)
  20. @headius headius.com Render to SVG and PDF svg_graphics = SVGGraphics2D.new(width,

    height) svg_graphics.defs_key_prefix = "jruby_charts" chart.element_hinting = true chart.draw(svg_graphics, Rectangle.new(width, height)) svg = svg_graphics.get_svg_element chart.id File.write("category_chart.svg", svg) pdf_doc = PDFDocument.new pdf_doc.title = "Application & Performance Monitoring Companies Revenue" pdf_doc.author = "Charles Oliver Nutter"; page = pdf_doc.create_page(Rectangle.new(612, 468)) pdf_graphics = page.graphics2D chart.draw(pdf_graphics, Rectangle.new(0, 0, 612, 468)) File.write("category_chart.pdf", pdf_doc.pdf_bytes)
  21. @headius headius.com Glimmer • Ruby DSL for GUI applications •

    Multiple backends (SWT, GTK, ...) • JRuby + SWT is the most mature • Cross-platform GUI is easy with JRuby! • Deployable everywhere • GUI libraries shipped with application • https://github.com/AndyObtiva/glimmer
  22. @headius headius.com JRuby on Android • Ruboto: JRuby framework for

    Android • Build apps using Ruby! • Ruboto IRB: demo application • "Ruboto Core" and "Ruboto IRB" APKs • Used in production apps for years • Help us update for latest JRuby, Android
  23. @headius headius.com User Focus: Kami • An interactive, accessible learning

    platform with intentional AI, actionable insights, and inclusive tools for students and teachers • Scaling Ruby for high-throughput workloads (millions of PDFs per day) • Access to the vast library of Java document, image, and PDF libraries • Uni fi ed Ruby experience across project teams • https://www.kamiapp.com/
  24. @headius headius.com User Focus: eazyBI • World-class reporting and business

    intelligence, integrated into the Atlassian stack • JRuby user since 2011 • Integration with Java libraries like Mondrian OLAP, Apache POI, Batik • Deployment as a Jira plugin .jar fi le • Real multithreading without global lock for heavy parallel worker pools and data import jobs • Deploy on Windows more easily than CRuby • https://eazybi.com/
  25. @headius headius.com JRuby Leads the Way • JRuby has been

    meeting the challenges of Ruby • JIT compiler: JRuby added JIT in 2008 • Optimized garbage collection: JVMs are best in the world • Concurrency, parallelism: JRuby is fully parallel • We move fast and help solve Ruby's problems!
  26. @headius headius.com JVM GC • Many options to tune JVM

    GCs • Heap size: small or large? • Throughput: faster allocations or shorter pause times? • Working set: large in-memory or mostly new objects? • Many options in standard OpenJDK • Serial, Parallel, G1, ZGC, Shenandoah
  27. @headius headius.com JVM Performance • JRuby depends on JVM for

    most optimization • JVM has world-class JIT compilers, garbage collectors • Similar design to ZJIT, but with 30 years of work in it • JRuby itself has an IR, basic block-based interpreter and JIT • Similar design to ZJIT starting in JRuby 9.0 (2015)
  28. @headius headius.com 0M 3.5M 7M 10.5M 14M Object.new allocations per

    second 0M 13M 10.3M Ruby 3.4 + YJIT Ruby 3.5 + opt_new JRuby 10
  29. @headius headius.com 0M 56.25M 112.5M 168.75M 225M Object.new allocations per

    second 217.5M 13M 10.3M Ruby 3.4 + YJIT Ruby 3.5 + opt_new JRuby 10 🤯
  30. @headius headius.com JVM Concurrency • Ractors are designed to bring

    concurrency to Ruby • You must write Ractor-friendly code (immutable objects) • High overhead crossing Ractor boundary • Threads in JRuby are already 100% parallel • Immutable objects FTW • Low overhead for threads and shared memory
  31. @headius headius.com if THREADS queues = CONCURRENT.times.map { Queue.new }

    threads = CONCURRENT.times.map do |i| Thread.new do queue = queues[i] data_chunk = queue.pop data_chunk.each { |item| JSON.parse(item) } end end end
  32. @headius headius.com Threads vs Ractors 0 1.25 2.5 3.75 5

    times faster than linear 4.2x 1.2x 1.1x CRuby threads CRuby ractors JRuby threads
  33. @headius headius.com Baseline Rails App • Scaffolded "blog" application on

    PostgreSQL, Puma • IBM VPC instance: 8 vCPU, 32GB • CRuby 3.2, 16 workers • JRuby 9.4: 16 threads • Database, siege benchmark driver on same instance
  34. @headius headius.com requests per second (higher is better) 0rps 450rps

    900rps 1350rps 1800rps 1,705rps 1,550rps CRuby + YJIT JRuby Memory required 0MB 2000MB 4000MB 6000MB 8000MB 1 user 16 users 160 users CRuby JRuby
  35. @headius headius.com User Focus: Logstash • Open-source data processing engine

    in the Elastic stack, for logging, observability, and security • JRuby user since 2012 • Hundreds of thousands of events per second using JRuby's multithreading • Integration with Java libraries and servers • Core queue in Java with integration and plugins handled by JRuby • Deployed as JVM-based package across all platforms • https://www.elastic.co/logstash
  36. @headius headius.com Logstash says... "[JRuby was] chosen to overcome MRI

    Ruby's lack of multithreading and to leverage the vast and mature ecosystem of Java"
  37. @headius headius.com User Focus: SubstituteAlert • Leading tool for substitute

    teacher alerts and assignment • JRuby users since 2013 • Real concurrency for highly-parallel backend that would be hard in CRuby • Java integration with Firebase for Android noti fi cations • Better performance pro fi ling tools for JVM • https://www.subalert.com/
  38. @headius headius.com JRuby 10.x • Many more optimizations coming! •

    Now that we are 3.4 compatible, we can work on fun stuff • If you fi nd something that's slow, let us! • More JDK features • JVM features to improve startup, fast native library integration • Upgrade JVM, your JRuby code runs faster!
  39. @headius headius.com Headius Enterprises • Continuing JRuby development • Support

    contracts • Developer relations • Partner with us! • Tell your team about JRuby • Help us make JRuby better • headius.com/jruby_support
  40. @headius headius.com Try JRuby! • Building an app? • Try

    to run on JRuby • Let us know what you need • Library author? • Add JRuby to CI • Report any issues • Let's talk! I have STICKERS!
  41. @headius headius.com Thank You! • Please get in touch! •

    @headius • @[email protected] • @headius.bsky.social • linkedin.com/in/headius/ • [email protected] • headius.com/welcome