Your SlideShare is downloading. ×
0
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Polyglot Programming in the JVM - 33rd Degree
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Polyglot Programming in the JVM - 33rd Degree

716

Published on

Polyglot Programming in the JVM - 33rd Degree

Polyglot Programming in the JVM - 33rd Degree

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
716
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
12
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Andres  Almiray   @aalmiray  Polyglot Programming in the JVM
  • 2. ABOUT THE SPEAKERJava developer since the beginningTrue believer in Open SourceGroovy committer since 2007Project lead of the Griffon frameworkCurrently working for
  • 3. SOME FACTS ABOUTJAVAPrevious name was Oak. Bonus points for knowing its realname before thatMade its public appearance in 1995C/C++ were king at the timeNetworking, multithreading were baked right into thelanguageDevelopers came for the applets and stayed for thecomponents (JEE and all that jazz)
  • 4. HOWEVER...It‘s already in its teensIt has not seen a groundbreaking feature upgrade since JDK5was released back in 2004 -> generics (and we do know howthat turned out to be, don’t we?)JDK7 was delayed again (late 2010, actual 2011). Somefeatures did not make the cut (lambdas)JDK8, late 2013?
  • 5. MORE SO...It is rather verbose when compared to how other languagesdo the same taskIts threading features are no longer enough. Concurrentprograms 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 argumentssake a basic Twitter clone) in less than a day‘s workWITHOUT an IDE?Did James Gosling ever say he was threatened with bodilyharm should operator overloading find its way into Java?
  • 7. The JVM is a greatplace to work howeverJava makes it painfulsometimes...
  • 8. What can we do about it?!
  • 9. DISCLAIMER(THIS IS NOT A BASH-THE-OTHER-LANGUAGES TALK)
  • 10. REDUCEDVERBOSITY
  • 11. STANDARD BEANSpublic class Bean { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; }}
  • 12. STANDARD BEANSpublic class Bean { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; }}
  • 13. STANDARD BEANSclass Bean { String name}
  • 14. STANDARD BEANSclass Bean(var name:String)class Bean { @scala.reflect.BeanProperty var name: String}
  • 15. STANDARD BEANS(defstruct Bean :name)
  • 16. 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; }}
  • 17. 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
  • 18. CLOSURES (OR FUNCTIONS)def adder = { a , b -> a + b }
  • 19. CLOSURES (OR FUNCTIONS)val adder = (a:Int, b:Int) => a + b
  • 20. CLOSURES (OR FUNCTIONS)(defn adder [a b] (+ a b))
  • 21. ENHANCED SWITCHchar 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(“invalidgrade “+grade);}
  • 22. ENHANCED SWITCHdef 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(‘invalidgrade ‘+grade)}
  • 23. ENHANCED SWITCHval 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) (.toUpperCasegrade)))
  • 25. JAVAINTEROPERABILITY
  • 26. ALL OF THESE ARETRUEJava can call Groovy, Scala and Clojure classes as if theywere Java classesGroovy, Scala and Clojure can call Java code withoutbreaking a sweatIn other words, interoperability with Java is a given. No needfor complicated bridges between languages (i.e. JSR 223)
  • 27. OK, SO...WHAT ELSECAN THESELANGUAGESDO?
  • 28. ALL OF THEMNative syntax for collection classesEverything is an objectClosures!Regular expressions as first class citizen
  • 29. GROOVYMetaprogramming (HOT!) both at buildtime and runtimeBuildersOperator overloadingHealthy ecosystem: Grails, Griffon, Gant, Gradle, Spock,Gaelyk, Gpars, CodeNarc, etc...Not an exhaustive list of features!
  • 30. SCALARicher type systemFunctional meets Object OrientedType inferencePattern matching (+ case classes)Actor modelCreate your own operatorTraitsNot an exhaustive list of features!
  • 31. CLOJUREData as code and viceversaImmutable structuresSTMNot an exhaustive list of features!
  • 32. DEMO
  • 33. OTHER PLACESWHERE YOU‘LLFINDPOLYGLOTPROGRAMMING
  • 34. WEB APPDEVELOPMENTXMLSQLJavaScriptJSONCSSFlash/Flex/ActionScript
  • 35. NEXT-GENDATASTORES (NOSQL)FleetDB -> ClojureFlockDB -> ScalaCouchDB, Riak -> ErlangBy the way, watch out for Polyglot Persistence ;-)
  • 36. BUILD SYSTEMSGradle, Gant -> GroovyRake -> Ruby/JRubyMaven3 -> XML, Groovy, RubySBT -> ScalaLeiningen -> Clojure
  • 37. PARTING THOUGHTSJava (the language) may have reached its maturity featurewiseOther JVM languages have evolved fasterPolyglot Programming is not a new conceptDownload and play with each of the demoed languages,maybe one of them strikes your fancy
  • 38. RESOURCES
  • 39. RESOURCES
  • 40. RESOURCES
  • 41. Q&A
  • 42. Thank You! @aalmirayandres.almiray@canoo.com

×