jruby - programmer's best friend on jvm

Post on 16-May-2015

1.190 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Presentation at Java Day Riga 2012 conference

TRANSCRIPT

Raimonds Simanovskis

Programmer’s BestFriend on JVM

Raimonds Simanovskisgithub.com/rsim

@rsim

The easiest Business Intelligence tool on the Web

What isRuby?

object-orienteddynamic

programming language

simple from outside

powerful insideYukihiro

Matsumotoor “Matz”

Classes

Single Inheritance

Constructor

No Type Declarations

Instance Variables

Last expression is always return value

.new is just a class method

Blocks / ClosuresAnonymous function as argument

Modules

Metaprogramming

Classes/Modules are open

Integration with Java

Embed JRuby asscripting engine

Use Java classesfrom 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 RailsWeb 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

ActionController

ActiveRecord

ActionView

Browser

Request Router

Response

Database

SQL

ActiveRecord (Model)class CreatePosts < ActiveRecor::Migration def self.up create_table :posts do |t| t.string :title t.text :body t.timestamps end endend

CREATE TABLE posts ( id NUMBER(38) NOT NULL, title VARCHAR2(255), body CLOB, created_at DATE, updated_at DATE);CREATE SEQUENCE posts_seq;

class Post < ActiveRecord::Base # nothing here!endpost = Post.newpost.title = "First post"post.savepost = Post.find(1)puts post.name # output: "First post"

ActionControllerclass 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

JRuby Gems

Application

Application source

warbler

JRuby deployment

Web Server

Trinidad JRubyApache Tomcat

ApplicationApplication

sourcedeploy

Gems

JRuby deployment

eazyBI case studyRuby on Rails application

JRubyJetty

Application Gems

.com

deploy

Mondrian OLAP engine

Apache Batik SVG toolkit

Packaged application

Application Gems

Privatepackage

pluginOSGi bundleJRuby *.jar

Application Gems

jruby-rack

package

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

base64 richards neural mandelbrot redblack0

1.25

2.5

3.75

5

1.3461.538

1.914 1.8061.565

2.658

3.443.66

4.226 4.32

Times Faster than Ruby 1.9.3JRuby/Java 6 JRuby/Java 7

JRuby BenefitsEasy to learn for Java programmers

Easy to mix Ruby and Java

Useful frameworks and libraries

Ruby community

Higher productivity for many tasks

top related