SlideShare una empresa de Scribd logo
1 de 71
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

Más contenido relacionado

La actualidad más candente

Introduction To Groovy
Introduction To GroovyIntroduction To Groovy
Introduction To Groovymanishkp84
 
functional groovy
functional groovyfunctional groovy
functional groovyPaul King
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy PluginsPaul King
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Mohamed Nabil, MSc.
 
Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Sunghyouk Bae
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Charles Nutter
 
Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoMuhammad Abdullah
 
Down the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandDown the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandCharles Nutter
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyHaim Yadid
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the futureAnsviaLab
 
Make Testing Groovy
Make Testing GroovyMake Testing Groovy
Make Testing GroovyPaul King
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015Charles Nutter
 
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 LanguagesStephen Chin
 
Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with KotlinHaim Yadid
 
Flutter 是什麼?用 Flutter 會省到時間嗎? @ GDG Devfest2020
Flutter 是什麼?用 Flutter 會省到時間嗎? @ GDG Devfest2020Flutter 是什麼?用 Flutter 會省到時間嗎? @ GDG Devfest2020
Flutter 是什麼?用 Flutter 會省到時間嗎? @ GDG Devfest2020Johnny Sung
 
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and SparkScala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and SparkEduardo Gonzalez
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesCharles Nutter
 

La actualidad más candente (20)

Introduction To Groovy
Introduction To GroovyIntroduction To Groovy
Introduction To Groovy
 
functional groovy
functional groovyfunctional groovy
functional groovy
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy Plugins
 
[Start] Scala
[Start] Scala[Start] Scala
[Start] Scala
 
Scala Introduction
Scala IntroductionScala Introduction
Scala Introduction
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
 
Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017
 
Scala in Practice
Scala in PracticeScala in Practice
Scala in Practice
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
 
Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demo
 
Down the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandDown the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM Wonderland
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, Seriously
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the future
 
Make Testing Groovy
Make Testing GroovyMake Testing Groovy
Make Testing Groovy
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015
 
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
 
Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with Kotlin
 
Flutter 是什麼?用 Flutter 會省到時間嗎? @ GDG Devfest2020
Flutter 是什麼?用 Flutter 會省到時間嗎? @ GDG Devfest2020Flutter 是什麼?用 Flutter 會省到時間嗎? @ GDG Devfest2020
Flutter 是什麼?用 Flutter 會省到時間嗎? @ GDG Devfest2020
 
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and SparkScala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 

Destacado

Spring Annotations: Proxy
Spring Annotations: ProxySpring Annotations: Proxy
Spring Annotations: ProxyOSOCO
 
Proactive monitoring with Monit
Proactive monitoring with MonitProactive monitoring with Monit
Proactive monitoring with MonitOSOCO
 
AWS CloudFormation en 5 Minutos
AWS CloudFormation en 5 MinutosAWS CloudFormation en 5 Minutos
AWS CloudFormation en 5 MinutosOSOCO
 
Understanding Java Dynamic Proxies
Understanding Java Dynamic ProxiesUnderstanding Java Dynamic Proxies
Understanding Java Dynamic ProxiesOSOCO
 
SSH Tunneling Recipes
SSH Tunneling RecipesSSH Tunneling Recipes
SSH Tunneling RecipesOSOCO
 
MADBike – Destapando la seguridad de BiciMAD (T3chFest 2017)
MADBike – Destapando la seguridad de BiciMAD (T3chFest 2017)MADBike – Destapando la seguridad de BiciMAD (T3chFest 2017)
MADBike – Destapando la seguridad de BiciMAD (T3chFest 2017)Alex Rupérez
 
Gigigo Keynote - Geofences & iBeacons
Gigigo Keynote - Geofences & iBeaconsGigigo Keynote - Geofences & iBeacons
Gigigo Keynote - Geofences & iBeaconsAlex Rupérez
 
NSCoder Keynote - Multipeer Connectivity Framework
NSCoder Keynote - Multipeer Connectivity FrameworkNSCoder Keynote - Multipeer Connectivity Framework
NSCoder Keynote - Multipeer Connectivity FrameworkAlex Rupérez
 
Gigigo Workshop - Create an iOS Framework, document it and not die trying
Gigigo Workshop - Create an iOS Framework, document it and not die tryingGigigo Workshop - Create an iOS Framework, document it and not die trying
Gigigo Workshop - Create an iOS Framework, document it and not die tryingAlex Rupérez
 
Gigigo Workshop - iOS Extensions
Gigigo Workshop - iOS ExtensionsGigigo Workshop - iOS Extensions
Gigigo Workshop - iOS ExtensionsAlex Rupérez
 

Destacado (10)

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

Similar a Polyglot Grails

Polyglot Plugin Programming
Polyglot Plugin ProgrammingPolyglot Plugin Programming
Polyglot Plugin ProgrammingAtlassian
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easyroialdaag
 
PHP, the GraphQL ecosystem and GraphQLite
PHP, the GraphQL ecosystem and GraphQLitePHP, the GraphQL ecosystem and GraphQLite
PHP, the GraphQL ecosystem and GraphQLiteJEAN-GUILLAUME DUJARDIN
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swaggerTony Tam
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Scala Native: Ahead of Time
Scala Native: Ahead of TimeScala Native: Ahead of Time
Scala Native: Ahead of TimeNadav Wiener
 
Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Martijn Verburg
 
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)Shanda innovation institute
 
Better Framework Better Life
Better Framework Better LifeBetter Framework Better Life
Better Framework Better Lifejeffz
 
Go - A Key Language in Enterprise Application Development?
Go - A Key Language in Enterprise Application Development?Go - A Key Language in Enterprise Application Development?
Go - A Key Language in Enterprise Application Development?C4Media
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRubyajuckel
 
javerosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparisonjaverosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparisonDomingo Suarez Torres
 
Software Engineering Thailand: Programming with Scala
Software Engineering Thailand: Programming with ScalaSoftware Engineering Thailand: Programming with Scala
Software Engineering Thailand: Programming with ScalaBrian Topping
 
Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gatesStrannik_2013
 
Ruby Midwest 2010 jRuby by Charles Nutter
Ruby Midwest 2010 jRuby by Charles NutterRuby Midwest 2010 jRuby by Charles Nutter
Ruby Midwest 2010 jRuby by Charles NutterSteven Chau
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprisesMike Slinn
 
Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Metosin Oy
 
Scala in Model-Driven development for Apparel Cloud Platform
Scala in Model-Driven development for Apparel Cloud PlatformScala in Model-Driven development for Apparel Cloud Platform
Scala in Model-Driven development for Apparel Cloud PlatformTomoharu ASAMI
 

Similar a Polyglot Grails (20)

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

Último

Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Último (20)

Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

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ę!

Notas del editor

  1. \n
  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. 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
  16. 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
  17. \n
  18. \n
  19. 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
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. 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
  30. 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
  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. 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
  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. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. 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
  41. 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
  42. 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
  43. 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
  44. 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
  45. Clojure code is automatically reloaded\n
  46. Clojure code is automatically reloaded\n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. Object orientation - supports partial classes (traits)\n
  54. \n
  55. \n\n
  56. \n\n
  57. \n
  58. \n
  59. \n\n
  60. \n\n
  61. No access to Groovy/Grails classes - no joint Groovy/Scala compilation\n
  62. No access to Groovy/Grails classes - no joint Groovy/Scala compilation\n
  63. 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
  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. 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
  66. \n\n
  67. \n\n
  68. \n
  69. \n
  70. 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
  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. Gems must be installed locally and their source code moved to the Grails project\n
  73. Gems must be installed locally and their source code moved to the Grails project\n
  74. Alternative JRuby integration\nhttp://kenai.com/projects/jruby/pages/RedBridge\n
  75. Clojure - full access to Grails classes, concurrency made easy language concepts complementing Groovy ones\nJRuby - proof of concept\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. \n
  79. 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