SlideShare a Scribd company logo
Java, Ruby & Rails
The Java platform “ It’s all about the Java Virtual Machine. That’s the integration hub.” Gosling, Sun Tech Days 2007 Lots of new languages for the JVM Scala, Clojure, Groovy, Jython, (J)Ruby, JavaScript (Rhino), JavaFX The DaVinci Machine JSR-292 Target JDK 7 invokedynamic instruction
Why Ruby? Ubiquity C-Ruby (MRI) JRuby IronRuby (.NET) Rubinius, Maglev, YARV Scripting java shebang/backticks Rails Framework Support from Sun, Thoughtworks Most likely to succeed?
What is Ruby? Created by Yukihiro Matsumoto (Matz) in 1993 “ A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.”  The principle of least surprise Runtime efficiency not a top priority “ More powerful than Perl, more OO  than Python” MRI is the specification RubySpec is in the works
Ruby Characteristics Interpreted Object oriented ” myString”.upcase 2_500.+2 44.modulo 5 Reflective Garbage collected Duck typing If it walks like a duck and quacks like a duck it must be a duck
Dynamic features Reopen existing classes redefine methods “ monkeypatching” Meta-programming Method aliasing alias_method  :validates_size_of ,  :validates_length_of method_missing Eg provide a generic sort method sort_by_x Closures
Core Ruby tools (j)ruby the interpreter (j)irb interactive ruby, ~readline support, tab completion ri ruby interactive ~man pages rdoc html doc ~javadoc rake ant/make for ruby gem package manager
Ruby anatomy Classes are CamelCased Methods are under_scored Generally no need for curly braces, parentheses, semicolon or return statement code more compact Comments =begin block comment =end # line comment Variables Constant @@classVariable @instanceVariable localVariable :symbol
Example
Ruby structure Modules Module::Class Mix-ins interfaces with functionality Namespace Subclass < Superclass Single inheritance only Files are named *.rb can hold many classes require ’file’ include Module searches $LOAD_PATH
Access modifiers private Private to this instance (might be a subclass) You can’t specify the receiver, not even self protected Can be called by instances of the same class Eg use for comparators  public FFA private :method or private (until end) The modifiers are methods, not keywords
Testing Test::Unit::TestCase xUnit for ruby JRuby to test Java code? JtestR to invoke Code coverage  might be an issue RSpec BDD
Method signature - Java Method overloading Number of method signatures increases fast if flexibility is wanted
Method signature – PL/SQL Named parameters Still have to change method signature too add parameters
Method signature – Ruby Hash as optional parameter, not named parameters No need to change method signature Hash doesn’t need curly braces Method overload unavailable *args => arguments array
More syntax examples =~  regexp matcher myString =~ /[0-9]+/ %w[]  String array myArray = %w[ruby java haskell] {||}   or  do || end  closures  (and embedded variables) myHash.each { |k, v| puts k+’ is ‘+v } myHash.each do |key, val| puts “#{key} is #{val}” end
Ruby on Rails MVC Framework “ Rails is the most well thought-out web development framework I’ve ever used. And that’s in a decade of doing web applications for a living. I’ve built my own frameworks, helped develop the Servlet API, and have created more than a few web servers from scratch. Nobody has done it like this before.” -James Duncan Davidson, Creator of Tomcat and Ant “ Rails is the killer app for Ruby.” Yukihiro Matsumoto, Creator of Ruby
RoR principles Opinionated software Convention over configuration DRY REST GET /products #get all GET /products/42 #get id=42 POST /products #create Fast feedback loop just reload, no compile Rails itself is a gem
Ruby on Rails concepts rails <appname> generates skeleton  routes.rb ~struts-config.xml *.html.erb ~JSP Generators Generates model, view, controller, tests Partials (html.erb snippets) Plugins (instead of gems) Default database is sqlite3 (via JDBC for JRuby) Filters (defined in controller)
RoR tools rails <appname> -d <database> script/generate scaffold Person name:string script/server script/console irb with access to the application script/dbconsole enter SQL script/server –debugger debugger in the code drops to console
ActiveRecord O/R mapping Db migrations, dev, test, prod   up and down database agnostic rake db:migrate config/database.yml Opinionated software primary key named id pluralization class Book => db books
RoR model example class BlogPost < ActiveRecord::Base belongs_to :author has_many :comments validates_presence_of :title end comments table needs blog_post_id blog_posts table needs author_id New post need title field
A/R Metaprogramming
A/R Metaprogramming
ActiveSupport::TestCase Inherits Test::Unit::TestCase Provides helpers, eg http calls <app>/test functional integration unit fixtures/fixtures.yml rake
Jruby Motivation The JVM Sneak into the enterprise Reuse infrastructure Integrate with Java applications Performance and scalability
JRuby on Rails Develop as Java Netbeans Eclipse Integrate with Java Call EJBs Use JMS queues Use JNDI  Use JAAS Deploy on Java As *.war using warbler Rails deployer (JBoss, Glassfish)
Java integration include Java / require ”java” include Java::JavaxSwing include_class &quot;javax.naming.InitialContext” require ”path/to/my.jar” prefix javaclasses to avoid name collisions String => JString include_class 'java.lang.String’  {|package,name| &quot;J#{name}&quot; }  Method alias System.currentTimeMillis => System.current_time_millis Getters and setters behaves like attr_accessor fields
IDE support Eclipse - DLTK (Dynamic Languages Toolkit) Eclipse foundation plugin Support for TCL, Python, Ruby  No Rails Eclipse - Aptana RadRails RDT Ruby Editor Rails support generators/scripts Visual debug Testrunner Netbeans Official plugin
Conclusion Ruby is sweet! Syntactic sugar Fun to work with Ruby is useful! Integrate with Java OO scripting Rails is probably fast enough Ruby is hard! “ Good programmers become better, bad programmers become worse” Test, test, test
Thank you and Namaste
Contact © Devoteam Consulting A/S. This document  is not  to be copied or reproduced in any way without the  express permission of Devoteam Consulting. AUSTRIA BELGIUM CZECH REPUBLIC DENMARK FRANCE MOROCCO NETHERLANDS NORWAY POLAND SAUDI ARABIA SPAIN SWEDEN SWITZERLAND  UNITED ARAB EMIRATES UNITED KINGDOM +46 (0)733-812135 Phone: [email_address] E-mail: Address Peter Sönnergren Person: CONTACT Author:  Date:  # ID:  DOCUMENT

More Related Content

What's hot (19)

Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
Agnieszka Figiel
 
Rjb
RjbRjb
Rjb
Wes Gamble
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
Thomas Lundström
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
Omar Bashir
 
Grand Central Dispatch
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatch
Robert Brown
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
Laxman Puri
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
peter_marklund
 
Java ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many LanguagesJava ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many Languages
elliando dias
 
Java introduction
Java introductionJava introduction
Java introduction
The icfai university jaipur
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)
Esun Kim
 
Security Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSecurity Goodness with Ruby on Rails
Security Goodness with Ruby on Rails
Source Conference
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
Mark Menard
 
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Vert.x - Tehran JUG meeting Aug-2014 - Saeed ZarinfamVert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Saeed Zarinfam
 
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
Bruno Oliveira
 
Dvm
DvmDvm
Dvm
Shivam Sharma
 
JRuby Basics
JRuby BasicsJRuby Basics
JRuby Basics
elliando dias
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRuby
Frederic Jean
 
DataMapper on Infinispan
DataMapper on InfinispanDataMapper on Infinispan
DataMapper on Infinispan
Lance Ball
 
Basics of java
Basics of javaBasics of java
Basics of java
onewomanmore witl
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
Agnieszka Figiel
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
Thomas Lundström
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
Omar Bashir
 
Grand Central Dispatch
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatch
Robert Brown
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
Laxman Puri
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
peter_marklund
 
Java ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many LanguagesJava ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many Languages
elliando dias
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)
Esun Kim
 
Security Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSecurity Goodness with Ruby on Rails
Security Goodness with Ruby on Rails
Source Conference
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
Mark Menard
 
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Vert.x - Tehran JUG meeting Aug-2014 - Saeed ZarinfamVert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Saeed Zarinfam
 
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
Bruno Oliveira
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRuby
Frederic Jean
 
DataMapper on Infinispan
DataMapper on InfinispanDataMapper on Infinispan
DataMapper on Infinispan
Lance Ball
 

Similar to Java, Ruby & Rails (20)

Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
David Keener
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
Ruby on Rails All Hands Meeting
Ruby on Rails All Hands MeetingRuby on Rails All Hands Meeting
Ruby on Rails All Hands Meeting
Dan Davis
 
Resthub lyonjug
Resthub lyonjugResthub lyonjug
Resthub lyonjug
Sébastien Deleuze
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
Gautam Rege
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
Arun Gupta
 
Java 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kolliparaJava 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kollipara
Manjula Kollipara
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
elliando dias
 
Dynamic Languages on the JVM
Dynamic Languages on the JVMDynamic Languages on the JVM
Dynamic Languages on the JVM
elliando dias
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
TAInteractive
 
Ruby on Rails
Ruby on Rails Ruby on Rails
Ruby on Rails
thinkahead.net
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
TAInteractive
 
JRuby and Google App Engine
JRuby and Google App EngineJRuby and Google App Engine
JRuby and Google App Engine
joshsmoore
 
Rollin onj Rubyv3
Rollin onj Rubyv3Rollin onj Rubyv3
Rollin onj Rubyv3
Oracle
 
Jet presentation
Jet presentationJet presentation
Jet presentation
Peter Sellars
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
Nicola Pedot
 
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Udaya Kiran
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
Michael MacDonald
 
It pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_enIt pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_en
George Birbilis
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
Thomas Fuchs
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
Ruby on Rails All Hands Meeting
Ruby on Rails All Hands MeetingRuby on Rails All Hands Meeting
Ruby on Rails All Hands Meeting
Dan Davis
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
Arun Gupta
 
Java 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kolliparaJava 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kollipara
Manjula Kollipara
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
elliando dias
 
Dynamic Languages on the JVM
Dynamic Languages on the JVMDynamic Languages on the JVM
Dynamic Languages on the JVM
elliando dias
 
JRuby and Google App Engine
JRuby and Google App EngineJRuby and Google App Engine
JRuby and Google App Engine
joshsmoore
 
Rollin onj Rubyv3
Rollin onj Rubyv3Rollin onj Rubyv3
Rollin onj Rubyv3
Oracle
 
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Udaya Kiran
 
It pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_enIt pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_en
George Birbilis
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
Thomas Fuchs
 
Ad

Recently uploaded (20)

End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | BluebashMCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
Bluebash
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
FME Beyond Data Processing Creating A Dartboard Accuracy App
FME Beyond Data Processing Creating A Dartboard Accuracy AppFME Beyond Data Processing Creating A Dartboard Accuracy App
FME Beyond Data Processing Creating A Dartboard Accuracy App
Safe Software
 
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptxISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
AyilurRamnath1
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | BluebashMCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
Bluebash
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
FME Beyond Data Processing Creating A Dartboard Accuracy App
FME Beyond Data Processing Creating A Dartboard Accuracy AppFME Beyond Data Processing Creating A Dartboard Accuracy App
FME Beyond Data Processing Creating A Dartboard Accuracy App
Safe Software
 
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptxISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
AyilurRamnath1
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
Ad

Java, Ruby & Rails

  • 1. Java, Ruby & Rails
  • 2. The Java platform “ It’s all about the Java Virtual Machine. That’s the integration hub.” Gosling, Sun Tech Days 2007 Lots of new languages for the JVM Scala, Clojure, Groovy, Jython, (J)Ruby, JavaScript (Rhino), JavaFX The DaVinci Machine JSR-292 Target JDK 7 invokedynamic instruction
  • 3. Why Ruby? Ubiquity C-Ruby (MRI) JRuby IronRuby (.NET) Rubinius, Maglev, YARV Scripting java shebang/backticks Rails Framework Support from Sun, Thoughtworks Most likely to succeed?
  • 4. What is Ruby? Created by Yukihiro Matsumoto (Matz) in 1993 “ A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.” The principle of least surprise Runtime efficiency not a top priority “ More powerful than Perl, more OO than Python” MRI is the specification RubySpec is in the works
  • 5. Ruby Characteristics Interpreted Object oriented ” myString”.upcase 2_500.+2 44.modulo 5 Reflective Garbage collected Duck typing If it walks like a duck and quacks like a duck it must be a duck
  • 6. Dynamic features Reopen existing classes redefine methods “ monkeypatching” Meta-programming Method aliasing alias_method :validates_size_of , :validates_length_of method_missing Eg provide a generic sort method sort_by_x Closures
  • 7. Core Ruby tools (j)ruby the interpreter (j)irb interactive ruby, ~readline support, tab completion ri ruby interactive ~man pages rdoc html doc ~javadoc rake ant/make for ruby gem package manager
  • 8. Ruby anatomy Classes are CamelCased Methods are under_scored Generally no need for curly braces, parentheses, semicolon or return statement code more compact Comments =begin block comment =end # line comment Variables Constant @@classVariable @instanceVariable localVariable :symbol
  • 10. Ruby structure Modules Module::Class Mix-ins interfaces with functionality Namespace Subclass < Superclass Single inheritance only Files are named *.rb can hold many classes require ’file’ include Module searches $LOAD_PATH
  • 11. Access modifiers private Private to this instance (might be a subclass) You can’t specify the receiver, not even self protected Can be called by instances of the same class Eg use for comparators public FFA private :method or private (until end) The modifiers are methods, not keywords
  • 12. Testing Test::Unit::TestCase xUnit for ruby JRuby to test Java code? JtestR to invoke Code coverage might be an issue RSpec BDD
  • 13. Method signature - Java Method overloading Number of method signatures increases fast if flexibility is wanted
  • 14. Method signature – PL/SQL Named parameters Still have to change method signature too add parameters
  • 15. Method signature – Ruby Hash as optional parameter, not named parameters No need to change method signature Hash doesn’t need curly braces Method overload unavailable *args => arguments array
  • 16. More syntax examples =~ regexp matcher myString =~ /[0-9]+/ %w[] String array myArray = %w[ruby java haskell] {||} or do || end closures (and embedded variables) myHash.each { |k, v| puts k+’ is ‘+v } myHash.each do |key, val| puts “#{key} is #{val}” end
  • 17. Ruby on Rails MVC Framework “ Rails is the most well thought-out web development framework I’ve ever used. And that’s in a decade of doing web applications for a living. I’ve built my own frameworks, helped develop the Servlet API, and have created more than a few web servers from scratch. Nobody has done it like this before.” -James Duncan Davidson, Creator of Tomcat and Ant “ Rails is the killer app for Ruby.” Yukihiro Matsumoto, Creator of Ruby
  • 18. RoR principles Opinionated software Convention over configuration DRY REST GET /products #get all GET /products/42 #get id=42 POST /products #create Fast feedback loop just reload, no compile Rails itself is a gem
  • 19. Ruby on Rails concepts rails <appname> generates skeleton routes.rb ~struts-config.xml *.html.erb ~JSP Generators Generates model, view, controller, tests Partials (html.erb snippets) Plugins (instead of gems) Default database is sqlite3 (via JDBC for JRuby) Filters (defined in controller)
  • 20. RoR tools rails <appname> -d <database> script/generate scaffold Person name:string script/server script/console irb with access to the application script/dbconsole enter SQL script/server –debugger debugger in the code drops to console
  • 21. ActiveRecord O/R mapping Db migrations, dev, test, prod up and down database agnostic rake db:migrate config/database.yml Opinionated software primary key named id pluralization class Book => db books
  • 22. RoR model example class BlogPost < ActiveRecord::Base belongs_to :author has_many :comments validates_presence_of :title end comments table needs blog_post_id blog_posts table needs author_id New post need title field
  • 25. ActiveSupport::TestCase Inherits Test::Unit::TestCase Provides helpers, eg http calls <app>/test functional integration unit fixtures/fixtures.yml rake
  • 26. Jruby Motivation The JVM Sneak into the enterprise Reuse infrastructure Integrate with Java applications Performance and scalability
  • 27. JRuby on Rails Develop as Java Netbeans Eclipse Integrate with Java Call EJBs Use JMS queues Use JNDI Use JAAS Deploy on Java As *.war using warbler Rails deployer (JBoss, Glassfish)
  • 28. Java integration include Java / require ”java” include Java::JavaxSwing include_class &quot;javax.naming.InitialContext” require ”path/to/my.jar” prefix javaclasses to avoid name collisions String => JString include_class 'java.lang.String’ {|package,name| &quot;J#{name}&quot; } Method alias System.currentTimeMillis => System.current_time_millis Getters and setters behaves like attr_accessor fields
  • 29. IDE support Eclipse - DLTK (Dynamic Languages Toolkit) Eclipse foundation plugin Support for TCL, Python, Ruby No Rails Eclipse - Aptana RadRails RDT Ruby Editor Rails support generators/scripts Visual debug Testrunner Netbeans Official plugin
  • 30. Conclusion Ruby is sweet! Syntactic sugar Fun to work with Ruby is useful! Integrate with Java OO scripting Rails is probably fast enough Ruby is hard! “ Good programmers become better, bad programmers become worse” Test, test, test
  • 31. Thank you and Namaste
  • 32. Contact © Devoteam Consulting A/S. This document is not to be copied or reproduced in any way without the express permission of Devoteam Consulting. AUSTRIA BELGIUM CZECH REPUBLIC DENMARK FRANCE MOROCCO NETHERLANDS NORWAY POLAND SAUDI ARABIA SPAIN SWEDEN SWITZERLAND UNITED ARAB EMIRATES UNITED KINGDOM +46 (0)733-812135 Phone: [email_address] E-mail: Address Peter Sönnergren Person: CONTACT Author: Date: # ID: DOCUMENT

Editor's Notes