Programmer’s Best Friend on JVM Raimonds Simanovskis
@rsim github.com/rsim Raimonds Simanovskis
The easiest Business Intelligence tool on the Web
What is Ruby?
object-oriented dynamic programming language simple from outside Yukihiro Matsumoto or “Matz” powerful inside
Classes
Single Inheritance
Constructor
No Type Declarations
Instance Variables
Last expression is always return value
.new is just a class method
Blocks / Closures Anonymous function as argument
Modules
Metaprogramming
Classes/Modules are open
Integration with Java Embed JRuby as scripting engine Use Java classes from JRuby
Embed JRuby
Embed JRuby
Use Java classes from JRuby Demo
Build with Rake
Test with Test::Unit or RSpec
Test with Test::Unit or RSpec
Ruby on Rails Web applications development framework Model View Controller (MVC) architecture Convention over Configuration Don’t Repeat Yourself (DRY) Focused on developer productivity Agile software development approach
MVC Architecture Request Router Database SQL Browser Response Action Active Controller Record Action View
ActiveRecord (Model) class CreatePosts < ActiveRecor::Migration def self.up create_table :posts do |t| CREATE TABLE posts ( t.string :title id NUMBER(38) NOT t.text :body NULL, t.timestamps title VARCHAR2(255), end body CLOB, end created_at DATE, end updated_at DATE ); CREATE SEQUENCE posts_seq; class Post < ActiveRecord::Base # nothing here! end post = Post.new post.title = "First post" post.save post = Post.find(1) puts post.name # output: "First post"
ActionController class PostsController < ApplicationController # GET /posts def index @posts = Post.all end # GET /posts/1 def show @post = Post.find(params[:id]) end # GET /posts/new def new @post = Post.new end # ... end
ActionView <h1>Posts</h1> <% @posts.each do |post| %> <h2><%= post.title %></h2> <h3>Created at <%= post.created_at %></h3> <p><%= post.body %></p> <% end %>
JRuby deployment <insert app server here> Java app sever Application WAR file Application JRuby Gems warbler source Application
JRuby deployment Web Server Trinidad JRuby Apache Tomcat Gems Application deploy Application source
JRuby deployment
eazyBI case study .com Ruby on Rails Jetty JRuby application deploy Application Gems Mondrian OLAP engine Apache Batik SVG toolkit pac Private kag e package Packaged application plugin OSGi bundle Application Gems JRuby jruby-rack *.jar Application Gems SQL Server
JRuby 1.7 and Java 7 invokedynamic
Ruby method calls
Ruby method calls
Ruby method calls
Ruby method calls
Ruby method calls
JRuby performance improvements JRuby/Java 6 JRuby/Java 7 Times Faster than Ruby 1.9.3 5 4.226 4.32 3.75 3.66 3.44 2.5 2.658 1.914 1.806 1.538 1.565 1.25 1.346 0 base64 richards neural mandelbrot redblack
JRuby Benefits Easy to learn for Java programmers Easy to mix Ruby and Java Useful frameworks and libraries Higher productivity for many tasks Ruby community

JRuby - Programmer's Best Friend on JVM