SlideShare une entreprise Scribd logo
1  sur  54
1 JRuby in Java Projects Denis Lutz
2 Motivation: Problem, Solution JRuby as language Java and Ruby Integration  Ruby Community Show Case Demo Usage areas for JRuby Agenda
3 Motivation
4 Lets redefine our thinking What is our task? What is the shortest path to the solution? Since… Not the solving of complicated tasks is the goal …but solving our task in the easiest possible way Motivation
5 Java has a huge set of tools JVM scripting languages are present (Groovy) You can find a tool for everything The java magazines are writing about scripting languages Theory
6 Projectwide scripting support not the rule, more an exception Ant = scripting language =>  XML is our scripting language If scripting language integration => Ant / Spring is the environment Adhoc scripting areas are randomly used by single devs Instead a major scripting support strategy is missing Young developers face only java or ant  Young devs are on their own to find more expressive languages Real world praxis
7 Entering JRuby
8 scripting tool as one of main and known tools scripting language as the surrounding environment and entry point (not Ant) clearly decleared scripting language standard definition of taks areas for the scripting language easy and powerfull communication with the underlying operating system powerfull language features instead of XML tools (Ant, Maven) knowledge reuse because of definition of several scripting areas in a projekt from GUIs and IDEs to automation and console procedures from enterprisy java community to a fun community in ruby Goal
9 What is JRuby ,[object Object]
Runs in JVM and integrates perfectly into Java environments
very expressive
mature
huge community powered by the Ruby on Rails framework,[object Object]
11 Facets of JRuby
12 Download Jruby at www.jruby.org Extract Add to  $PATH Test your installation with “jruby –v” on the console Command execution with “jruby –S ‘command’ ” jruby –S irb        -> Will start the JRuby console Get started with JRuby in 3 mins…
13 Simple Syntax Everything is an object Blocks Self contained ( contains most useful libs out of the box) Open classes Principle of least surprise Most imressive language features
14 Simple object creation
15 Create your class and use it, lightweight and easy!
16 Everything is an object
17 Blocks, the most amazing and powerful feature ever
18 Lets call JRuby from Java public void callJRuby() {   ScriptEngineManager m = new ScriptEngineManager();  ScriptEngine rubyEngine = m.getEngineByName("jruby");  if (rubyEngine==null)       throw new RuntimeException("Did not find my ruby engine");  ScriptContext context = rubyEngine.getContext();  context.setAttribute("world","Programmierer",ScriptContext.ENGINE_SCOPE);  try{    File f = new File("hello1.rb");     BufferedReader br = new BufferedReader(new FileReader(f));     rubyEngine.eval(br, context); // (1)   } catch (ScriptException e) {   e.printStackTrace();   } catch (FileNotFoundException fnfe) {     System.err.println(fnfe.getMessage());   }}
19 require 'java’ java_import java.lang.System  => Java::JavaLang::System  version = System.getProperties["java.runtime.version"]  => "1.6.0_17-b04-248-10M3025”  import java.util.ArrayList list = ArrayList.new  => #<Java::JavaUtil::ArrayList:0x2bf09a31>  ruby-1.8.7-p334 :042 > iterator = list.iterator  => #<#<Class:01x41a7c484>:0x367c218e>  ruby-1.8.7-p334 :043 > iterator.java_class  => class java.util.AbstractList$Itr  ruby-1.8.7-p334 :044 > list.get(1) NativeException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 Lets call Java from Jruby und use your legacy systems
20 Ruby’s Community
21 Very strong community, why? Got powered by Ruby on Rails (MVC Framework) Fun oriented community Motivated hobby programmers, who can be 9-5 employees ;-) Get into positive cycle of beeing threated well and wanting more ruby GEMS = ruby libraries, created by the community Community
22 Endless amounts of gems
23 Find most popular gems in one place, rated by the community
24 Live Demo: Using a GEM
25 we want to communicate with a REST API should be usable within a build or inside a java class of course Should provide an easy API for our java class The task Easiest solution (a base for it) ?
26 Choose your gem HTTParty Choose HTTParty as the gem for REST communication
27 Install the GEM
28 Write our nice little class
29 Use it immidiatelly on the console to play with it
30 We knew from one site about the best fitting GEM for our task We had no troubles installing it I can try my written code on the console it just works, doesn’t matter what you install its my experience after two years using ruby, yours will be the same Why was this great?
31 Integration with Java
32 Yes its right, Rails got over JSF (java standard) in the meanwhile Is this still a new and not known technology for you? Rails (Ruby) popularity
33 Yes, possible and widely used JRuby on Rails Frontend as war file in Tomcat Rails Front Ends in Java Projects possible  everything else is waste of money and developers frustration No risk, tell to your java influenced boss: „its just a war file“   No server infrastructure changes needed Deploy a Ruby on Rails Application in a java war jruby -S gem install -y rails warbler $RAILS_APP_ROOT/jruby -S warble war
34 Java Build with Rake
35 Rake as build tool in Java projects Basic problem: ANT is accepted, Maven the „new standard“ None of them is sufficient for the task we want to do Why?
36 Projectsetup, its in the Wiki, well because Ant cant do it ;-)  Folders and File management „if“ – „else“ , can you declare it out of your head now in Ant?   Declare a method in your build? Oh, yea no problem let me just look into Ant API Loading of fixtures, possible with some XML setup again Server startup? I am doing it by hand and each new developer has to learn the specifics  Maven „the biggest hype“ that helps me even less then Ant Problems with Ant and others…
37 Full language power in your build, not XML We can still call our old Ant tasks UNIX operations as if we would be on the console Method declarations, as simple as possible Reuse of a language we already use not learning new XML frameworks What we want
38 Rake does all you want : project setup methods operating system calls objects in your build file operations Ivy integration Rake is the solution, rubys build tool
39 Rake in 3 mins, nothing is easier!
40 Call classic and custom Ant tasks from rake if needed
41 Operating system communication File management Folder management Talk to your operating system as from the console
42 Some rake possibilities = just full ruby power
43 In/Out API for your project
44 Its difficult to process files as well as different formats in java Import or Export is mostly a focused single task Can be done separated, by one developer No requirement to do it in java Customer data import is a very common and important task Use JRuby to provide an import / export API Data processing much faster Easy CSV, Excel, XML processing  Generate projects specific formats for import JRuby as your In/Out API of any project
45 JRuby as your In/Out API of any project
46 (Integration) Testing
47 Integration tests are the best candidate to do it with JRuby Abstract, mimal input, very high coverage Are easy to keep out of the java environment system Can be perfectly done with pure ruby WEBRAT GEM as JRuby Library Integration Testing
48 Webrat Example
49 GUI Testing API Evaluates the pure HTML output No browser setup or dependency to run your tests Write your tests fast in ruby  Cover the complete application workflow with minimal effort Can be run automatically in backgroud while developing Excellent to give fast feedback about application stability Webrat
50 Expected Result from  Jruby integration
51 All mentioned task areas can be done easier in JRuby More choices of tools, as would it be only with Java Knowledge reuse in different project areas Work is getting more lightweigt From java IDEs to fast editors Perfect interaction between different parts of the build Expected result

Contenu connexe

Tendances

Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Anton Arhipov
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyBruno Oliveira
 
Mashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMatt Butcher
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMTom Lee
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Anton Arhipov
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaKeith Bennett
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machineLaxman Puri
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924yohanbeschi
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Charles Nutter
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overviewjeresig
 
Spring into rails
Spring into railsSpring into rails
Spring into railsHiro Asari
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes BackBurke Libbey
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developergicappa
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsAgnieszka Figiel
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classesyoavwix
 

Tendances (19)

Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
 
Mashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMashups with Drupal and QueryPath
Mashups with Drupal and QueryPath
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVM
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overview
 
Spring into rails
Spring into railsSpring into rails
Spring into rails
 
55 New Features in Java 7
55 New Features in Java 755 New Features in Java 7
55 New Features in Java 7
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
JVM
JVMJVM
JVM
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classes
 

Similaire à JRuby in Java Projects

From Ant to Rake
From Ant to RakeFrom Ant to Rake
From Ant to Rakejazzman1980
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBrian Sam-Bodden
 
Java Programming (M&M)
Java Programming (M&M)Java Programming (M&M)
Java Programming (M&M)mafffffe19
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java LanguagePawanMM
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java SlidesVinit Vyas
 
Dynamic Languages on the JVM
Dynamic Languages on the JVMDynamic Languages on the JVM
Dynamic Languages on the JVMelliando dias
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting StartedMartin Chapman
 
JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?Charlie Gracie
 
#JavaOne What's in an object?
#JavaOne What's in an object?#JavaOne What's in an object?
#JavaOne What's in an object?Charlie Gracie
 
EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008geraldbauer
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)Shaharyar khan
 
Intoduction to java
Intoduction to javaIntoduction to java
Intoduction to javajalinder123
 
Dr. Rajeshree Khande :Intoduction to java
Dr. Rajeshree Khande :Intoduction to javaDr. Rajeshree Khande :Intoduction to java
Dr. Rajeshree Khande :Intoduction to javaDrRajeshreeKhande
 

Similaire à JRuby in Java Projects (20)

From Ant to Rake
From Ant to RakeFrom Ant to Rake
From Ant to Rake
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
00 intro to java
00 intro to java00 intro to java
00 intro to java
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
Java Programming (M&M)
Java Programming (M&M)Java Programming (M&M)
Java Programming (M&M)
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 
Real World Technologies
Real World TechnologiesReal World Technologies
Real World Technologies
 
Java presentation
Java presentationJava presentation
Java presentation
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
 
Dynamic Languages on the JVM
Dynamic Languages on the JVMDynamic Languages on the JVM
Dynamic Languages on the JVM
 
java new technology
java new technologyjava new technology
java new technology
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
 
JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?
 
#JavaOne What's in an object?
#JavaOne What's in an object?#JavaOne What's in an object?
#JavaOne What's in an object?
 
EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008
 
Java Programming Basics
Java Programming BasicsJava Programming Basics
Java Programming Basics
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
 
Intoduction to java
Intoduction to javaIntoduction to java
Intoduction to java
 
Dr. Rajeshree Khande :Intoduction to java
Dr. Rajeshree Khande :Intoduction to javaDr. Rajeshree Khande :Intoduction to java
Dr. Rajeshree Khande :Intoduction to java
 

Dernier

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Dernier (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 

JRuby in Java Projects

  • 1. 1 JRuby in Java Projects Denis Lutz
  • 2. 2 Motivation: Problem, Solution JRuby as language Java and Ruby Integration Ruby Community Show Case Demo Usage areas for JRuby Agenda
  • 4. 4 Lets redefine our thinking What is our task? What is the shortest path to the solution? Since… Not the solving of complicated tasks is the goal …but solving our task in the easiest possible way Motivation
  • 5. 5 Java has a huge set of tools JVM scripting languages are present (Groovy) You can find a tool for everything The java magazines are writing about scripting languages Theory
  • 6. 6 Projectwide scripting support not the rule, more an exception Ant = scripting language => XML is our scripting language If scripting language integration => Ant / Spring is the environment Adhoc scripting areas are randomly used by single devs Instead a major scripting support strategy is missing Young developers face only java or ant Young devs are on their own to find more expressive languages Real world praxis
  • 8. 8 scripting tool as one of main and known tools scripting language as the surrounding environment and entry point (not Ant) clearly decleared scripting language standard definition of taks areas for the scripting language easy and powerfull communication with the underlying operating system powerfull language features instead of XML tools (Ant, Maven) knowledge reuse because of definition of several scripting areas in a projekt from GUIs and IDEs to automation and console procedures from enterprisy java community to a fun community in ruby Goal
  • 9.
  • 10. Runs in JVM and integrates perfectly into Java environments
  • 13.
  • 14. 11 Facets of JRuby
  • 15. 12 Download Jruby at www.jruby.org Extract Add to $PATH Test your installation with “jruby –v” on the console Command execution with “jruby –S ‘command’ ” jruby –S irb -> Will start the JRuby console Get started with JRuby in 3 mins…
  • 16. 13 Simple Syntax Everything is an object Blocks Self contained ( contains most useful libs out of the box) Open classes Principle of least surprise Most imressive language features
  • 17. 14 Simple object creation
  • 18. 15 Create your class and use it, lightweight and easy!
  • 19. 16 Everything is an object
  • 20. 17 Blocks, the most amazing and powerful feature ever
  • 21. 18 Lets call JRuby from Java public void callJRuby() { ScriptEngineManager m = new ScriptEngineManager(); ScriptEngine rubyEngine = m.getEngineByName("jruby"); if (rubyEngine==null) throw new RuntimeException("Did not find my ruby engine"); ScriptContext context = rubyEngine.getContext(); context.setAttribute("world","Programmierer",ScriptContext.ENGINE_SCOPE); try{ File f = new File("hello1.rb"); BufferedReader br = new BufferedReader(new FileReader(f)); rubyEngine.eval(br, context); // (1) } catch (ScriptException e) { e.printStackTrace(); } catch (FileNotFoundException fnfe) { System.err.println(fnfe.getMessage()); }}
  • 22. 19 require 'java’ java_import java.lang.System => Java::JavaLang::System version = System.getProperties["java.runtime.version"] => "1.6.0_17-b04-248-10M3025” import java.util.ArrayList list = ArrayList.new => #<Java::JavaUtil::ArrayList:0x2bf09a31> ruby-1.8.7-p334 :042 > iterator = list.iterator => #<#<Class:01x41a7c484>:0x367c218e> ruby-1.8.7-p334 :043 > iterator.java_class => class java.util.AbstractList$Itr ruby-1.8.7-p334 :044 > list.get(1) NativeException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 Lets call Java from Jruby und use your legacy systems
  • 24. 21 Very strong community, why? Got powered by Ruby on Rails (MVC Framework) Fun oriented community Motivated hobby programmers, who can be 9-5 employees ;-) Get into positive cycle of beeing threated well and wanting more ruby GEMS = ruby libraries, created by the community Community
  • 26. 23 Find most popular gems in one place, rated by the community
  • 27. 24 Live Demo: Using a GEM
  • 28. 25 we want to communicate with a REST API should be usable within a build or inside a java class of course Should provide an easy API for our java class The task Easiest solution (a base for it) ?
  • 29. 26 Choose your gem HTTParty Choose HTTParty as the gem for REST communication
  • 31. 28 Write our nice little class
  • 32. 29 Use it immidiatelly on the console to play with it
  • 33. 30 We knew from one site about the best fitting GEM for our task We had no troubles installing it I can try my written code on the console it just works, doesn’t matter what you install its my experience after two years using ruby, yours will be the same Why was this great?
  • 35. 32 Yes its right, Rails got over JSF (java standard) in the meanwhile Is this still a new and not known technology for you? Rails (Ruby) popularity
  • 36. 33 Yes, possible and widely used JRuby on Rails Frontend as war file in Tomcat Rails Front Ends in Java Projects possible everything else is waste of money and developers frustration No risk, tell to your java influenced boss: „its just a war file“  No server infrastructure changes needed Deploy a Ruby on Rails Application in a java war jruby -S gem install -y rails warbler $RAILS_APP_ROOT/jruby -S warble war
  • 37. 34 Java Build with Rake
  • 38. 35 Rake as build tool in Java projects Basic problem: ANT is accepted, Maven the „new standard“ None of them is sufficient for the task we want to do Why?
  • 39. 36 Projectsetup, its in the Wiki, well because Ant cant do it ;-) Folders and File management „if“ – „else“ , can you declare it out of your head now in Ant? Declare a method in your build? Oh, yea no problem let me just look into Ant API Loading of fixtures, possible with some XML setup again Server startup? I am doing it by hand and each new developer has to learn the specifics Maven „the biggest hype“ that helps me even less then Ant Problems with Ant and others…
  • 40. 37 Full language power in your build, not XML We can still call our old Ant tasks UNIX operations as if we would be on the console Method declarations, as simple as possible Reuse of a language we already use not learning new XML frameworks What we want
  • 41. 38 Rake does all you want : project setup methods operating system calls objects in your build file operations Ivy integration Rake is the solution, rubys build tool
  • 42. 39 Rake in 3 mins, nothing is easier!
  • 43. 40 Call classic and custom Ant tasks from rake if needed
  • 44. 41 Operating system communication File management Folder management Talk to your operating system as from the console
  • 45. 42 Some rake possibilities = just full ruby power
  • 46. 43 In/Out API for your project
  • 47. 44 Its difficult to process files as well as different formats in java Import or Export is mostly a focused single task Can be done separated, by one developer No requirement to do it in java Customer data import is a very common and important task Use JRuby to provide an import / export API Data processing much faster Easy CSV, Excel, XML processing Generate projects specific formats for import JRuby as your In/Out API of any project
  • 48. 45 JRuby as your In/Out API of any project
  • 50. 47 Integration tests are the best candidate to do it with JRuby Abstract, mimal input, very high coverage Are easy to keep out of the java environment system Can be perfectly done with pure ruby WEBRAT GEM as JRuby Library Integration Testing
  • 52. 49 GUI Testing API Evaluates the pure HTML output No browser setup or dependency to run your tests Write your tests fast in ruby Cover the complete application workflow with minimal effort Can be run automatically in backgroud while developing Excellent to give fast feedback about application stability Webrat
  • 53. 50 Expected Result from Jruby integration
  • 54. 51 All mentioned task areas can be done easier in JRuby More choices of tools, as would it be only with Java Knowledge reuse in different project areas Work is getting more lightweigt From java IDEs to fast editors Perfect interaction between different parts of the build Expected result
  • 55. 52 My personal, subjective impression You will reach more, having to know less Achieve more with less work using ruby
  • 56. 53 http://www.jruby.org/ http://kenai.com/projects/jruby/pages/Home Jruby console with “jruby –S irb” http://www.cygwin.com/ (Unix Console replacement for Windows) Editors Textmate (MacOs) http://www.e-texteditor.com/ (Windows) IDE’s http://www.jetbrains.com/ruby/ http://www.aptana.com/products/radrails (Eclipse Plugin) http://wiki.netbeans.org/Ruby (Netbeans Ruby Support) Further informations
  • 57. 54 Thanks a lot and have fun with JRuby!