SlideShare a Scribd company logo
Andres Almiray | Canoo Engineering AG


Polyglot Programming
in the JVM	

 Or how I Learned to Stop Worrying and Love
                   the JVM
About the speaker	

    Java developer since the beginning
    True believer in open source
    Groovy committer since 2007
    Project lead of the Griffon framework
    Currently working for
Some facts about Java	

    Previous name was Oak. Bonus points for
     knowing its real name before that
    Made its public appearance in 1995
    C/C++ were king at the time
    Networking, multithreading were baked
     right into the language
    Developers came for the applets and stayed
     for the components (JEE and all that jazz)
However...	

    It is already in its teens
    It has not seen a major feature upgrade
     since JDK5 was released back in 2004 ->
     generics (and we do know how that turned
     out to be, don’t we?)
    JDK7 has been delayed again (late 2010).
     Some features might or might not make
     the cut (the closures debacle)
More so...	

    It is rather verbose when compared to how
     other languages do the same task
    Its threading features are no longer
     enough. Concurrent programs desperately
     cry for immutability these days
Truth or myth?	

    Is Java oftenly referred as overengineered?
    Can you build a Java based web application
     (for arguments sake a basic Twitter clone)
     in less than a day‘s work WITHOUT an IDE?
    Did James Gosling ever say he was
     threatened with bodily harm should
     operator overloading find its way into Java?
The JVM is a great place to
work however Java makes it
   painful sometimes...
What can we do about it?!
Polyglot Programming @ Jax.de 2010
Disclaimer
                       	

(this is not a bash-the-other-languages talk)
Reduced Verbosity
Standard Beans	

public class Bean {
  private String name;

    public String getName() {
      return name;
    }

    public void setName(String name) {
      this.name = name;
    }
}
Standard Beans	

public class Bean {
  private String name;

    public String getName() {
      return name;
    }

    public void setName(String name) {
      this.name = name;
    }
}
Standard Beans	



class Bean {
  String name
}
Standard Beans	



class Bean(var name:String)


class Bean {
  @scala.reflect.BeanProperty
  var name: String
}
Standard Beans	



(defstruct Bean :name)
Closures (or Functions)	

public interface Adder {
    int add(int a, int b);
}

public class MyAdder implements Adder {
  public int add(int a, int b) {
    return a + b;
    }
}
Closures (or Functions)	



def adder = { a , b -> a + b }
Closures (or Functions)	



def adder(a: Int, b: Int) = a + b
Closures (or Functions)	



(defn adder [a b] (+ a b))
Enhanced switch	

char letterGrade(int grade) {
  if(grade >= 0 && grade <= 60) return ‘F‘;
  if(grade > 60 && grade <= 70) return ‘D‘;
  if(grade > 70 && grade <= 80) return ‘C‘;
  if(grade > 80 && grade <= 90) return ‘B‘;
  if(grade > 90 && grade <= 100) return ‘A‘;
  throw new IllegalArgumentException(‘invalid
grade ‘+grade);
}
Enhanced Switch	

def letterGrade(grade) {
  switch(grade) {
     case 90..100: return ‘A‘
     case 80..<90: return ‘B‘
     case 70..<80: return ‘C‘
     case 60..<70: return ‘D‘
     case 0..<60: return ‘F‘
     case ~"[ABCDFabcdf]":
          return grade.toUpperCase()
  }
  throw new IllegalArgumentException
(‘invalid grade ‘+grade)
}
Enhanced Switch	



val VALID_GRADES = Set("A", "B", "C", "D", "F")
def letterGrade(value: Any):String = value match
{
  case x:Int if (90 to 100).contains(x) => "A"
  case x:Int if (80 to 90).contains(x) => "B"
  case x:Int if (70 to 80).contains(x) => "C"
  case x:Int if (60 to 70).contains(x) => "D"
  case x:Int if (0 to 60).contains(x) => "F"
  case x:String if VALID_GRADES(x.toUpperCase) =>
x.toUpperCase()
}
Enhanced Switch	


(defn letter-grade [grade]
  (cond
   (in grade 90 100) "A"
   (in grade 80 90) "B"
   (in grade 70 80) "C"
   (in grade 60 70) "D"
   (in grade 0 60) "F"
   (re-find #"[ABCDFabcdf]" grade)
(.toUpperCase grade)))
Java Interoperability
All of these are true	

    Java can call Groovy, Scala and Clojure
     classes as if they were Java classes
    Groovy, Scala and Clojure can call Java code
     without breaking a sweat


    In other words, interoperability with Java is
     a given. No need for complicated bridges
     between languages (i.e. JSR 223)
Ok, so...	

What else can these
  languages do?
All of them 	

    Native syntax for collection classes
    Everything is an object
    Closures!
    Regular expressions as first class citizens
    Operator overloading
Groovy	

    Metaprogramming (HOT!) both at buildtime
     and runtime
    Builders
    Healthy ecosystem: Grails, Griffon, Gant,
     Gradle, Spock, Gaelyk, Gpars, CodeNarc,
     etc...


    Not an exhaustive list of features!
Scala	

    Richer type system
    Type inference
    Pattern matching (case classes)
    Actor model




    Not an exhaustive list of features!
Clojure	

    Data as code and viceversa
    Immutable structures
    STM




    Not an exhaustive list of features!
Demo
Other places where you‘ll
find Polyglot Programming
Web app development	

    XML
    SQL
    JavaScript
    JSON
    CSS
    Flash/Flex/ActionScript
Next-Gen datastores (NoSQL)	

    FleetDB -> Clojure


    FlockDB -> Scala


    CouchDB, Riak -> Erlang



    btw watch out for Polyglot Persistence ;-)
Build systems	

    Gradle, Gant -> Groovy


    Rake -> Ruby/JRuby


    Maven3 -> XML, Groovy, Ruby
Parting thoughts	

    Java (the language) may have reached its
     maturity feature wise
    Other JVM languages evolved faster
    Polyglot Programming is not a new concept
    Download and play with each of the
     demoed languages, maybe one of them
     strikes your fancy
Resources

More Related Content

PDF
Polyglot Programming in the JVM - 33rd Degree
PPTX
K is for Kotlin
PDF
Continuations in scala (incomplete version)
PDF
Scala the-good-parts
PDF
BangaloreJUG introduction to kotlin
PDF
Kotlin - Better Java
PDF
Kotlin Types for Java Developers
KEY
Polyglot Grails
Polyglot Programming in the JVM - 33rd Degree
K is for Kotlin
Continuations in scala (incomplete version)
Scala the-good-parts
BangaloreJUG introduction to kotlin
Kotlin - Better Java
Kotlin Types for Java Developers
Polyglot Grails

What's hot (20)

PDF
Kotlin for Android Developers - 1
KEY
Introduction To Grails
PDF
Discovering functional treasure in idiomatic Groovy
PDF
Swift and Kotlin Presentation
PDF
Android antipatterns
PDF
Kotlin, smarter development for the jvm
PDF
Kotlin for Android Developers - 3
PPTX
Scala - the good, the bad and the very ugly
PPTX
Introduction to Koltin for Android Part I
PDF
Kotlin: Challenges in JVM language design
PPTX
Kotlin L → ∞
PPT
Java for the Beginners
PDF
A quick and fast intro to Kotlin
PDF
DSLs in JavaScript
PPTX
Introduction to Kotlin Language and its application to Android platform
PPTX
Java For Automation
PPTX
Kotlin
PDF
Clojure - An Introduction for Java Programmers
ODP
10 Things I Hate About Scala
PPT
Java Intro
Kotlin for Android Developers - 1
Introduction To Grails
Discovering functional treasure in idiomatic Groovy
Swift and Kotlin Presentation
Android antipatterns
Kotlin, smarter development for the jvm
Kotlin for Android Developers - 3
Scala - the good, the bad and the very ugly
Introduction to Koltin for Android Part I
Kotlin: Challenges in JVM language design
Kotlin L → ∞
Java for the Beginners
A quick and fast intro to Kotlin
DSLs in JavaScript
Introduction to Kotlin Language and its application to Android platform
Java For Automation
Kotlin
Clojure - An Introduction for Java Programmers
10 Things I Hate About Scala
Java Intro
Ad

Viewers also liked (8)

PDF
Linda Kelleher's Presentation
PPT
Believe It
PDF
Jfokus - Rocket Propelled Java
PPT
香港六合彩
PPT
Awards presentation 10 28-2010 draft
PDF
The Life of Pie (slides only)
PPT
香港六合彩
PDF
Catch The Riptide
Linda Kelleher's Presentation
Believe It
Jfokus - Rocket Propelled Java
香港六合彩
Awards presentation 10 28-2010 draft
The Life of Pie (slides only)
香港六合彩
Catch The Riptide
Ad

Similar to Polyglot Programming @ Jax.de 2010 (20)

PPT
Polyglot Programming in the JVM
PDF
Polyglot Programming in the JVM - Øredev
PPT
What's New in Groovy 1.6?
PPT
Groovy Update - JavaPolis 2007
PPTX
Clojure And Swing
PPT
2007 09 10 Fzi Training Groovy Grails V Ws
PPT
Svcc Groovy Testing
PDF
Introduction to Oracle Groovy
PDF
Groovy - Grails as a modern scripting language for Web applications
PPT
GTAC Boosting your Testing Productivity with Groovy
PPT
Jet presentation
PDF
Google Interview Questions By Scholarhat
PDF
Oscon Java Testing on the Fast Lane
PPT
Boosting Your Testing Productivity with Groovy
PPT
Javaone2008 Bof 5101 Groovytesting
PPTX
Intro to scala
PDF
A Sceptical Guide to Functional Programming
PDF
Evolving The Java Language
PDF
Polyglot Programming @ CONFESS
PDF
Groovy On Trading Desk (2010)
Polyglot Programming in the JVM
Polyglot Programming in the JVM - Øredev
What's New in Groovy 1.6?
Groovy Update - JavaPolis 2007
Clojure And Swing
2007 09 10 Fzi Training Groovy Grails V Ws
Svcc Groovy Testing
Introduction to Oracle Groovy
Groovy - Grails as a modern scripting language for Web applications
GTAC Boosting your Testing Productivity with Groovy
Jet presentation
Google Interview Questions By Scholarhat
Oscon Java Testing on the Fast Lane
Boosting Your Testing Productivity with Groovy
Javaone2008 Bof 5101 Groovytesting
Intro to scala
A Sceptical Guide to Functional Programming
Evolving The Java Language
Polyglot Programming @ CONFESS
Groovy On Trading Desk (2010)

More from Andres Almiray (20)

PDF
Dealing with JSON in the relational world
PDF
Deploying to production with confidence 🚀
PDF
Going beyond ORMs with JSON Relational Duality Views
PDF
Setting up data driven tests with Java tools
PDF
Creando, creciendo, y manteniendo una comunidad de codigo abierto
PDF
Liberando a produccion con confianza
PDF
Liberando a produccion con confidencia
PDF
OracleDB Ecosystem for Java Developers
PDF
Softcon.ph - Maven Puzzlers
PDF
Maven Puzzlers
PDF
Oracle Database Ecosystem for Java Developers
PDF
JReleaser - Releasing at the speed of light
PDF
Building modular applications with the Java Platform Module System and Layrry
PDF
Going Reactive with g rpc
PDF
Building modular applications with JPMS and Layrry
PDF
Taking Micronaut out for a spin
PDF
Apache Groovy's Metaprogramming Options and You
PDF
What I wish I knew about Maven years ago
PDF
What I wish I knew about maven years ago
PDF
The impact of sci fi in tech
Dealing with JSON in the relational world
Deploying to production with confidence 🚀
Going beyond ORMs with JSON Relational Duality Views
Setting up data driven tests with Java tools
Creando, creciendo, y manteniendo una comunidad de codigo abierto
Liberando a produccion con confianza
Liberando a produccion con confidencia
OracleDB Ecosystem for Java Developers
Softcon.ph - Maven Puzzlers
Maven Puzzlers
Oracle Database Ecosystem for Java Developers
JReleaser - Releasing at the speed of light
Building modular applications with the Java Platform Module System and Layrry
Going Reactive with g rpc
Building modular applications with JPMS and Layrry
Taking Micronaut out for a spin
Apache Groovy's Metaprogramming Options and You
What I wish I knew about Maven years ago
What I wish I knew about maven years ago
The impact of sci fi in tech

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Spectroscopy.pptx food analysis technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
cuic standard and advanced reporting.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
1. Introduction to Computer Programming.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Network Security Unit 5.pdf for BCA BBA.
gpt5_lecture_notes_comprehensive_20250812015547.pdf
MIND Revenue Release Quarter 2 2025 Press Release
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Spectroscopy.pptx food analysis technology
Encapsulation_ Review paper, used for researhc scholars
cuic standard and advanced reporting.pdf
Tartificialntelligence_presentation.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The Rise and Fall of 3GPP – Time for a Sabbatical?
Diabetes mellitus diagnosis method based random forest with bat algorithm
Dropbox Q2 2025 Financial Results & Investor Presentation
Accuracy of neural networks in brain wave diagnosis of schizophrenia
1. Introduction to Computer Programming.pptx
NewMind AI Weekly Chronicles - August'25-Week II
MYSQL Presentation for SQL database connectivity

Polyglot Programming @ Jax.de 2010

  • 1. Andres Almiray | Canoo Engineering AG Polyglot Programming in the JVM Or how I Learned to Stop Worrying and Love the JVM
  • 2. About the speaker   Java developer since the beginning   True believer in open source   Groovy committer since 2007   Project lead of the Griffon framework   Currently working for
  • 3. Some facts about Java   Previous name was Oak. Bonus points for knowing its real name before that   Made its public appearance in 1995   C/C++ were king at the time   Networking, multithreading were baked right into the language   Developers came for the applets and stayed for the components (JEE and all that jazz)
  • 4. However...   It is already in its teens   It has not seen a major feature upgrade since JDK5 was released back in 2004 -> generics (and we do know how that turned out to be, don’t we?)   JDK7 has been delayed again (late 2010). Some features might or might not make the cut (the closures debacle)
  • 5. More so...   It is rather verbose when compared to how other languages do the same task   Its threading features are no longer enough. Concurrent programs desperately cry for immutability these days
  • 6. Truth or myth?   Is Java oftenly referred as overengineered?   Can you build a Java based web application (for arguments sake a basic Twitter clone) in less than a day‘s work WITHOUT an IDE?   Did James Gosling ever say he was threatened with bodily harm should operator overloading find its way into Java?
  • 7. The JVM is a great place to work however Java makes it painful sometimes...
  • 8. What can we do about it?!
  • 10. Disclaimer (this is not a bash-the-other-languages talk)
  • 12. Standard Beans public class Bean { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
  • 13. Standard Beans public class Bean { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
  • 14. Standard Beans class Bean { String name }
  • 15. Standard Beans class Bean(var name:String) class Bean { @scala.reflect.BeanProperty var name: String }
  • 17. Closures (or Functions) public interface Adder { int add(int a, int b); } public class MyAdder implements Adder { public int add(int a, int b) { return a + b; } }
  • 18. Closures (or Functions) def adder = { a , b -> a + b }
  • 19. Closures (or Functions) def adder(a: Int, b: Int) = a + b
  • 20. Closures (or Functions) (defn adder [a b] (+ a b))
  • 21. Enhanced switch char letterGrade(int grade) { if(grade >= 0 && grade <= 60) return ‘F‘; if(grade > 60 && grade <= 70) return ‘D‘; if(grade > 70 && grade <= 80) return ‘C‘; if(grade > 80 && grade <= 90) return ‘B‘; if(grade > 90 && grade <= 100) return ‘A‘; throw new IllegalArgumentException(‘invalid grade ‘+grade); }
  • 22. Enhanced Switch def letterGrade(grade) { switch(grade) { case 90..100: return ‘A‘ case 80..<90: return ‘B‘ case 70..<80: return ‘C‘ case 60..<70: return ‘D‘ case 0..<60: return ‘F‘ case ~"[ABCDFabcdf]": return grade.toUpperCase() } throw new IllegalArgumentException (‘invalid grade ‘+grade) }
  • 23. Enhanced Switch val VALID_GRADES = Set("A", "B", "C", "D", "F") def letterGrade(value: Any):String = value match { case x:Int if (90 to 100).contains(x) => "A" case x:Int if (80 to 90).contains(x) => "B" case x:Int if (70 to 80).contains(x) => "C" case x:Int if (60 to 70).contains(x) => "D" case x:Int if (0 to 60).contains(x) => "F" case x:String if VALID_GRADES(x.toUpperCase) => x.toUpperCase() }
  • 24. Enhanced Switch (defn letter-grade [grade] (cond (in grade 90 100) "A" (in grade 80 90) "B" (in grade 70 80) "C" (in grade 60 70) "D" (in grade 0 60) "F" (re-find #"[ABCDFabcdf]" grade) (.toUpperCase grade)))
  • 26. All of these are true   Java can call Groovy, Scala and Clojure classes as if they were Java classes   Groovy, Scala and Clojure can call Java code without breaking a sweat   In other words, interoperability with Java is a given. No need for complicated bridges between languages (i.e. JSR 223)
  • 27. Ok, so... What else can these languages do?
  • 28. All of them   Native syntax for collection classes   Everything is an object   Closures!   Regular expressions as first class citizens   Operator overloading
  • 29. Groovy   Metaprogramming (HOT!) both at buildtime and runtime   Builders   Healthy ecosystem: Grails, Griffon, Gant, Gradle, Spock, Gaelyk, Gpars, CodeNarc, etc...
   Not an exhaustive list of features!
  • 30. Scala   Richer type system   Type inference   Pattern matching (case classes)   Actor model
   Not an exhaustive list of features!
  • 31. Clojure   Data as code and viceversa   Immutable structures   STM
   Not an exhaustive list of features!
  • 32. Demo
  • 33. Other places where you‘ll find Polyglot Programming
  • 34. Web app development   XML   SQL   JavaScript   JSON   CSS   Flash/Flex/ActionScript
  • 35. Next-Gen datastores (NoSQL)   FleetDB -> Clojure
   FlockDB -> Scala
   CouchDB, Riak -> Erlang   btw watch out for Polyglot Persistence ;-)
  • 36. Build systems   Gradle, Gant -> Groovy
   Rake -> Ruby/JRuby
   Maven3 -> XML, Groovy, Ruby
  • 37. Parting thoughts   Java (the language) may have reached its maturity feature wise   Other JVM languages evolved faster   Polyglot Programming is not a new concept   Download and play with each of the demoed languages, maybe one of them strikes your fancy