SlideShare uma empresa Scribd logo
1 de 46
Baixar para ler offline
POLYGLOT
PROGRAMMING
IN THE JVM
       Or how I Learned to Stop Worrying and Love the JVM




Andres Almiray | Canoo Engineering AG
@aalmiray
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‘s already in its teens
It has not seen a groundbreaking feature upgrade
since JDK5 was released back in 2004 -> generics
(and we do know how that turned out to be, don’t
we?)
JDK7 was delayed again (late 2010, actual 2011).
Some features did not make the cut (lambdas)
JDK8, late 2013?
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?!
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 interfaceAdder {
    int add(int a, int b);
}


public class  MyAdder implements Adder {
    public int add(int a, int b) {
      return a + b;
    }
}
CLOSURES (OR FUNCTIONS)
// JDK7^H8 Closures proposal

(int a, int b)(a + b)


#(int a, int b) { return a + b; }

(int a, int b) -> a + b
CLOSURES (OR FUNCTIONS)



def adder = { a , b -> a + b }
CLOSURES (OR FUNCTIONS)




val 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 citizen
GROOVY
Metaprogramming (HOT!) both at buildtime and
runtime
Builders
Operator overloading
Healthy ecosystem: Grails, Griffon, Gant, Gradle,
Spock, Gaelyk, Gpars, CodeNarc, etc...

Not an exhaustive list of features!
SCALA
Richer type system
Functional meets Object Oriented
Type inference
Pattern matching (+ case classes)
Actor model
Create your own operator
Traits



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



By the way, watch out for Polyglot Persistence ;-)
BUILD SYSTEMS
Gradle, Gant -> Groovy

Rake -> Ruby/JRuby

Maven3 -> XML, Groovy, Ruby

SBT -> Scala

Leiningen -> Clojure
PARTING THOUGHTS
Java (the language) may have reached its maturity
feature wise
Other JVM languages have 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
RESOURCES
RESOURCES
Q&A
THANK YOU!

Mais conteúdo relacionado

Mais procurados

AST Transformations
AST TransformationsAST Transformations
AST Transformations
HamletDRC
 
Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developers
Bartosz Kosarzycki
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin Presentation
Andrzej Sitek
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
HamletDRC
 

Mais procurados (19)

Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvm
 
Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, Seriously
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
AST Transformations
AST TransformationsAST Transformations
AST Transformations
 
Kotlin hands on - MorningTech ekito 2017
Kotlin hands on - MorningTech ekito 2017Kotlin hands on - MorningTech ekito 2017
Kotlin hands on - MorningTech ekito 2017
 
Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with Kotlin
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projects
 
Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developers
 
Kotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRreadyKotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRready
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin Presentation
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
 
Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demo
 
BangaloreJUG introduction to kotlin
BangaloreJUG   introduction to kotlinBangaloreJUG   introduction to kotlin
BangaloreJUG introduction to kotlin
 
Kotlin cheat sheet by ekito
Kotlin cheat sheet by ekitoKotlin cheat sheet by ekito
Kotlin cheat sheet by ekito
 
Ankara Jug - Practical Functional Programming with Scala
Ankara Jug - Practical Functional Programming with ScalaAnkara Jug - Practical Functional Programming with Scala
Ankara Jug - Practical Functional Programming with Scala
 
Kotlin
KotlinKotlin
Kotlin
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 

Semelhante a Polyglot Programming in the JVM - Øredev

Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010
Andres Almiray
 
Introduction To Groovy
Introduction To GroovyIntroduction To Groovy
Introduction To Groovy
manishkp84
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional Programming
Garth Gilmour
 
Intro to scala
Intro to scalaIntro to scala
Intro to scala
Joe Zulli
 
Polyglot Programming @ CONFESS
Polyglot Programming @ CONFESSPolyglot Programming @ CONFESS
Polyglot Programming @ CONFESS
Andres Almiray
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with Groovy
James Williams
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
jeffz
 
Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6
Ray Ploski
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with Groovy
Andres Almiray
 

Semelhante a Polyglot Programming in the JVM - Øredev (20)

Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010
 
Introduction to Oracle Groovy
Introduction to Oracle GroovyIntroduction to Oracle Groovy
Introduction to Oracle Groovy
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Introduction To Groovy
Introduction To GroovyIntroduction To Groovy
Introduction To Groovy
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional Programming
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages
 
Intro to scala
Intro to scalaIntro to scala
Intro to scala
 
Polyglot Programming @ CONFESS
Polyglot Programming @ CONFESSPolyglot Programming @ CONFESS
Polyglot Programming @ CONFESS
 
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
 
Svcc Groovy Testing
Svcc Groovy TestingSvcc Groovy Testing
Svcc Groovy Testing
 
Groovy!
Groovy!Groovy!
Groovy!
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with Groovy
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 Groovytesting
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescript
 
JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011
 
Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6
 
What's New in Groovy 1.6?
What's New in Groovy 1.6?What's New in Groovy 1.6?
What's New in Groovy 1.6?
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with Groovy
 
Kotlin: maybe it's the right time
Kotlin: maybe it's the right timeKotlin: maybe it's the right time
Kotlin: maybe it's the right time
 

Mais de Andres Almiray

Mais de Andres Almiray (20)

Creando, creciendo, y manteniendo una comunidad de codigo abierto
Creando, creciendo, y manteniendo una comunidad de codigo abiertoCreando, creciendo, y manteniendo una comunidad de codigo abierto
Creando, creciendo, y manteniendo una comunidad de codigo abierto
 
Liberando a produccion con confianza
Liberando a produccion con confianzaLiberando a produccion con confianza
Liberando a produccion con confianza
 
Liberando a produccion con confidencia
Liberando a produccion con confidenciaLiberando a produccion con confidencia
Liberando a produccion con confidencia
 
OracleDB Ecosystem for Java Developers
OracleDB Ecosystem for Java DevelopersOracleDB Ecosystem for Java Developers
OracleDB Ecosystem for Java Developers
 
Softcon.ph - Maven Puzzlers
Softcon.ph - Maven PuzzlersSoftcon.ph - Maven Puzzlers
Softcon.ph - Maven Puzzlers
 
Maven Puzzlers
Maven PuzzlersMaven Puzzlers
Maven Puzzlers
 
Oracle Database Ecosystem for Java Developers
Oracle Database Ecosystem for Java DevelopersOracle Database Ecosystem for Java Developers
Oracle Database Ecosystem for Java Developers
 
JReleaser - Releasing at the speed of light
JReleaser - Releasing at the speed of lightJReleaser - Releasing at the speed of light
JReleaser - Releasing at the speed of light
 
Building modular applications with the Java Platform Module System and Layrry
Building modular applications with the Java Platform Module System and LayrryBuilding modular applications with the Java Platform Module System and Layrry
Building modular applications with the Java Platform Module System and Layrry
 
Going Reactive with g rpc
Going Reactive with g rpcGoing Reactive with g rpc
Going Reactive with g rpc
 
Building modular applications with JPMS and Layrry
Building modular applications with JPMS and LayrryBuilding modular applications with JPMS and Layrry
Building modular applications with JPMS and Layrry
 
Taking Micronaut out for a spin
Taking Micronaut out for a spinTaking Micronaut out for a spin
Taking Micronaut out for a spin
 
Apache Groovy's Metaprogramming Options and You
Apache Groovy's Metaprogramming Options and YouApache Groovy's Metaprogramming Options and You
Apache Groovy's Metaprogramming Options and You
 
What I wish I knew about Maven years ago
What I wish I knew about Maven years agoWhat I wish I knew about Maven years ago
What I wish I knew about Maven years ago
 
What I wish I knew about maven years ago
What I wish I knew about maven years agoWhat I wish I knew about maven years ago
What I wish I knew about maven years ago
 
The impact of sci fi in tech
The impact of sci fi in techThe impact of sci fi in tech
The impact of sci fi in tech
 
Gradle Ex Machina - Devoxx 2019
Gradle Ex Machina - Devoxx 2019Gradle Ex Machina - Devoxx 2019
Gradle Ex Machina - Devoxx 2019
 
Creating Better Builds with Gradle
Creating Better Builds with GradleCreating Better Builds with Gradle
Creating Better Builds with Gradle
 
Interacting with the Oracle Cloud Java SDK with Gradle
Interacting with the Oracle Cloud Java SDK with GradleInteracting with the Oracle Cloud Java SDK with Gradle
Interacting with the Oracle Cloud Java SDK with Gradle
 
Gradle ex-machina
Gradle ex-machinaGradle ex-machina
Gradle ex-machina
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Polyglot Programming in the JVM - Øredev

  • 1. POLYGLOT PROGRAMMING IN THE JVM Or how I Learned to Stop Worrying and Love the JVM Andres Almiray | Canoo Engineering AG @aalmiray
  • 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‘s already in its teens It has not seen a groundbreaking feature upgrade since JDK5 was released back in 2004 -> generics (and we do know how that turned out to be, don’t we?) JDK7 was delayed again (late 2010, actual 2011). Some features did not make the cut (lambdas) JDK8, late 2013?
  • 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?!
  • 9.
  • 10.
  • 11. DISCLAIMER (THIS IS NOT A BASH-THE-OTHER- LANGUAGES TALK)
  • 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 public class Bean { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
  • 15. STANDARD BEANS class Bean { String name }
  • 16. STANDARD BEANS class Bean(var name:String) class Bean { @scala.reflect.BeanProperty var name: String }
  • 18. CLOSURES (OR FUNCTIONS) public interfaceAdder { int add(int a, int b); } public class MyAdder implements Adder { public int add(int a, int b) { return a + b; } }
  • 19. CLOSURES (OR FUNCTIONS) // JDK7^H8 Closures proposal (int a, int b)(a + b) #(int a, int b) { return a + b; } (int a, int b) -> a + b
  • 20. CLOSURES (OR FUNCTIONS) def adder = { a , b -> a + b }
  • 21. CLOSURES (OR FUNCTIONS) val adder = (a:Int, b:Int) => a + b
  • 22. CLOSURES (OR FUNCTIONS) (defn adder [a b] (+ a b))
  • 23. 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); }
  • 24. 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) }
  • 25. 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() }
  • 26. 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)))
  • 28. 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)
  • 29. OK, SO... WHAT ELSE CAN THESE LANGUAGES DO?
  • 30. ALL OF THEM Native syntax for collection classes Everything is an object Closures! Regular expressions as first class citizen
  • 31. GROOVY Metaprogramming (HOT!) both at buildtime and runtime Builders Operator overloading Healthy ecosystem: Grails, Griffon, Gant, Gradle, Spock, Gaelyk, Gpars, CodeNarc, etc... Not an exhaustive list of features!
  • 32. SCALA Richer type system Functional meets Object Oriented Type inference Pattern matching (+ case classes) Actor model Create your own operator Traits Not an exhaustive list of features!
  • 33. CLOJURE Data as code and viceversa Immutable structures STM Not an exhaustive list of features!
  • 34. DEMO
  • 35.
  • 36.
  • 37. OTHER PLACES WHERE YOU‘LL FIND POLYGLOT PROGRAMMING
  • 39. NEXT-GEN DATASTORES (NOSQL) FleetDB -> Clojure FlockDB -> Scala CouchDB, Riak -> Erlang By the way, watch out for Polyglot Persistence ;-)
  • 40. BUILD SYSTEMS Gradle, Gant -> Groovy Rake -> Ruby/JRuby Maven3 -> XML, Groovy, Ruby SBT -> Scala Leiningen -> Clojure
  • 41. PARTING THOUGHTS Java (the language) may have reached its maturity feature wise Other JVM languages have 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
  • 45. Q&A