JRuby: Up and Running! Charles Oliver Nutter and Thomas Enebo

Slides:



Advertisements
Similar presentations
Chapter 15 © 2010 by Addison Wesley Longman, Inc Origins and Uses of Ruby - Designed by Yukihiro Matsumoto; released in Use spread rapidly.
Advertisements

Creating Web Services with Ruby on Rails Robert Thew Internet and Web Systems II.
Language of the Month If it’s December, it must be Ruby! Adam Coffman and Brent Beer.
Sakai on Rails Integrating Ruby and Sakai David Adams, Virginia Tech.
Ruby on Rails Tutorial Peter Mosca April, Ruby on Rails Tutorial Ruby History Invented 12 years ago in Japan by Yukihiro Matsumoto Spent first 5.
1 JRuby on Rails GAO ANG Sun Functional Campus Ambassador 1.
Ruby The Gem of new programming languages. An interpreted scripting language.
Ruby on Rails: An Introduction JA-SIG Summer Conference 2007 Michael Irion The University of Tulsa.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
A little engineering on Rails Robert W. Hasker. Goals Intro to the Rails framework ▫Basic concepts: MVC, Active Record ▫A bit of Ruby Using Rails to build.
Ruby on Rails Charles Severance Textbook: Build Your own Ruby on Rails Application by Patrick Lenz (ISBN: )
Ruby on Rails CSCI 6314 David Gaspar Jennifer Garcia Avila.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Ruby & rails by Nicholas Belotti. What is ruby Ruby is an object orientated scripting language. In Ruby...everything is an object! Ruby was released in.
JRuby: Bringing Ruby to the JVM™ Thomas E. Enebo, Aandtech Inc. Charles Oliver Nutter, Ventera Corp
Web Application Programming Carol Wolf Computer Science.
Why Java? A brief introduction to Java and its features Prepared by Mithat Konar.
Ruby! Ronald L. Ramos. What is Ruby? Ruby is a scripting language designed by Yukihiro Matsumoto, also known as Matz. It runs on a variety of platforms,
Ruby on Rails Your first app. Rails files app/ Contains the controllers, models, views and assets for your application. You’ll focus on this folder for.
Module Overview n Module Title: OO Programming n Module Code: MIT3446 n Module Value: 3.0 n Duration: 15 weeks n Class-Contact Hours: Lecture15 hrs n Lab/Tutor30hrs.
Ruby/Ruby on Rails Yasushi Osonoi Open Dream corporation
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Introduction to Ruby&Rails Yuri Veremeyenko Monica Verma.
© 2012 LogiGear Corporation. All Rights Reserved FitNesseFitNesse Authors: Nghia Pham 1.
Ruby on Rails. Web Framework for Ruby Designed to make it easier to develop, deploy, and maintain web applications Design with Model-View-Controller –almost.
Presented By P.SRIVIDYA 085D1A0552 Programming Language.
1 JRuby Now and Future Charles Oliver Nutter JRuby Guy Sun Microsystems Except where otherwise noted, the content of this presentation is licensed under.
Visual Mobile Gaming Your Name Sun Campus Ambassador Your Address.
1 JRuby: Up and Running! Charles Oliver Nutter and Thomas Enebo The JRuby Guys Sun Microsystems Except where otherwise noted, the content of this presentation.
NetBeans & Ruby David Botterill Software Engineer Global Technology Manager - Campus Ambassador Program Sun Microsystems, Inc.
1 JRuby Charles Oliver Nutter JRuby Guy Sun Microsystems 1.
JRuby: Ruby and Rails for the JVM Charles Nutter Except where otherwise noted, the content of this presentation is licensed under the Creative Commons.
CodeBeamer Bootcamp 2007 Customizing CodeBeamer features through scripting Aron Gombas Architect, Intland.
GlassFish Workshop 1 Dynamic Languages in GlassFish Arun Gupta blogs.sun.com/arungupta.
1 Charles Oliver Nutter Thomas Enebo Tor Norbye Martin Krauskopf JRuby: Understanding the Fuss Except where otherwise noted, the content of this presentation.
Netbeans: Beyond Java Silveira Neto Sun Campus Ambassador University of Ceará, Brazil.
JRuby on Rails Presenter Name
JRuby on Rails Brian Leonard ブライアン レオナルド
1 Sun Microsystems, Ruby, and JRuby Charles Oliver Nutter Senior Staff Engineer Sun Microsystems Except where otherwise noted, the content of this presentation.
Progress Apama Fundamentals
JRuby: Ready for ACTION!
Ruby: An Introduction Created by Yukihiro Matsumoto in 1993 (named after his birthstone) Pure OO language (even the number 1 is an instance of a class)
Scope History of Ruby. Where can you use Ruby? General Features.
JRuby: Up and Running! Charles Oliver Nutter and Thomas Enebo
Chapter 1 Introduction to Computers, Programs, and Java
Ruby Tooling in NetBeans
Platform as a Service.

JRuby Charles Oliver Nutter
JRuby on Rails Charles Oliver Nutter JRuby Core Developer
The plan What's JRuby? The Ruby language Why JRuby? How to use it
PHP Training at GoLogica in Bangalore
Longtime Java developer More recent Ruby developer
JRuby It's What's For Dinner
JRuby: Up and Running! Charles Oliver Nutter and Thomas Enebo
Ruby, Rails, GUIs, and More
PHP / MySQL Introduction
JRuby State of the Art! Except where otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution-Share Alike 3.0.
JRuby Charles Oliver Nutter JRuby Guy Sun Microsystems
Scripting Java with JRuby
CMPE419 Mobile Application Development
SharePoint Framework Extensions
JRuby: Bringing Ruby to the JVM™
MIT GSL 2018 week 3 | thursday Meteor and App Ideation.
Google App Engine Ying Zou 01/24/2016.
2/24/2019 6:15 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
(Computer fundamental Lab)
CMPE419 Mobile Application Development
Web Application Development Using PHP
Presentation transcript:

JRuby: Up and Running! Charles Oliver Nutter and Thomas Enebo The JRuby Guys Sun Microsystems Except where otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License (http://creativecommons.org/licenses/by-sa/3.0/us/).

Agenda JRuby overview Real-world JRuby Swing programming Tools and IDE support Graphics and applets (that don't suck) Web applications Interactive: what do you want to know?

The JRuby Guys Charles Oliver Nutter and Thomas Enebo Longtime Java developers (10+ yrs each) Engineers at Sun Microsystems for 1 yr Full-time JRuby developers Also working on JVM dynlang support Wide range of past experience C, C++, C#, Perl, Python, Delphi, Lisp, Scheme Java EE and ME, JINI, WS

What Is Ruby Dynamic-typed, pure OO language Interpreted Open source, written in C Good: easy to write, easy to read, powerful, “fun” Bad: green threads, unicode support, libraries, “slow” Created 1993 by Yukihiro “Matz” Matsumoto “More powerful than Perl and more OO than Python” Very active community, wide range of apps Ruby 1.8.x is current, 1.9 is in development to become 2.0

Ruby Quick Tour: Pure OO Everything is an Object Circle.new(4) => instance of Circle “abc”.length => 3 1.to_s => “1” All Objects are instances of Classes 1.class => Fixnum Single-Inheritance Object is base class of all classes

Ruby Quick Tour: Basics Literals Fixnum: 1 Float: 1.0 Bignum: 12345678987654321 String: “one” 'one' %Q[one] %q[one] ... Multiline string (“here doc”): x = <<EOS extend across two lines EOS Symbol: :one, %s[one] Regexp: /^foo\w+.*bar$/, %r[^foo$] Array: [1, “ein”, :ichi] Hash: {:one => 1, :two => 2}

Ruby Quick Tour: Basics String interpolation a = “foo” b = “bar#{a}baz” => “barfoobaz” Operator overloading def +(arg); ... Attributes class Foo attr_accessor :a end x = Foo.new x.a = “hello” puts x.a => “hello”

Ruby Quick Tour: Duck Typing Dynamic typing “If it waddles like a duck and it quacks like a duck...” Runtime errors rarely happen Unit testing helps prevent them def make_it_waddle(waddler) waddler.waddle end make_it_waddle(Duck.new) make_it_waddle(Penguin.new) make_it_waddle(Octopus.new)

Ruby Quick Tour: A Simple Class class Hello # initialize is Ruby's constructor def initialize(message) @message = message end def print # insert the @message into a string puts "Hello #{@message}" # construct a Hello object hello = Hello.new("JAOO!") hello.print

Ruby Quick Tour: Blocks/Closures # two formats: braces {} and do .. end [1, 2, 3].each {|number| puts “I see #{number}“ } [1, 2, 3].each do |number| puts “I see #{number}“ end # methods that accept blocks def foo yield “hello“ def foo2(&block) block.call(“hello“)

Ruby Quick Tour: Modules # A collection of objects class MyProducts # Enumerable provides iteration methods include Enumerable # define an 'each' method that iterates def each # yield each element in turn end list = MyProducts.new list.select {|item| item.price > 5.00} list.sort {|a, b| a.name <=> b.name} list.max

JRuby Java implementation of Ruby language “It's just Ruby!” Started in 2002, open source, many contributors Ola Bini, Marcin Mielzynsky, Nick Sieger, Bill Dortch, Vladimir Sizikov, MenTaLguY Aiming for compatibility with current Ruby version Ruby 1.8.6 patchlevel 111 (114 was just released) Improvements on Ruby Native threading, better performance, many libraries

JRuby 1.1 Released! JRuby 1.1 is finished! Massive improvements over 1.0 Full compiler for Ruby code to JVM bytecode Performance is many times better across the board New Regexp impl with full Oniguruma features New rewritten IO subsystem to parallel Ruby behavior Reduced memory footprint Best compatibility level ever Ready for production use (and already being used) Quick series of maintenance releases coming

DEMO Interactive JRuby 14

Where is JRuby being used? Swing GUI development Makes Swing much nicer to use, easier to handle Tooling for IDEs JRuby's parser enables NetBeans, Eclipse, IntelliJ Graphics Ruby + graphics = cool demos JRuby on Rails Better deployment options, better performance

Swing GUI Programming Swing API is very large, complex Ruby magic simplifies most of the tricky bits Java is a very verbose language Ruby makes Swing actually fun No consistent cross-platform GUI library for Ruby Swing works everywhere Java does (everywhere) No fire-and-forget execution No dependencies: any script works on any JRuby install

DEMO Swing in Ruby 17

Swing Options Cheri - cheri.rubyforge.org Builder-like DSL syntax Profligacy - ihate.rubyforge.org/profligacy Rubified layout expression language Trivial event binding without listeners MonkeyBars - monkeybars.rubyforge.org Leverage GUI builders MVC structure

JRuby Enables Tooling JRuby's parser used by most Ruby IDEs NetBeans Ruby Support Eclipse RDT/RadRails/Aptana, DLTK, 3rd Rail IntelliJ (not parser, but other areas) Jedit NetBeans is the best right now

DEMO NetBeans Ruby and Rails 20

Pretty Graphics! “Processing is an open source programming language and environment for people who want to program images, animation, and interactions.” Basically a cool Java library for 2D graphics Ruby-Processing wraps Processing with JRuby Cool, rubified 2D graphics environment for you Eye-candy demos for us Thanks to Jeremy Ashkenas for putting these together

DEMO Pretty Graphics! 22

Web applications Classic Java web dev is too complicated Modern frameworks follow Rails' lead Over-flexible, over-configured Conventions trump repetition and configuration Rails deployment is still a pain You shouldn't need N processes! Rails performance should be better JRuby has potential to be much faster

Ruby on Rails A Full-stack MVC web development framework Open Source (MIT), Many Contributors Written in Ruby Single-Threaded design First released in 2004 by David Heinemeier Hansson Ruby and Rails book sales are outselling Perl book sales

Rails Precepts Convention over Configuration Why punish the common cases? Encourages standard practices Everything simpler and smaller Don't Repeat Yourself (DRY) Framework written around minimizing repetition Repetitive code harmful to adaptability Agile Development Environment No recompile, deploy, restart cycles Simple tools to generate code quickly Testing built into framework

The Rails Way: Controllers # app/controllers/person_controller.rb class PersonController < ApplicationController verify :method => :post, :only => [:create, :update, :delete] def list @all_people = Person.find :all end alias :index :list def update @entry = Person.find(params[:id]) @entry.update_attributes(params[:person]) redirect_to :action => 'list' ... Rails Example

The Rails Way: Views Rails Example <!-- app/views/person/list.rhtml --> <table> <tr> <% for column in Person.content_columns %> <th><%= column.human_name %></th> <% end %> </tr> <% for person in @people %> <td><%=h person.send(column.name) %></td> <td><%= link_to 'Show', :action => 'show', :id => person %></td> <td><%= link_to 'Edit', :action => 'edit', :id => person %></td> <td><%= link_to 'Destroy', { :action => 'destroy', :id => person }, :confirm => 'Are you sure?', :method => :post %></td> </table> <%= link_to 'Previous page', { :page => @person_pages.current.previous } if @person_pages.current.previous %> <%= link_to 'Next page', { :page => @person_pages.current.next } if @person_pages.current.next %> Rails Example

The Rails Way: Persistence # connect to the database ActiveRecord::Base.establish_connection( :adapter => "mysql", :database => "mydb", :host => "localhost", :username => "mydb_user", :password => "foo" ) # create a model object class Contact < ActiveRecord::Base end # persist! Contact.create "name" => "Charles Nutter", "title" => "JRuby Developer" Contact.create "name" => "Thomas Enebo", "title" => "JRuby Developer" # query Contact.find(:all).each {|c| puts c.name} nutter = Contact.find_by_name("Charles Nutter") # update nutter.title = "Dark Overlord of the Universe" nutter.save Rails Example

ActiveRecord Migrations # db/migrate/001_add_user_table.rb class AddUserTable < ActiveRecord::Migration def self.up create_table :users do |t| t.column :first_name, :string t.column :last_name, :string t.column :birthday, :date end def self.down drop_table :users Rails Example

DEMO The MySQL “World” App 30

Production JRuby on Rails Oracle's Mix – digg-like social customer site mix.oracle.com Sun's MediaCast – file distribution portal mediacast.sun.com ThoughtWorks' Mingle – collaborative project mgmt mingle.thoughtworks.com Sonar – code/project analysis tool sonar.hortis.ch More on the way!

Thank you! JRuby - www.jruby.org wiki.jruby.org GlassFish - glassfish.dev.java.net gem install glassfish Looking for bug reports, feature requests! NetBeans - www.netbeans.org Try it out, send feedback! Charlie's blog: headius.blogspot.com Tom's blg: www.bloglines.com/blog/ThomasEEnebo