SlideShare a Scribd company logo
Polyglot Grails
Me
• @mgryszko
• @osoco
• Groovy/Grails
  (sometimes Java)
  hacker

• test addicted and
  clean code lover
Osoco
•   Small but outstanding   •   Quality preachers
    software development
    shop                    •   TDD mantra singers

•   Groovy and Grails       •   On EC2 cloud nine
    hackers
Osoco
•   Small but outstanding   •   Quality preachers
    software development
    shop                    •   TDD mantra singers

•   Groovy and Grails       •   On EC2 cloud nine
    hackers




       Julián                            David
Polyglot
Polyglot programming

•   term coined 2006 by Neil Ford

•   general + special-purpose languages

•   http://memeagora.blogspot.com/2006/12/polyglot-
    programming.html
http://www.flickr.com/photos/pinelife/269961241/
Maybe you didn’t know...




                   http://www.flickr.com/photos/pinelife/269961241/
Maybe you didn’t know...
But you are already polyglot programmer!




                           http://www.flickr.com/photos/pinelife/269961241/
From relational algebra
       to JVM

• relational algebra, rise of RDBMS -> SQL
• world-wide-web -> JavaScript, HTML (?)
• multilanguage platforms - .NET, JVM
> 200 languages on JVM
> 200 languages on JVM
> 200 languages on JVM
Why polyglot?
• General purpose languages evolve too
  slowly
• Specific-languages solve specific problems
  (DSLs included)
• New challenges
• Old habits die hard
Do we have to speak
Groovy with Grails?
Do we have to speak
 Groovy with Grails?
• Yes...
• Groovy and Grails are inseparable
Do we have to speak
 Groovy with Grails?
• Yes...
• Groovy and Grails are inseparable
• But...
• Non-Groovy code can be executed from
  Grails components
Grails is already
polyglot, can we push it
        further?
Grails plugins

       • Clojure

       • Scala

       • JRuby
Grails plugins

       • Clojure

       • Scala

       • JRuby
Clojure

• Functional language
• Lisp reloaded
• Built-in support for concurrency
• Java interoperability
Clojure

• Functional language
• Lisp reloaded
• Built-in support for concurrency
• Java interoperability
Functional language

• Not pure functional
• Explicit state management
• Immutable, lazy and infinite data structures
• Higher-order functions
• Dynamically typed*
Functional language

• Not pure functional
• Explicit state management
• Immutable, lazy and infinite data structures
• Higher-order functions
• Dynamically typed*
Lisp reloaded
• Everything is sequence (extended Lisp list)
• Extended data structures - maps, sets
• Less parentheses, commas = whitespaces
• Multimethods dispatch on anything
• Metadata
• Tail call optimization on JVM
Lisp reloaded
• Everything is sequence (extended Lisp list)
• Extended data structures - maps, sets
• Less parentheses, commas = whitespaces
• Multimethods dispatch on anything
• Metadata
• Tail call optimization on JVM
Concurrency
• Managed references (refs, agents, atoms,
  vars)
• Software Transactional Memory
• Actors
• Atoms (~  java.util.concurrent.atomic.Atomic*   )
• Vars (~                  )
          java.lang.ThreadLocal
Concurrency
• Managed references (refs, agents, atoms,
  vars)
• Software Transactional Memory
• Actors
• Atoms (~  java.util.concurrent.atomic.Atomic*   )
• Vars (~                  )
          java.lang.ThreadLocal
Java interoperability
• Import Java classes
• Direct access to class/instance fields and
  methods
• Syntactic sugar
• Implement Java interfaces and classes on
  the fly
• Create Java classes
Java interoperability
• Import Java classes
• Direct access to class/instance fields and
  methods
• Syntactic sugar
• Implement Java interfaces and classes on
  the fly
• Create Java classes
Why Clojure & Grails?

• Concurrency
• Laziness
• Rich collection library
 • Relational algebra
Why Clojure & Grails?

• Concurrency
• Laziness
• Rich collection library
 • Relational algebra
Clojure and Grails
• Install Clojure plugin
  http://grails.org/plugin/clojure
  grails install-plugin clojure

• Put your sources under src/clj
• Use grails namespace
  (ns grails)

• Access Clojure code through clj property
Clojure and Grails
• Install Clojure plugin
  http://grails.org/plugin/clojure
  grails install-plugin clojure

• Put your sources under src/clj
• Use grails namespace
  (ns grails)

• Access Clojure code through clj property
Demo - bootstrap


• Clojure code can access Grails objects
• Sample note added during bootstrap
Demo - bootstrap


• Clojure code can access Grails objects
• Sample note added during bootstrap
Demo - tag counter

• Note taking application
• Notes can be tagged
• Calculate most popular tags
Demo - tag counter

• Note taking application
• Notes can be tagged
• Calculate most popular tags
Plugin gotchas


• Uses Clojure 1.2
• No access to Groovy-augmented methods
  e.g. String.reverse()
Plugin gotchas


• Uses Clojure 1.2
• No access to Groovy-augmented methods
  e.g. String.reverse()
Scala

• Object-functional
• Statically typed but with type inference
• Concurrency through actors
• Almost as fast as Java
Scala

• Object-functional
• Statically typed but with type inference
• Concurrency through actors
• Almost as fast as Java
Functional language
• Immutability
• Higher-order functions
• Pattern matching + case classes
• Lazy evaluation
• Monads
• Parser combinators
Functional language
• Immutability
• Higher-order functions
• Pattern matching + case classes
• Lazy evaluation
• Monads
• Parser combinators
Why Scala in Grails?

• High performance without Java
• Functional features
• DSLs
Why Scala in Grails?

• High performance without Java
• Functional features
• DSLs
Scala and Grails

• Install Scala plugin
  http://www.grails.org/plugin/scala
  grails install-plugin scala

• Put your source under src/scala
• Add explicit Scala dependencies
  compile "org.scala-lang:scala-compiler:2.9.1",
          "org.scala-lang:scala-library:2.9.1"
Scala and Grails

• Install Scala plugin
  http://www.grails.org/plugin/scala
  grails install-plugin scala

• Put your source under src/scala
• Add explicit Scala dependencies
  compile "org.scala-lang:scala-compiler:2.9.1",
          "org.scala-lang:scala-library:2.9.1"
Demo
            shortest path

•   Calculate shortest path
    between two cities

•   Use Scala4Graph library
Demo
            shortest path

•   Calculate shortest path
    between two cities

•   Use Scala4Graph library
Plugin gotchas

• No access to Groovy/Grails classes
• Execute Grails with --verbose option for
  Scala compiler error
• No IDE support for executing Scala code
  tests
Plugin gotchas

• No access to Groovy/Grails classes
• Execute Grails with --verbose option for
  Scala compiler error
• No IDE support for executing Scala code
  tests
Plugin gotchas

• DSL objects must be 100% Scala
• Boilerplate code for accessing Scala results
  scalaList.foreach(
    [apply: {groovyList << it}] as Function1
  )


• Scala components can be Spring beans
Plugin gotchas

• DSL objects must be 100% Scala
• Boilerplate code for accessing Scala results
  scalaList.foreach(
    [apply: {groovyList << it}] as Function1
  )


• Scala components can be Spring beans
Ruby

• JRuby - Ruby 1.8.7 & 1.9.2 compatible
• Object-oriented, dynamic
• Some functional features
• Tones of gems
Ruby

• JRuby - Ruby 1.8.7 & 1.9.2 compatible
• Object-oriented, dynamic
• Some functional features
• Tones of gems
Why Ruby in Grails?

• Hard to find a valid reason...
• Rails app migration to Grails?
• Particular gem?
Why Ruby in Grails?

• Hard to find a valid reason...
• Rails app migration to Grails?
• Particular gem?
Ruby and Grails

• Install Ruby plugin
  http://www.grails.org/plugin/ruby
  grails install-plugin ruby

• Put your sources under src/ruby
• Access Ruby code through ruby property
Ruby and Grails

• Install Ruby plugin
  http://www.grails.org/plugin/ruby
  grails install-plugin ruby

• Put your sources under src/ruby
• Access Ruby code through ruby property
Demo - BOFH server


• http://en.wikipedia.org/wiki/
  Bastard_Operator_From_Hell
• bofh-excuse gem
Demo - BOFH server


• http://en.wikipedia.org/wiki/
  Bastard_Operator_From_Hell
• bofh-excuse gem
Plugin gotchas


• No gem installation
• No access to Grails classes
Plugin gotchas


• No gem installation
• No access to Grails classes
Speak your mother
         tongue
• plug in your compiler on compileStart
  event (Scala plugin)
• use JSR223 javax.script.ScriptEngine
  (Ruby plugin)
• use custom interpreter (Clojure plugin,
  clojure.lang.Compiler)

• trigger code reloading when changed
My ranking

    for
My ranking

    for
My ranking

    for
My ranking

    for
Thank you!
 ¡Gracias!
  Danke!
 Dziękuję!
Source code


• http://github.com/mgryszko/grails-polyglot-demo

More Related Content

PDF
Polyglot JVM
PPT
Polyglot Programming in the JVM
PDF
Functional Programming with Groovy
PPT
Groovy presentation
PDF
awesome groovy
PDF
groovy rules
PDF
Swift and Kotlin Presentation
PDF
Designing with Groovy Traits - Gr8Conf India
Polyglot JVM
Polyglot Programming in the JVM
Functional Programming with Groovy
Groovy presentation
awesome groovy
groovy rules
Swift and Kotlin Presentation
Designing with Groovy Traits - Gr8Conf India

What's hot (20)

PPT
Introduction To Groovy
PDF
functional groovy
PDF
Atlassian Groovy Plugins
PDF
[Start] Scala
KEY
Scala Introduction
PDF
Kotlin for Android Developers - 3
PDF
Kotlin @ Coupang Backend 2017
PDF
Scala in Practice
PDF
Ruby Performance - The Last Mile - RubyConf India 2016
PPTX
Introduction to kotlin + spring boot demo
PDF
Down the Rabbit Hole: An Adventure in JVM Wonderland
PDF
Taking Kotlin to production, Seriously
PDF
Scala : language of the future
PDF
Make Testing Groovy
PDF
JRuby and Invokedynamic - Japan JUG 2015
PDF
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
PDF
Building microservices with Kotlin
PDF
Flutter 是什麼?用 Flutter 會省到時間嗎? @ GDG Devfest2020
PPTX
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
KEY
JavaOne 2011 - JVM Bytecode for Dummies
Introduction To Groovy
functional groovy
Atlassian Groovy Plugins
[Start] Scala
Scala Introduction
Kotlin for Android Developers - 3
Kotlin @ Coupang Backend 2017
Scala in Practice
Ruby Performance - The Last Mile - RubyConf India 2016
Introduction to kotlin + spring boot demo
Down the Rabbit Hole: An Adventure in JVM Wonderland
Taking Kotlin to production, Seriously
Scala : language of the future
Make Testing Groovy
JRuby and Invokedynamic - Japan JUG 2015
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
Building microservices with Kotlin
Flutter 是什麼?用 Flutter 會省到時間嗎? @ GDG Devfest2020
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
JavaOne 2011 - JVM Bytecode for Dummies
Ad

Viewers also liked (10)

PDF
Spring Annotations: Proxy
PDF
Proactive monitoring with Monit
PDF
AWS CloudFormation en 5 Minutos
PDF
Understanding Java Dynamic Proxies
PDF
SSH Tunneling Recipes
PDF
MADBike – Destapando la seguridad de BiciMAD (T3chFest 2017)
PDF
Gigigo Keynote - Geofences & iBeacons
PDF
NSCoder Keynote - Multipeer Connectivity Framework
PDF
Gigigo Workshop - Create an iOS Framework, document it and not die trying
PDF
Gigigo Workshop - iOS Extensions
Spring Annotations: Proxy
Proactive monitoring with Monit
AWS CloudFormation en 5 Minutos
Understanding Java Dynamic Proxies
SSH Tunneling Recipes
MADBike – Destapando la seguridad de BiciMAD (T3chFest 2017)
Gigigo Keynote - Geofences & iBeacons
NSCoder Keynote - Multipeer Connectivity Framework
Gigigo Workshop - Create an iOS Framework, document it and not die trying
Gigigo Workshop - iOS Extensions
Ad

Similar to Polyglot Grails (20)

PDF
Polyglot Plugin Programming
PDF
Java Edge.2009.Grails.Web.Dev.Made.Easy
PDF
PHP, the GraphQL ecosystem and GraphQLite
PPTX
Scaling with swagger
PDF
遇見 Ruby on Rails
PDF
Clojurescript slides
PDF
Scala Native: Ahead of Time
KEY
Polyglot and Functional Programming (OSCON 2012)
PDF
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
PDF
Better Framework Better Life
PDF
Go - A Key Language in Enterprise Application Development?
KEY
Introduction to JRuby
PDF
javerosmx-2015-marzo-groovy-java8-comparison
PDF
Software Engineering Thailand: Programming with Scala
PPTX
Gradle.Enemy at the gates
KEY
Ruby Midwest 2010 jRuby by Charles Nutter
PPTX
Scala adoption by enterprises
KEY
Rails 3.1
PDF
Clojure in real life 17.10.2014
PDF
Scala in Model-Driven development for Apparel Cloud Platform
Polyglot Plugin Programming
Java Edge.2009.Grails.Web.Dev.Made.Easy
PHP, the GraphQL ecosystem and GraphQLite
Scaling with swagger
遇見 Ruby on Rails
Clojurescript slides
Scala Native: Ahead of Time
Polyglot and Functional Programming (OSCON 2012)
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
Better Framework Better Life
Go - A Key Language in Enterprise Application Development?
Introduction to JRuby
javerosmx-2015-marzo-groovy-java8-comparison
Software Engineering Thailand: Programming with Scala
Gradle.Enemy at the gates
Ruby Midwest 2010 jRuby by Charles Nutter
Scala adoption by enterprises
Rails 3.1
Clojure in real life 17.10.2014
Scala in Model-Driven development for Apparel Cloud Platform

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
A Presentation on Artificial Intelligence
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Network Security Unit 5.pdf for BCA BBA.
Encapsulation_ Review paper, used for researhc scholars
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Digital-Transformation-Roadmap-for-Companies.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
NewMind AI Monthly Chronicles - July 2025
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MYSQL Presentation for SQL database connectivity
Building Integrated photovoltaic BIPV_UPV.pdf
Machine learning based COVID-19 study performance prediction
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I
A Presentation on Artificial Intelligence
Understanding_Digital_Forensics_Presentation.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Bridging biosciences and deep learning for revolutionary discoveries: a compr...

Polyglot Grails

  • 2. Me • @mgryszko • @osoco • Groovy/Grails (sometimes Java) hacker • test addicted and clean code lover
  • 3. Osoco • Small but outstanding • Quality preachers software development shop • TDD mantra singers • Groovy and Grails • On EC2 cloud nine hackers
  • 4. Osoco • Small but outstanding • Quality preachers software development shop • TDD mantra singers • Groovy and Grails • On EC2 cloud nine hackers Julián David
  • 6. Polyglot programming • term coined 2006 by Neil Ford • general + special-purpose languages • http://memeagora.blogspot.com/2006/12/polyglot- programming.html
  • 8. Maybe you didn’t know... http://www.flickr.com/photos/pinelife/269961241/
  • 9. Maybe you didn’t know... But you are already polyglot programmer! http://www.flickr.com/photos/pinelife/269961241/
  • 10. From relational algebra to JVM • relational algebra, rise of RDBMS -> SQL • world-wide-web -> JavaScript, HTML (?) • multilanguage platforms - .NET, JVM
  • 11. > 200 languages on JVM
  • 12. > 200 languages on JVM
  • 13. > 200 languages on JVM
  • 14. Why polyglot? • General purpose languages evolve too slowly • Specific-languages solve specific problems (DSLs included) • New challenges • Old habits die hard
  • 15. Do we have to speak Groovy with Grails?
  • 16. Do we have to speak Groovy with Grails? • Yes... • Groovy and Grails are inseparable
  • 17. Do we have to speak Groovy with Grails? • Yes... • Groovy and Grails are inseparable • But... • Non-Groovy code can be executed from Grails components
  • 18. Grails is already polyglot, can we push it further?
  • 19. Grails plugins • Clojure • Scala • JRuby
  • 20. Grails plugins • Clojure • Scala • JRuby
  • 21. Clojure • Functional language • Lisp reloaded • Built-in support for concurrency • Java interoperability
  • 22. Clojure • Functional language • Lisp reloaded • Built-in support for concurrency • Java interoperability
  • 23. Functional language • Not pure functional • Explicit state management • Immutable, lazy and infinite data structures • Higher-order functions • Dynamically typed*
  • 24. Functional language • Not pure functional • Explicit state management • Immutable, lazy and infinite data structures • Higher-order functions • Dynamically typed*
  • 25. Lisp reloaded • Everything is sequence (extended Lisp list) • Extended data structures - maps, sets • Less parentheses, commas = whitespaces • Multimethods dispatch on anything • Metadata • Tail call optimization on JVM
  • 26. Lisp reloaded • Everything is sequence (extended Lisp list) • Extended data structures - maps, sets • Less parentheses, commas = whitespaces • Multimethods dispatch on anything • Metadata • Tail call optimization on JVM
  • 27. Concurrency • Managed references (refs, agents, atoms, vars) • Software Transactional Memory • Actors • Atoms (~ java.util.concurrent.atomic.Atomic* ) • Vars (~ ) java.lang.ThreadLocal
  • 28. Concurrency • Managed references (refs, agents, atoms, vars) • Software Transactional Memory • Actors • Atoms (~ java.util.concurrent.atomic.Atomic* ) • Vars (~ ) java.lang.ThreadLocal
  • 29. Java interoperability • Import Java classes • Direct access to class/instance fields and methods • Syntactic sugar • Implement Java interfaces and classes on the fly • Create Java classes
  • 30. Java interoperability • Import Java classes • Direct access to class/instance fields and methods • Syntactic sugar • Implement Java interfaces and classes on the fly • Create Java classes
  • 31. Why Clojure & Grails? • Concurrency • Laziness • Rich collection library • Relational algebra
  • 32. Why Clojure & Grails? • Concurrency • Laziness • Rich collection library • Relational algebra
  • 33. Clojure and Grails • Install Clojure plugin http://grails.org/plugin/clojure grails install-plugin clojure • Put your sources under src/clj • Use grails namespace (ns grails) • Access Clojure code through clj property
  • 34. Clojure and Grails • Install Clojure plugin http://grails.org/plugin/clojure grails install-plugin clojure • Put your sources under src/clj • Use grails namespace (ns grails) • Access Clojure code through clj property
  • 35. Demo - bootstrap • Clojure code can access Grails objects • Sample note added during bootstrap
  • 36. Demo - bootstrap • Clojure code can access Grails objects • Sample note added during bootstrap
  • 37. Demo - tag counter • Note taking application • Notes can be tagged • Calculate most popular tags
  • 38. Demo - tag counter • Note taking application • Notes can be tagged • Calculate most popular tags
  • 39. Plugin gotchas • Uses Clojure 1.2 • No access to Groovy-augmented methods e.g. String.reverse()
  • 40. Plugin gotchas • Uses Clojure 1.2 • No access to Groovy-augmented methods e.g. String.reverse()
  • 41. Scala • Object-functional • Statically typed but with type inference • Concurrency through actors • Almost as fast as Java
  • 42. Scala • Object-functional • Statically typed but with type inference • Concurrency through actors • Almost as fast as Java
  • 43. Functional language • Immutability • Higher-order functions • Pattern matching + case classes • Lazy evaluation • Monads • Parser combinators
  • 44. Functional language • Immutability • Higher-order functions • Pattern matching + case classes • Lazy evaluation • Monads • Parser combinators
  • 45. Why Scala in Grails? • High performance without Java • Functional features • DSLs
  • 46. Why Scala in Grails? • High performance without Java • Functional features • DSLs
  • 47. Scala and Grails • Install Scala plugin http://www.grails.org/plugin/scala grails install-plugin scala • Put your source under src/scala • Add explicit Scala dependencies compile "org.scala-lang:scala-compiler:2.9.1", "org.scala-lang:scala-library:2.9.1"
  • 48. Scala and Grails • Install Scala plugin http://www.grails.org/plugin/scala grails install-plugin scala • Put your source under src/scala • Add explicit Scala dependencies compile "org.scala-lang:scala-compiler:2.9.1", "org.scala-lang:scala-library:2.9.1"
  • 49. Demo shortest path • Calculate shortest path between two cities • Use Scala4Graph library
  • 50. Demo shortest path • Calculate shortest path between two cities • Use Scala4Graph library
  • 51. Plugin gotchas • No access to Groovy/Grails classes • Execute Grails with --verbose option for Scala compiler error • No IDE support for executing Scala code tests
  • 52. Plugin gotchas • No access to Groovy/Grails classes • Execute Grails with --verbose option for Scala compiler error • No IDE support for executing Scala code tests
  • 53. Plugin gotchas • DSL objects must be 100% Scala • Boilerplate code for accessing Scala results scalaList.foreach( [apply: {groovyList << it}] as Function1 ) • Scala components can be Spring beans
  • 54. Plugin gotchas • DSL objects must be 100% Scala • Boilerplate code for accessing Scala results scalaList.foreach( [apply: {groovyList << it}] as Function1 ) • Scala components can be Spring beans
  • 55. Ruby • JRuby - Ruby 1.8.7 & 1.9.2 compatible • Object-oriented, dynamic • Some functional features • Tones of gems
  • 56. Ruby • JRuby - Ruby 1.8.7 & 1.9.2 compatible • Object-oriented, dynamic • Some functional features • Tones of gems
  • 57. Why Ruby in Grails? • Hard to find a valid reason... • Rails app migration to Grails? • Particular gem?
  • 58. Why Ruby in Grails? • Hard to find a valid reason... • Rails app migration to Grails? • Particular gem?
  • 59. Ruby and Grails • Install Ruby plugin http://www.grails.org/plugin/ruby grails install-plugin ruby • Put your sources under src/ruby • Access Ruby code through ruby property
  • 60. Ruby and Grails • Install Ruby plugin http://www.grails.org/plugin/ruby grails install-plugin ruby • Put your sources under src/ruby • Access Ruby code through ruby property
  • 61. Demo - BOFH server • http://en.wikipedia.org/wiki/ Bastard_Operator_From_Hell • bofh-excuse gem
  • 62. Demo - BOFH server • http://en.wikipedia.org/wiki/ Bastard_Operator_From_Hell • bofh-excuse gem
  • 63. Plugin gotchas • No gem installation • No access to Grails classes
  • 64. Plugin gotchas • No gem installation • No access to Grails classes
  • 65. Speak your mother tongue • plug in your compiler on compileStart event (Scala plugin) • use JSR223 javax.script.ScriptEngine (Ruby plugin) • use custom interpreter (Clojure plugin, clojure.lang.Compiler) • trigger code reloading when changed
  • 66. My ranking for
  • 67. My ranking for
  • 68. My ranking for
  • 69. My ranking for
  • 70. Thank you! ¡Gracias! Danke! Dziękuję!

Editor's Notes

  • #2: \n
  • #3: \n
  • #4: \n
  • #5: \n
  • #6: \n
  • #7: \n
  • #8: \n
  • #9: \n
  • #10: \n
  • #11: \n
  • #12: \n
  • #13: \n
  • #14: \n
  • #15: \n
  • #16: Person: polyglot is someone with a high degree of proficiency in several languages; hyperpolyglot: more that 6 languages\nComputing: polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it.\n
  • #17: My first professional work as a software developer was writing Clipper code. Clipper was a compiler for dBASE code with object-oriented extensions. This was in the days of DOS, and the entire application was written in a single language. We didn&apos;t even use SQL. Instead, the data storage was shared DBF files on a new concept, the LAN (I remember reading a PC-Magazine of that era declaring that the current year was the &quot;Year of the LAN&quot;).\n\nWe are entering a new era of software development. For most of our (short) history, we&apos;ve primarily written code in a single language. Of course, there are exceptions: most applications now are written with both a general purpose language and SQL. Now, increasingly, we&apos;re expanding our horizons. More and more, applications are written with Ajax frameworks (i.e., JavaScript). If you consider the embedded languages we use, it&apos;s even broader: XML is used as an embedded configuration language widely in both the Java and .NET worlds.\n\nBut I&apos;m beginning to see a time where even the core language (the one that gets translated to byte code) will cease its monoculture. Pretty much any computer you buy has multiple processors in it, so we&apos;re going to have to get better writing threading code. Yet, as anyone who has read Java Concurrency in Practice by Brian Goetz (an exceptional book, by the way), writing good multi-threading code is hard. Very hard. So why bother? Why not use a language that handles multiple threads more gracefully? Like a functional language? Functional languages eliminate side effects on variables, making it easier to write thread-safe code. Haskell is such a language, and implementations exist for both Java (Jaskell) and .NET (Haskell.net). Need a nice web-based user interface? Why not use Ruby on Rails via JRuby (which now support RoR).\n\nApplications of the future will take advantage of the polyglot nature of the language world. We have 2 primary platforms for &quot;enterprise&quot; development: .NET and Java. There are now lots of languages that target those platforms. We should embrace this idea. While it will make some chores more difficult (like debugging), it makes others trivially easy (or at least easier). It&apos;s all about choosing the right tool for the job and leveraging it correctly. Pervasive testing helps the debugging problem (adamant test-driven development folks spend much less time in the debugger). SQL, Ajax, and XML are just the beginning. Increasingly, as I&apos;ve written before, we&apos;re going to start adding domain specific languages. The times of writing an application in a single general purpose language is over. Polyglot programming is a subject I&apos;m going to speak about a lot next year. Stay tuned...\n\n
  • #18: \n
  • #19: \n
  • #20: 1. First computer programs were monolingual (up to end 70ties). Late 70ties and 80ties Oracle pushed first commercial RDBMS (Oracle v2) to the market. A couple of weeks later IBM introduced System/38, an architecture with a built-in RDBMS.\n\nSQL is a declarative language with some procedural (imperative) extensions.\n\nWhy SQL and RDBMS became so popular?\nBest mix of simplicity, robustness, flexibility, performance, scalability, and compatibility in managing generic data.\n\n2. In addition to an imperative language for the core solution, JavaScript and HTML were added to the programmer&amp;#x2019;s palette. \n\nHTML ~ declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow.\n\n3. New general purpose languages (Java, C#) built on the top of execution environments (JVM, CLR - Common Language Runtime).\n\nAlthough new languages, they carried some baggage of the past (C-like syntax). But they separated language definition from the execution environment specification.\n
  • #21: \n
  • #22: \n
  • #23: \n
  • #24: \n
  • #25: \n
  • #26: \n
  • #27: \n
  • #28: \n
  • #29: \n
  • #30: Specific-languages solve specific problems - HTML for markup building, SQL for relational calculus\nNew challenges - multiprocessor and multicore machines, scaling by more concurrency\nOld habits die hard - we got used to old-school languages, so paradigm shift is painful\n\n
  • #31: Perfect description for Groovy and Grails\n- built on the top of a stable language (Java), platform (JVM) and frameworks (Spring, Hibernate)\n- uses Groovy for the rapid development\n- facilitates creation of DSLs (Groovy builders, metaprogramming capabilities)\n
  • #32: Perfect description for Groovy and Grails\n- built on the top of a stable language (Java), platform (JVM) and frameworks (Spring, Hibernate)\n- uses Groovy for the rapid development\n- facilitates creation of DSLs (Groovy builders, metaprogramming capabilities)\n
  • #33: Perfect description for Groovy and Grails\n- built on the top of a stable language (Java), platform (JVM) and frameworks (Spring, Hibernate)\n- uses Groovy for the rapid development\n- facilitates creation of DSLs (Groovy builders, metaprogramming capabilities)\n
  • #34: Grails assumes that components (controllers, services, domain objects) are written in Groovy and bases its functionality on this premise. Language constructs determine component behaviour.\n\nThanks to Groovy dynamic nature and a flexible build system, we can plug code written in other JVM languages into Grails components\n
  • #35: Grails assumes that components (controllers, services, domain objects) are written in Groovy and bases its functionality on this premise. Language constructs determine component behaviour.\n\nThanks to Groovy dynamic nature and a flexible build system, we can plug code written in other JVM languages into Grails components\n
  • #36: \n
  • #37: \n
  • #38: \n
  • #39: \n
  • #40: \n
  • #41: Functions should have no side-effects. You can mark that a function introduces side effects with do*\nHigher-order functions - functions are treated like data\nDynamically typed - by default, but allow this behaviour to be overridden through the use of explicit type hints that result in static typing. One reason to use such hints would be to achieve the performance benefits of static typing in performance-sensitive parts of code.\n
  • #42: Lisp reloaded\n- homoiconic - Clojure code is just Clojure data\n- Polish prefix notation\n- less paretheses (LISP = Lost In Stupid Parentheses, Lots of Irritating Superfluous Parentheses)\n- multimethods - polymorphism in Lisp\n- metadata used e.g. to attach documentation, type hinting\n- TCO - not supported natively on JVM. Clojure enforces it through loop/fn - recur\n\n
  • #43: Managed references\nref - shared changes, synchronous, coordinated changes (in a transaction)\nagent - shared changes, asynchronous, independent changes\natom - shared changes, synchronous, independent changes\nvar - isolated changes\n\nSTM - works like database with ACI properties (atomicity, consistency, isolation). Not D (durable)\nData mutated inside a transaction (dosync). Changes isolated from other threads. First thread that completely executes the block of code that&amp;#x2019;s the transaction is allowed to commit the changed values. Once a thread commits, when any other thread attempts to commit, that transaction is aborted and the changes are rolled back.\nThe commit performed when a transaction is successful is atomic in nature. This means that even if a transaction makes changes to multiple refs, as far as the outside world is concerned, they all appear to happen at the same instant (when the transaction commits). STM systems can also choose to retry failed transactions, and many do so until the transaction succeeds. Clojure also supports this automatic retrying of failed transactions, up to an internal limit.\n\nAtomic - if a transaction mutates several refs, the changes become visible to the outside world at one instant. Either all the changes happen, or, if the transaction fails, the changes are rolled back and no change happens.\n\nIsolation - in-transaction changes visible only to the transaction\n\nConsistency - refs accept validator functions when created. These functions are used to check the consistency of the data when changes are made to them. If the validator function fails, the transaction is rolled back.\n\nActor (agent)\nReceives a message (function) that updates a mutable state.\nMay be used for side-effects inside the transaction - a message to an agent during a transaction is sent only once, even a transaction is restarted\n\nVar\nCan have a root binding (visible to all threads) and a local per-thread binding\n
  • #44: Syntactic sugar\n- constructor call (SimpleDateFormat. &quot;yyyy-MM-dd&quot;)\n- dot special form (. rnd nextInt 10)\n- dot dot \n(. (. (Calendar/getInstance) getTimeZone) getDisplayName)\n(.. (Calendar/getInstance) getTimeZone getDisplayName)\n- doto ~ Groovy with\n(let [calendar-obj (Calendar/getInstance)]\n (doto calendar-obj\n (.set Calendar/AM_PM Calendar/AM)\n (.set Calendar/HOUR 0)\n (.set Calendar/MINUTE 0)\n (.set Calendar/SECOND 0)\n (.set Calendar/MILLISECOND 0))\n (.getTime calendar-obj)))\n- Java methods -&gt; first-class functions\n(map #(.getBytes %) [&quot;amit&quot; &quot;rob&quot; &quot;kyle&quot;])\n(map (memfn getBytes) [&quot;amit&quot; &quot;rob&quot; &quot;kyle&quot;])\n- bean - convert Java object into Closure map\n(bean (Calendar/getInstance))\n- array macros\n\nImplementing Java interfaces and classes\n- to use them in Clojure code\n- proxy macro\n- partial implementation of a interface/class\n- multiple classes/interfaces in a single proxy\n\nCreate Java classes\n - to use them in Java code\n
  • #45: Clojure contrib can be added as Maven dependency\n dependencies {\n compile &apos;org.clojure:clojure-contrib:1.2.0&apos;\n }\n\n\n\n
  • #46: Clojure code is automatically reloaded\n
  • #47: Clojure code is automatically reloaded\n
  • #48: \n
  • #49: \n
  • #50: \n
  • #51: \n
  • #52: \n
  • #53: \n
  • #54: Object orientation - supports partial classes (traits)\n
  • #55: \n
  • #56: \n\n
  • #57: \n\n
  • #58: \n
  • #59: \n
  • #60: \n\n
  • #61: \n\n
  • #62: No access to Groovy/Grails classes - no joint Groovy/Scala compilation\n
  • #63: No access to Groovy/Grails classes - no joint Groovy/Scala compilation\n
  • #64: DSL classes must be 100% Scala\n- Groovy classes cannot participate in pattern matching - they are not case classes\n- Scala cannot access Groovy code - implicit conversions only for Scala objects\n
  • #65: DSL classes must be 100% Scala\n- Groovy classes cannot participate in pattern matching - they are not case classes\n- Scala cannot access Groovy code - implicit conversions only for Scala objects\n
  • #66: TCO - recompile Ruby with vm_opts.h #define OPT_TAILCALL_OPTIMIZATION 1\nFunctions with side effect are marked with !\nEverything is expression\nHigher-order functions, partial functions and currying\n\n
  • #67: \n\n
  • #68: \n\n
  • #69: \n
  • #70: \n
  • #71: The Bastard Operator From Hell (BOFH), a fictional character created by Simon Travaglia, is a rogue system administrator who takes out his anger on users (often referred to as lusers), colleagues, bosses, and anyone else who gets in his way.\n
  • #72: The Bastard Operator From Hell (BOFH), a fictional character created by Simon Travaglia, is a rogue system administrator who takes out his anger on users (often referred to as lusers), colleagues, bosses, and anyone else who gets in his way.\n
  • #73: Gems must be installed locally and their source code moved to the Grails project\n
  • #74: Gems must be installed locally and their source code moved to the Grails project\n
  • #75: Alternative JRuby integration\nhttp://kenai.com/projects/jruby/pages/RedBridge\n
  • #76: Clojure - full access to Grails classes, concurrency made easy language concepts complementing Groovy ones\nJRuby - proof of concept\n
  • #77: Clojure - full access to Grails classes, concurrency made easy language concepts complementing Groovy ones\nJRuby - proof of concept\n
  • #78: Clojure - full access to Grails classes, concurrency made easy language concepts complementing Groovy ones\nJRuby - proof of concept\n
  • #79: \n
  • #80: The Bastard Operator From Hell (BOFH), a fictional character created by Simon Travaglia, is a rogue system administrator who takes out his anger on users (often referred to as lusers), colleagues, bosses, and anyone else who gets in his way.\n