SlideShare a Scribd company logo
1 of 22
Download to read offline
BLENDING JAVA WITH
DYNAMIC LANGUAGES
speaker.identity {
  name        'Venkat Subramaniam'
  company 'Agile Developer, Inc.'
  credentials 'Programmer', 'Author', 'Trainer'
  blog        'http://agiledeveloper.com/blog'
  email       'venkats@agiledeveloper.com'
}
Abstract
The last several years have brought us some exciting advances in
the capability and strength of the Java platform. At the same
time, developers are increasingly excited about the productivity
gains promised by the use of dynamic languages. The good news
is that it is possible to get the best of both worlds—to take
advantage of dynamic languages and leverage your knowledge of
and investments in the Java Platform at the same time!

In this presentation we will take an in-depth look at mixing
dynamic languages and Java in the same application. We'll first
look at it from the perspective of full interaction, and explore
some idiomatic differences in interaction. Then, from an
application development perspective, we'll discuss how these
can help in areas like Rules Engine, DSLs, and Meta
Programming.
                                                                   2
Java: The Language and the Platform

 Java started out as a powerful, yet simple language

 Through it we realized WORA—Write Once Run Anywhere

 ‘C’ like language with Automatic Garbage Collection

 Powerful set of API and libraries

 Strong community of passionate developers and innovators

 Now we realize, the real strength of Java is not in the language

 It’s in the platform


                                                                    3
Dynamic Languages
Dynamic Languages have been around for a long time

Facilitate ease of metaprogramming, building DSLs, ... leading
to higher productivity

There is renewed interest in this area

Why?

  Machines have gotten faster

  More Availability—community based development

  Awareness of test driven development

  Excitement from killer apps
                                                                 4
Java Languages
Java was once this single language on multiple platforms

.NET was multiple languages on a single platform

Now Java has become a true multiple languages on multiple
platforms

                 Groovy     JavaScript
       JRuby                               Jython

                   Java Bytecode

      Java                                   Jaskell


                                                            5
Multi–Language Means What?


Compiling from higher level languages to bytecode is not new

But, multi–language means full interoperability with
constructs created in different languages

Can you inherit from a class created in another language?

Can you associate or aggregate classes created in another
language?

Can you intermix them without major restrictions?



                                                               6
Why Mix Dynamic Languages?

Dynamic Languages bring power of Metaprogramming and
DSL to the table

Can improve your productivity

You can allow your users to be more expressive

You can use it for Rule Specification in Rule Engines

You can let your program evolve

You can take dynamic decisions based on certain input or
application state


                                                           7
API for Interoperability
Languages to Java API/JDK

  Language specific facilities—different languages handle this
  differently

  For example, here are options in Groovy




                          Source: “Programming Groovy: Dynamic Productivity for the Java Developer”

Java to other languages

   JSR–223 is a standard API for language interoperability

   Useful to call from Java into other languages                                                8
JavaScript to Java
You can use Java API/JDK from within JavaScript




                                                  9
Idiomatic Difference


One of the real fun in mixing languages is enjoying the
idiomatic differences

It is about calling Java API but using syntactic sugar and
facilities of dynamic languages

Reduces code size, gives you productivity




                                                             10
Building Swing App using JavaScript




                                      11
Building Swing App using Groovy




                                  12
Calling JavaScript from Java



Java allows you to call into scripts using JSR–223

ScriptEngineManager allows you to query for and fetch
ScriptEngines

Once you obtain a ScriptEngine, use eval to execute any script




                                                                 13
Calling JavaScript from Java...
package com.agiledeveloper;

import javax.script.*;

public class Script
{

   public static void main(String[] args)

   {

   
    try

   
    {

   
    
    ScriptEngineManager scriptManager = new ScriptEngineManager();

   

   
    
    ScriptEngine engine = scriptManager.getEngineByName(quot;groovyquot;);

   

   
    
    engine.eval(quot;println 'Hello from Groovy'quot;);

   
    }

   
    catch(ScriptException ex)

   
    {

   
    
    System.out.println(quot;Error in scripting: quot; + ex);

   
    }
                                                                               14
Invocable Interface
   Allows you to invoke functions and methods
package com.agiledeveloper;
import javax.script.*;

public class Script {

   public static void main(String[] args) {

   
    try {

   
    
     ScriptEngineManager scriptManager = new ScriptEngineManager();

   

   
    
     ScriptEngine engine = scriptManager.getEngineByName(quot;groovyquot;);

   

   
    
     engine.eval(
       quot;def count(val) { for (i in 1..val) { println i }; return 'Thank you for calling' }quot;);

   
    

   
    
     Invocable invocable = (Invocable) engine;

   
    

   
    
     Object result = invocable.invokeFunction(quot;countquot;, 5);

   
    

   
    
     System.out.println(quot;Result from invocation is quot; + result);

   
    }

   
    catch(Exception ex) ...                                                                15
Compilable Interface



If you’re going to make repeated calls to an interface you can
ask it to be pre-compiled

Provides more efficiency




                                                                 16
Groovy Simplifies this


To call into Groovy from Java you don’t have to use JSR–223
unless you want to use script as is (without compilation)

Groovy provides joint compilation

You can compile Groovy code into Java bytecode and use it
like any other Java code




                                                              17
Using Groovy with Java




                         18
A Small DSL Sample




                     19
A Small DSL Sample




                     20
References

http://groovy.codehaus.org
https://scripting.dev.java.net/
“Programming Groovy: Dynamic Productivity for the
Java Developer,” by Venkat Subramaniam, Pragmatic
Bookshelf, 2008.



      You can download examples and slides from
       http://www.agiledeveloper.com - download
                                                    21
Thank You!
  Please fill in your session evaluations


You can download examples and slides from
 http://www.agiledeveloper.com - download
                                            22

More Related Content

What's hot

Introduction to go lang
Introduction to go langIntroduction to go lang
Introduction to go langAmal Mohan N
 
Think beyond frameworks, The real gems are in the languages
Think beyond frameworks, The real gems are in the languagesThink beyond frameworks, The real gems are in the languages
Think beyond frameworks, The real gems are in the languagesNaresha K
 
Onivim: Modal Editing from the Future
Onivim: Modal Editing from the FutureOnivim: Modal Editing from the Future
Onivim: Modal Editing from the FutureBryan Phelps
 
Livecode widget course
Livecode widget courseLivecode widget course
Livecode widget coursecrazyaxe
 
Buildr - build like you code
Buildr -  build like you codeBuildr -  build like you code
Buildr - build like you codeIzzet Mustafaiev
 
really really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfacesreally really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfacesGiulio De Donato
 
蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈d0nn9n
 
Intro to Crystal Programming Language
Intro to Crystal Programming LanguageIntro to Crystal Programming Language
Intro to Crystal Programming LanguageAdler Hsieh
 
Evolution or stagnation programming languages
Evolution or stagnation programming languagesEvolution or stagnation programming languages
Evolution or stagnation programming languagesDaniele Esposti
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28Jorge Hidalgo
 
Java & JavaScript: Best Friends?
Java & JavaScript: Best Friends?Java & JavaScript: Best Friends?
Java & JavaScript: Best Friends?jbandi
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOULucas Jellema
 
Dev + DevOps для PHP розробника
Dev + DevOps для PHP розробникаDev + DevOps для PHP розробника
Dev + DevOps для PHP розробникаphpfriendsclub
 
Як РНР розробник пише код на Kotlin
Як РНР розробник пише код на KotlinЯк РНР розробник пише код на Kotlin
Як РНР розробник пише код на Kotlinphpfriendsclub
 

What's hot (20)

Scala vs ruby
Scala vs rubyScala vs ruby
Scala vs ruby
 
Introduction to go lang
Introduction to go langIntroduction to go lang
Introduction to go lang
 
Groovy & Java
Groovy & JavaGroovy & Java
Groovy & Java
 
Think beyond frameworks, The real gems are in the languages
Think beyond frameworks, The real gems are in the languagesThink beyond frameworks, The real gems are in the languages
Think beyond frameworks, The real gems are in the languages
 
Onivim: Modal Editing from the Future
Onivim: Modal Editing from the FutureOnivim: Modal Editing from the Future
Onivim: Modal Editing from the Future
 
Livecode widget course
Livecode widget courseLivecode widget course
Livecode widget course
 
Buildr - build like you code
Buildr -  build like you codeBuildr -  build like you code
Buildr - build like you code
 
really really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfacesreally really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfaces
 
蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈
 
Week1 dq3
Week1 dq3Week1 dq3
Week1 dq3
 
Crystal
CrystalCrystal
Crystal
 
Intro to Crystal Programming Language
Intro to Crystal Programming LanguageIntro to Crystal Programming Language
Intro to Crystal Programming Language
 
Go Lang
Go LangGo Lang
Go Lang
 
Gwt Presentation
Gwt PresentationGwt Presentation
Gwt Presentation
 
Evolution or stagnation programming languages
Evolution or stagnation programming languagesEvolution or stagnation programming languages
Evolution or stagnation programming languages
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28
 
Java & JavaScript: Best Friends?
Java & JavaScript: Best Friends?Java & JavaScript: Best Friends?
Java & JavaScript: Best Friends?
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
 
Dev + DevOps для PHP розробника
Dev + DevOps для PHP розробникаDev + DevOps для PHP розробника
Dev + DevOps для PHP розробника
 
Як РНР розробник пише код на Kotlin
Як РНР розробник пише код на KotlinЯк РНР розробник пише код на Kotlin
Як РНР розробник пише код на Kotlin
 

Viewers also liked

電腦作業2
電腦作業2電腦作業2
電腦作業2junia
 
APG Awards: Tate Tracks
APG Awards: Tate TracksAPG Awards: Tate Tracks
APG Awards: Tate TracksMatt Springate
 
Lasse Koskela What Does It Do Does It Work
Lasse Koskela What Does It Do Does It WorkLasse Koskela What Does It Do Does It Work
Lasse Koskela What Does It Do Does It Workdeimos
 
Creating Friend Lists on Facebook
Creating Friend Lists on FacebookCreating Friend Lists on Facebook
Creating Friend Lists on Facebookmdpr
 
Using Oral Recordings for Reflection in English (with video)
Using Oral Recordings for Reflection in English (with video)Using Oral Recordings for Reflection in English (with video)
Using Oral Recordings for Reflection in English (with video)Andrew McCarthy
 
Analytics ebook-sample
Analytics ebook-sampleAnalytics ebook-sample
Analytics ebook-sampleIan Lurie
 
Search and Social Media
Search and Social MediaSearch and Social Media
Search and Social MediaIan Lurie
 
Frank Mantek Google G Data
Frank Mantek Google G DataFrank Mantek Google G Data
Frank Mantek Google G Datadeimos
 
American Independent Writers Going Freelance Workshop Nov 7 2009
American Independent Writers   Going Freelance Workshop Nov 7 2009American Independent Writers   Going Freelance Workshop Nov 7 2009
American Independent Writers Going Freelance Workshop Nov 7 2009Shashi Bellamkonda
 
A Content Creation Strategy for a Busy Nonprofit - Ignite 10NTC
A Content Creation Strategy for a Busy Nonprofit - Ignite 10NTCA Content Creation Strategy for a Busy Nonprofit - Ignite 10NTC
A Content Creation Strategy for a Busy Nonprofit - Ignite 10NTCKivi Leroux Miller
 
Jumping off a plane: The crazy risks of being an entrepreneur
Jumping off a plane: The crazy risks of being an entrepreneurJumping off a plane: The crazy risks of being an entrepreneur
Jumping off a plane: The crazy risks of being an entrepreneurDaniel Tenner
 
Como voce se imagina daqui a 40 anos
Como voce se imagina daqui a 40 anosComo voce se imagina daqui a 40 anos
Como voce se imagina daqui a 40 anosLuca Bastos
 
E Bay Letterwith Public Redacted Verified Complaint
E Bay Letterwith Public Redacted Verified ComplaintE Bay Letterwith Public Redacted Verified Complaint
E Bay Letterwith Public Redacted Verified Complaintalirafat
 

Viewers also liked (20)

電腦作業2
電腦作業2電腦作業2
電腦作業2
 
APG Awards: Tate Tracks
APG Awards: Tate TracksAPG Awards: Tate Tracks
APG Awards: Tate Tracks
 
Lasse Koskela What Does It Do Does It Work
Lasse Koskela What Does It Do Does It WorkLasse Koskela What Does It Do Does It Work
Lasse Koskela What Does It Do Does It Work
 
Creating Friend Lists on Facebook
Creating Friend Lists on FacebookCreating Friend Lists on Facebook
Creating Friend Lists on Facebook
 
database diklat
database diklatdatabase diklat
database diklat
 
Using Oral Recordings for Reflection in English (with video)
Using Oral Recordings for Reflection in English (with video)Using Oral Recordings for Reflection in English (with video)
Using Oral Recordings for Reflection in English (with video)
 
Analytics ebook-sample
Analytics ebook-sampleAnalytics ebook-sample
Analytics ebook-sample
 
Search and Social Media
Search and Social MediaSearch and Social Media
Search and Social Media
 
Frank Mantek Google G Data
Frank Mantek Google G DataFrank Mantek Google G Data
Frank Mantek Google G Data
 
Concediu
ConcediuConcediu
Concediu
 
American Independent Writers Going Freelance Workshop Nov 7 2009
American Independent Writers   Going Freelance Workshop Nov 7 2009American Independent Writers   Going Freelance Workshop Nov 7 2009
American Independent Writers Going Freelance Workshop Nov 7 2009
 
A Content Creation Strategy for a Busy Nonprofit - Ignite 10NTC
A Content Creation Strategy for a Busy Nonprofit - Ignite 10NTCA Content Creation Strategy for a Busy Nonprofit - Ignite 10NTC
A Content Creation Strategy for a Busy Nonprofit - Ignite 10NTC
 
Jumping off a plane: The crazy risks of being an entrepreneur
Jumping off a plane: The crazy risks of being an entrepreneurJumping off a plane: The crazy risks of being an entrepreneur
Jumping off a plane: The crazy risks of being an entrepreneur
 
Clocker and OpenStack
Clocker and OpenStackClocker and OpenStack
Clocker and OpenStack
 
電腦作業
電腦作業電腦作業
電腦作業
 
Test De Memorie
Test De MemorieTest De Memorie
Test De Memorie
 
Como voce se imagina daqui a 40 anos
Como voce se imagina daqui a 40 anosComo voce se imagina daqui a 40 anos
Como voce se imagina daqui a 40 anos
 
E Bay Letterwith Public Redacted Verified Complaint
E Bay Letterwith Public Redacted Verified ComplaintE Bay Letterwith Public Redacted Verified Complaint
E Bay Letterwith Public Redacted Verified Complaint
 
Seminariotecnologia2010
Seminariotecnologia2010Seminariotecnologia2010
Seminariotecnologia2010
 
50 Great Golf Holes
50 Great Golf Holes50 Great Golf Holes
50 Great Golf Holes
 

Similar to Blending Java with Dynamic Languages

Gr8Conf US 2017 - From Java to Groovy: Adventure Time!
Gr8Conf US 2017 - From Java to Groovy: Adventure Time!Gr8Conf US 2017 - From Java to Groovy: Adventure Time!
Gr8Conf US 2017 - From Java to Groovy: Adventure Time!Iván López Martín
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!Iván López Martín
 
Step by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For BeginnersStep by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For Beginnerscalltutors
 
Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdfAdiseshaK
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finessemzgubin
 
Java Course in Gurgaon: Your Gateway to Mastering Java Programming
Java Course in Gurgaon: Your Gateway to Mastering Java ProgrammingJava Course in Gurgaon: Your Gateway to Mastering Java Programming
Java Course in Gurgaon: Your Gateway to Mastering Java ProgrammingUncodemy
 
JRuby in Java Projects
JRuby in Java ProjectsJRuby in Java Projects
JRuby in Java Projectsjazzman1980
 
Java presentation
Java presentationJava presentation
Java presentationsurajdmk
 
Java presentation
Java presentationJava presentation
Java presentationsurajdmk
 
Training on Core java | PPT Presentation | Shravan Sanidhya
Training on Core java | PPT Presentation | Shravan SanidhyaTraining on Core java | PPT Presentation | Shravan Sanidhya
Training on Core java | PPT Presentation | Shravan SanidhyaShravan Sanidhya
 
Features of java unit 1
Features of java unit 1Features of java unit 1
Features of java unit 1RubaNagarajan
 
GWT Introduction for Eclipse Day
GWT Introduction for Eclipse Day GWT Introduction for Eclipse Day
GWT Introduction for Eclipse Day DNG Consulting
 
Dynamic Languages on the JVM
Dynamic Languages on the JVMDynamic Languages on the JVM
Dynamic Languages on the JVMelliando dias
 
Presentación rs232 java
Presentación rs232 javaPresentación rs232 java
Presentación rs232 javaJohn Rojas
 

Similar to Blending Java with Dynamic Languages (20)

Gr8Conf US 2017 - From Java to Groovy: Adventure Time!
Gr8Conf US 2017 - From Java to Groovy: Adventure Time!Gr8Conf US 2017 - From Java to Groovy: Adventure Time!
Gr8Conf US 2017 - From Java to Groovy: Adventure Time!
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!
 
Step by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For BeginnersStep by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For Beginners
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdf
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
 
Java Course in Gurgaon: Your Gateway to Mastering Java Programming
Java Course in Gurgaon: Your Gateway to Mastering Java ProgrammingJava Course in Gurgaon: Your Gateway to Mastering Java Programming
Java Course in Gurgaon: Your Gateway to Mastering Java Programming
 
130700548484460000
130700548484460000130700548484460000
130700548484460000
 
Ch2
Ch2Ch2
Ch2
 
JRuby in Java Projects
JRuby in Java ProjectsJRuby in Java Projects
JRuby in Java Projects
 
Java Intro
Java IntroJava Intro
Java Intro
 
Java presentation
Java presentationJava presentation
Java presentation
 
Core java slides
Core java slidesCore java slides
Core java slides
 
Java presentation
Java presentationJava presentation
Java presentation
 
Java presentation
Java presentationJava presentation
Java presentation
 
Training on Core java | PPT Presentation | Shravan Sanidhya
Training on Core java | PPT Presentation | Shravan SanidhyaTraining on Core java | PPT Presentation | Shravan Sanidhya
Training on Core java | PPT Presentation | Shravan Sanidhya
 
Features of java unit 1
Features of java unit 1Features of java unit 1
Features of java unit 1
 
GWT Introduction for Eclipse Day
GWT Introduction for Eclipse Day GWT Introduction for Eclipse Day
GWT Introduction for Eclipse Day
 
Dynamic Languages on the JVM
Dynamic Languages on the JVMDynamic Languages on the JVM
Dynamic Languages on the JVM
 
Presentación rs232 java
Presentación rs232 javaPresentación rs232 java
Presentación rs232 java
 

More from deimos

Aspect Orientated Programming in Ruby
Aspect Orientated Programming in RubyAspect Orientated Programming in Ruby
Aspect Orientated Programming in Rubydeimos
 
Randy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural PrinciplesRandy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural Principlesdeimos
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuerydeimos
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvmdeimos
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwrdeimos
 
Aslak Hellesoy Executable User Stories R Spec Bdd
Aslak Hellesoy Executable User Stories R Spec BddAslak Hellesoy Executable User Stories R Spec Bdd
Aslak Hellesoy Executable User Stories R Spec Bdddeimos
 
Udi Dahan Intentions And Interfaces
Udi Dahan Intentions And InterfacesUdi Dahan Intentions And Interfaces
Udi Dahan Intentions And Interfacesdeimos
 
Tim Mackinnon Agile And Beyond
Tim Mackinnon Agile And BeyondTim Mackinnon Agile And Beyond
Tim Mackinnon Agile And Beyonddeimos
 
Steve Vinoski Rest And Reuse And Serendipity
Steve Vinoski Rest And Reuse And SerendipitySteve Vinoski Rest And Reuse And Serendipity
Steve Vinoski Rest And Reuse And Serendipitydeimos
 
Stefan Tilkov Soa Rest And The Web
Stefan Tilkov Soa Rest And The WebStefan Tilkov Soa Rest And The Web
Stefan Tilkov Soa Rest And The Webdeimos
 
Stefan Tilkov Pragmatic Intro To Rest
Stefan Tilkov Pragmatic Intro To RestStefan Tilkov Pragmatic Intro To Rest
Stefan Tilkov Pragmatic Intro To Restdeimos
 
Rod Johnson Cathedral
Rod Johnson CathedralRod Johnson Cathedral
Rod Johnson Cathedraldeimos
 
Mike Stolz Dramatic Scalability
Mike Stolz Dramatic ScalabilityMike Stolz Dramatic Scalability
Mike Stolz Dramatic Scalabilitydeimos
 
Matt Youill Betfair
Matt Youill BetfairMatt Youill Betfair
Matt Youill Betfairdeimos
 
Pete Goodliffe A Tale Of Two Systems
Pete Goodliffe A Tale Of Two SystemsPete Goodliffe A Tale Of Two Systems
Pete Goodliffe A Tale Of Two Systemsdeimos
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registrydeimos
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platformdeimos
 
Neal Gafter Java Evolution
Neal Gafter Java EvolutionNeal Gafter Java Evolution
Neal Gafter Java Evolutiondeimos
 
Markus Voelter Textual DSLs
Markus Voelter Textual DSLsMarkus Voelter Textual DSLs
Markus Voelter Textual DSLsdeimos
 
Marc Evers People Vs Process Beyond Agile
Marc Evers People Vs Process Beyond AgileMarc Evers People Vs Process Beyond Agile
Marc Evers People Vs Process Beyond Agiledeimos
 

More from deimos (20)

Aspect Orientated Programming in Ruby
Aspect Orientated Programming in RubyAspect Orientated Programming in Ruby
Aspect Orientated Programming in Ruby
 
Randy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural PrinciplesRandy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural Principles
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuery
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwr
 
Aslak Hellesoy Executable User Stories R Spec Bdd
Aslak Hellesoy Executable User Stories R Spec BddAslak Hellesoy Executable User Stories R Spec Bdd
Aslak Hellesoy Executable User Stories R Spec Bdd
 
Udi Dahan Intentions And Interfaces
Udi Dahan Intentions And InterfacesUdi Dahan Intentions And Interfaces
Udi Dahan Intentions And Interfaces
 
Tim Mackinnon Agile And Beyond
Tim Mackinnon Agile And BeyondTim Mackinnon Agile And Beyond
Tim Mackinnon Agile And Beyond
 
Steve Vinoski Rest And Reuse And Serendipity
Steve Vinoski Rest And Reuse And SerendipitySteve Vinoski Rest And Reuse And Serendipity
Steve Vinoski Rest And Reuse And Serendipity
 
Stefan Tilkov Soa Rest And The Web
Stefan Tilkov Soa Rest And The WebStefan Tilkov Soa Rest And The Web
Stefan Tilkov Soa Rest And The Web
 
Stefan Tilkov Pragmatic Intro To Rest
Stefan Tilkov Pragmatic Intro To RestStefan Tilkov Pragmatic Intro To Rest
Stefan Tilkov Pragmatic Intro To Rest
 
Rod Johnson Cathedral
Rod Johnson CathedralRod Johnson Cathedral
Rod Johnson Cathedral
 
Mike Stolz Dramatic Scalability
Mike Stolz Dramatic ScalabilityMike Stolz Dramatic Scalability
Mike Stolz Dramatic Scalability
 
Matt Youill Betfair
Matt Youill BetfairMatt Youill Betfair
Matt Youill Betfair
 
Pete Goodliffe A Tale Of Two Systems
Pete Goodliffe A Tale Of Two SystemsPete Goodliffe A Tale Of Two Systems
Pete Goodliffe A Tale Of Two Systems
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registry
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platform
 
Neal Gafter Java Evolution
Neal Gafter Java EvolutionNeal Gafter Java Evolution
Neal Gafter Java Evolution
 
Markus Voelter Textual DSLs
Markus Voelter Textual DSLsMarkus Voelter Textual DSLs
Markus Voelter Textual DSLs
 
Marc Evers People Vs Process Beyond Agile
Marc Evers People Vs Process Beyond AgileMarc Evers People Vs Process Beyond Agile
Marc Evers People Vs Process Beyond Agile
 

Recently uploaded

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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
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
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
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
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Recently uploaded (20)

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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
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
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
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)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
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
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

Blending Java with Dynamic Languages

  • 1. BLENDING JAVA WITH DYNAMIC LANGUAGES speaker.identity { name 'Venkat Subramaniam' company 'Agile Developer, Inc.' credentials 'Programmer', 'Author', 'Trainer' blog 'http://agiledeveloper.com/blog' email 'venkats@agiledeveloper.com' }
  • 2. Abstract The last several years have brought us some exciting advances in the capability and strength of the Java platform. At the same time, developers are increasingly excited about the productivity gains promised by the use of dynamic languages. The good news is that it is possible to get the best of both worlds—to take advantage of dynamic languages and leverage your knowledge of and investments in the Java Platform at the same time! In this presentation we will take an in-depth look at mixing dynamic languages and Java in the same application. We'll first look at it from the perspective of full interaction, and explore some idiomatic differences in interaction. Then, from an application development perspective, we'll discuss how these can help in areas like Rules Engine, DSLs, and Meta Programming. 2
  • 3. Java: The Language and the Platform Java started out as a powerful, yet simple language Through it we realized WORA—Write Once Run Anywhere ‘C’ like language with Automatic Garbage Collection Powerful set of API and libraries Strong community of passionate developers and innovators Now we realize, the real strength of Java is not in the language It’s in the platform 3
  • 4. Dynamic Languages Dynamic Languages have been around for a long time Facilitate ease of metaprogramming, building DSLs, ... leading to higher productivity There is renewed interest in this area Why? Machines have gotten faster More Availability—community based development Awareness of test driven development Excitement from killer apps 4
  • 5. Java Languages Java was once this single language on multiple platforms .NET was multiple languages on a single platform Now Java has become a true multiple languages on multiple platforms Groovy JavaScript JRuby Jython Java Bytecode Java Jaskell 5
  • 6. Multi–Language Means What? Compiling from higher level languages to bytecode is not new But, multi–language means full interoperability with constructs created in different languages Can you inherit from a class created in another language? Can you associate or aggregate classes created in another language? Can you intermix them without major restrictions? 6
  • 7. Why Mix Dynamic Languages? Dynamic Languages bring power of Metaprogramming and DSL to the table Can improve your productivity You can allow your users to be more expressive You can use it for Rule Specification in Rule Engines You can let your program evolve You can take dynamic decisions based on certain input or application state 7
  • 8. API for Interoperability Languages to Java API/JDK Language specific facilities—different languages handle this differently For example, here are options in Groovy Source: “Programming Groovy: Dynamic Productivity for the Java Developer” Java to other languages JSR–223 is a standard API for language interoperability Useful to call from Java into other languages 8
  • 9. JavaScript to Java You can use Java API/JDK from within JavaScript 9
  • 10. Idiomatic Difference One of the real fun in mixing languages is enjoying the idiomatic differences It is about calling Java API but using syntactic sugar and facilities of dynamic languages Reduces code size, gives you productivity 10
  • 11. Building Swing App using JavaScript 11
  • 12. Building Swing App using Groovy 12
  • 13. Calling JavaScript from Java Java allows you to call into scripts using JSR–223 ScriptEngineManager allows you to query for and fetch ScriptEngines Once you obtain a ScriptEngine, use eval to execute any script 13
  • 14. Calling JavaScript from Java... package com.agiledeveloper; import javax.script.*; public class Script { public static void main(String[] args) { try { ScriptEngineManager scriptManager = new ScriptEngineManager(); ScriptEngine engine = scriptManager.getEngineByName(quot;groovyquot;); engine.eval(quot;println 'Hello from Groovy'quot;); } catch(ScriptException ex) { System.out.println(quot;Error in scripting: quot; + ex); } 14
  • 15. Invocable Interface Allows you to invoke functions and methods package com.agiledeveloper; import javax.script.*; public class Script { public static void main(String[] args) { try { ScriptEngineManager scriptManager = new ScriptEngineManager(); ScriptEngine engine = scriptManager.getEngineByName(quot;groovyquot;); engine.eval( quot;def count(val) { for (i in 1..val) { println i }; return 'Thank you for calling' }quot;); Invocable invocable = (Invocable) engine; Object result = invocable.invokeFunction(quot;countquot;, 5); System.out.println(quot;Result from invocation is quot; + result); } catch(Exception ex) ... 15
  • 16. Compilable Interface If you’re going to make repeated calls to an interface you can ask it to be pre-compiled Provides more efficiency 16
  • 17. Groovy Simplifies this To call into Groovy from Java you don’t have to use JSR–223 unless you want to use script as is (without compilation) Groovy provides joint compilation You can compile Groovy code into Java bytecode and use it like any other Java code 17
  • 19. A Small DSL Sample 19
  • 20. A Small DSL Sample 20
  • 21. References http://groovy.codehaus.org https://scripting.dev.java.net/ “Programming Groovy: Dynamic Productivity for the Java Developer,” by Venkat Subramaniam, Pragmatic Bookshelf, 2008. You can download examples and slides from http://www.agiledeveloper.com - download 21
  • 22. Thank You! Please fill in your session evaluations You can download examples and slides from http://www.agiledeveloper.com - download 22