Cool Web Apps with Grails, Groovy and Next-Gen Scripting Languages William Grosso Twofish
Abstract <ul><li>The rise of next-generation languages that run on top of the JVM is probably the most interesting thing t...
Actual Talk <ul><li>The rise of next-generation languages that run on top of the JVM is probably the most interesting thin...
Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation </li></ul><ul><li>“ Improving” the La...
Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation (2003 Recap) </li></ul><ul><li>“ Impr...
Who Am I?
Opinionated Talk <ul><li>I’m not selling something </li></ul><ul><ul><li>I’m talking about something that I think is going...
This all started in July <ul><li>Left Engage in June  </li></ul><ul><li>Decided to spend some time exploring new technolog...
Up and running for >3 months without any attention from me
Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation (2003 Recap) </li></ul><ul><li>“ Impr...
In 2003 …  <ul><li>I was invited to give a colloquium talk at CSU Sonoma </li></ul><ul><ul><li>Dot-com bust was still in e...
That Talk Began With …. <ul><li>I want to convince you of two things </li></ul><ul><ul><li>That Java, or some language lik...
My 2003 Big Bold Claim <ul><li>In the world of the future, programs will be increasingly be written by communities  </li><...
Supporting Communities <ul><li>New programmers must be able to get up to speed in the language </li></ul><ul><li>Platforms...
I Was Right <ul><li>Take a look at the libraries out there </li></ul><ul><li>Take a look at Java’s market share </li></ul>...
Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation (2003 Recap) </li></ul><ul><li>“ Impr...
But I Wasn’t Completely Right JVM Platform Libraries and  Application Frameworks Your App / Your Web App Your Libraries Yo...
Lots of people having similar thoughts. The JVM is robust enough, and the platform is robust enough, and … that people are...
Short list of “interesting” languages: Jython JRuby Scala Groovy Kawa Clojure PHP NetRexx (??)
Completely a sidenote: If you’re curious about programming language design, this is the single best  site on the web
Closures have been THE hot topic in commercial language design
Odersky’s claim: closures + first class  containers + super strong typing are the bees knees
Complexity is bad. Java is near the edge of the cliff. 4.5M PDF and a Tiny Thumbnail? For Generics? Ruby has a similar pro...
Desiderata for the Tiers JVM Platform Libraries and  Application Frameworks Your App Your Libraries Your Prototypes Strong...
Only Groovy Makes the Short List <ul><li>Start with: Jython, JRuby, Scala, Groovy, Kawa, Clojure, PHP, NetRexx  </li></ul>...
 
Looks Like Java Go read the code examples It’s easy
Let’s Look at Concurrency Not Java def? 1 .. 8  sleep 30 But … it’s close
Complete Integration with Java <ul><li>Need to be able to use any library or jar </li></ul><ul><ul><li>Seamlessly create a...
import groovy.swing.*; import java.awt.*; import javax.swing.*; class Model extends Observable { static CURRENCY = [&quot;...
swing = new SwingBuilder() model = new Model() frame = swing.frame(title: &quot;Groovy SwingBuilder MVC Demo&quot;, layout...
 
 
First Class Containers <ul><li>Boils down to  </li></ul><ul><ul><li>Easy construction syntax  </li></ul></ul><ul><ul><li>M...
weekMap = [ &quot;Su&quot; : &quot;Sunday&quot;, &quot;Mo&quot; : &quot;Monday&quot;, &quot;Tu&quot; : &quot;Tuesday&quot;...
Gafter’s Def’n of Closure <ul><li>A closure is a function that refers to free variables in its lexical context </li></ul><...
In Practice <ul><li>A closure is a function pointer that knows all the variables that were in scope when it was defined </...
Inner Classes are Close! <ul><li>Java solution: Define an anonymous inner class that implements a well-known interface </l...
Don’t believe me?  Neal likes Java  a LOT more than I do
XML Support <ul><li><interactive example with groovy console> </li></ul>def CAR_RECORDS = ''' <records> <car name='HSV Mal...
XML Support II <ul><li>XMLBuilder </li></ul><ul><li>Will be discussed in detail after MetaObject Protocol section </li></ul>
Rapid Prototyping: Scripts, Shell and Console <ul><li>Scripts – groovy doesn’t need to use classes.  </li></ul><ul><ul><li...
Metaobject Protocol <ul><li>A  metaobject protocol  (MOP) is an  interpreter  of the  semantics  of a program that is open...
MetaObject Protocols: The Point <ul><li>At runtime, can find out about, and alter, class definitions </li></ul><ul><ul><li...
Chris will talk more about GORM later on
Builders <ul><li>Lots and lots of things are tree-like data structures </li></ul><ul><ul><li>User interfaces (structure of...
What’s Martin Fowler been doing since the refactoring book anyway?
 
How to Build a Builder <ul><li>Implement a (Java!) subclass of BuilderSupport </li></ul><ul><li>Or just use methodMissing ...
MarkupBuilder import groovy.xml.MarkupBuilder  def writer = new StringWriter()  def xml = new MarkupBuilder(writer) xml.re...
Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation (2003 Recap) </li></ul><ul><li>“ Impr...
Rails as a Thunderbolt <ul><li>Convention over configuration </li></ul><ul><ul><li>Kind of like design patterns, except th...
The Rails guys invented the “movie to demo the framework” idea and their movies are still WOW OH WOW GOOD
<ul><li>PHP </li></ul><ul><li>PHP </li></ul><ul><li>Java (Coldfusion) </li></ul><ul><li>PHP </li></ul><ul><li>.NET </li></...
In 4 years, Rails has made very impressive strides. Market leader in the “early stage startup” category.
Issues with Ruby <ul><li>Powerful language, currently in flux </li></ul><ul><ul><li>Transition from 1.8 to 1.9 is slow and...
Backwards compatibility is not a huge priority
Backwards compatibility is not a huge priority
This is scary
Of course, Java is mostly developed by Sun ….
This is from a Ruby guy who doesn’t like JRuby very much …
Issues with Rails <ul><li>Focus on CRUD </li></ul><ul><ul><li>Works very well for the standard web architecture </li></ul>...
Grails is “Groovy on Rails” <ul><li>Adopt many, if not all, of the key ideas of Rails </li></ul><ul><ul><li>Swap out Ruby ...
Pieces / Parts <ul><li>GSP – “Groovy Server Pages” </li></ul><ul><ul><li>A lot like JSP </li></ul></ul><ul><li>GORM – “Gro...
GORM <ul><li><<Chris– a world class expert in GORM>> </li></ul>
Plugins and Extensability <ul><li>Grails is a platform for extensions </li></ul><ul><li>Makes a lot of sense given the poi...
SWAG Estimate: About ¾ of plugins are mentioned here (BIRT, for example, is not)
Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation </li></ul><ul><li>“ Improving” the La...
Twofish Model TFEL TFEL DB TFEL DB <ul><li>JBoss 4 on Java 6. </li></ul><ul><li>Everything clustered </li></ul><ul><li>Eve...
<<IntelliJ>>
Annoyances (Love Mashup) <ul><li>Mainly from my incompetence with HTML. </li></ul><ul><li>Also: imperfect prototyping envi...
Plugins (Love Mashup) <ul><li>Cloud Foundry – easy deploy to Amazon </li></ul><ul><li>YUI – cleaner UI components </li></u...
Annoyances (Twofish) <ul><li>Oddly enough, the Java stack </li></ul><ul><ul><li>JDK has an XML Parser </li></ul></ul><ul><...
Plugins (Twofish) <ul><li>Quartz plugin – Background processing </li></ul><ul><li>BIRT plugin – Enterprise class reports <...
Additional Reading
This is a great series of articles. Whenever anyone tells you a technology is going to be big, ask yourself: WWTT?
 
 
Upcoming SlideShare
Loading in …5
×

Groovy And Grails

2,905 views
2,857 views

Published on

Talk given at SDForum's Java SIG on Jan 6, 2009

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

No Downloads
Views
Total views
2,905
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
55
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Groovy And Grails

    1. 1. Cool Web Apps with Grails, Groovy and Next-Gen Scripting Languages William Grosso Twofish
    2. 2. Abstract <ul><li>The rise of next-generation languages that run on top of the JVM is probably the most interesting thing to happen in the Java universe since the combination of the Spring framework and the EJB 2 specification signaled the complete implosion of the Enterprise Software Stack </li></ul><ul><li>In this talk, I'll cover, in sequence: </li></ul><ul><ul><li>A brief overview of the state of the art of web application development </li></ul></ul><ul><ul><li>A brief overview of Groovy, one of the most interesting of the next-gen languages available on the JVM. </li></ul></ul><ul><ul><li>A brief overview of Grails, the best web-application framework currently available (where &quot;best&quot; is, of course, highly idiosyncratic) </li></ul></ul><ul><ul><li>The source code to an actual working web application written in Groovy/Grails. </li></ul></ul>
    3. 3. Actual Talk <ul><li>The rise of next-generation languages that run on top of the JVM is probably the most interesting thing to happen in the Java universe since the combination of the Spring framework and the EJB 2 specification signaled the complete implosion of the Enterprise Software Stack </li></ul><ul><li>In this talk, I'll cover, in sequence: </li></ul><ul><ul><li>A brief discussion of Java and the programming languages on the JVM. </li></ul></ul><ul><ul><li>A fairly lengthy overview of Groovy, one of the most interesting of the next-gen languages available on the JVM. </li></ul></ul><ul><ul><li>A brief overview of Grails, the best web-application framework currently available (where &quot;best&quot; is, of course, highly idiosyncratic) </li></ul></ul><ul><ul><li>The source code to an (admittedly small) actual working web application written in Groovy/Grails. </li></ul></ul>
    4. 4. Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation </li></ul><ul><li>“ Improving” the Language: Groovy </li></ul><ul><li>Improving the Framework: Grails </li></ul><ul><li>Some Actual Code </li></ul>
    5. 5. Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation (2003 Recap) </li></ul><ul><li>“ Improving” the Language: Groovy </li></ul><ul><li>Improving the Framework: Grails </li></ul><ul><li>Some Actual Code </li></ul>
    6. 6. Who Am I?
    7. 7. Opinionated Talk <ul><li>I’m not selling something </li></ul><ul><ul><li>I’m talking about something that I think is going to be big in 2010 </li></ul></ul><ul><li>Goal is also to be somewhat provocative </li></ul><ul><ul><ul><li>“ I would rather be vaguely correct than precisely wrong” – John Maynard Keynes </li></ul></ul></ul><ul><ul><ul><li>“ The references are not without merit” – George Santayana </li></ul></ul></ul>And these are my opinions, not necessarily Twofish’s
    8. 8. This all started in July <ul><li>Left Engage in June </li></ul><ul><li>Decided to spend some time exploring new technologies </li></ul><ul><ul><li>Was impressed enough by Grails to write my “Love Mashup” </li></ul></ul><ul><li>Took the job at Twofish and left things percolating in my brain </li></ul>
    9. 9. Up and running for >3 months without any attention from me
    10. 10. Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation (2003 Recap) </li></ul><ul><li>“ Improving” the Language: Groovy </li></ul><ul><li>Improving the Framework: Grails </li></ul><ul><li>Some Actual Code </li></ul>
    11. 11. In 2003 … <ul><li>I was invited to give a colloquium talk at CSU Sonoma </li></ul><ul><ul><li>Dot-com bust was still in effect; valley was deep in recession </li></ul></ul><ul><li>Java: It's better than you think, for reasons you haven't realized you already know. </li></ul><ul><ul><li>http://www.slideshare.net/wgrosso/java-and-community-support-presentation/ </li></ul></ul>
    12. 12. That Talk Began With …. <ul><li>I want to convince you of two things </li></ul><ul><ul><li>That Java, or some language like it, is inevitable from a technological point of view </li></ul></ul><ul><ul><li>That Java itself is inevitable from a social point of view. </li></ul></ul><ul><li>I want to avoid using the traditional technology or “computer science” based arguments </li></ul>
    13. 13. My 2003 Big Bold Claim <ul><li>In the world of the future, programs will be increasingly be written by communities </li></ul><ul><li>The single best measure of whether a programming language is worth using is: how well does it support communities. </li></ul><ul><ul><li>The social aspects of the language dominate the technological aspects of the language </li></ul></ul>
    14. 14. Supporting Communities <ul><li>New programmers must be able to get up to speed in the language </li></ul><ul><li>Platforms to learn the language on must be cheap and plentiful </li></ul><ul><li>Programmers must be able to use the language on whatever machine they’re using </li></ul><ul><li>Programmers must be able to understand and reuse each other’s code </li></ul><ul><li>Old code must survive in a useful form </li></ul><ul><ul><li>And evolve and improve </li></ul></ul>
    15. 15. I Was Right <ul><li>Take a look at the libraries out there </li></ul><ul><li>Take a look at Java’s market share </li></ul><ul><li>It’s entrenched and dominant </li></ul>
    16. 16. Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation (2003 Recap) </li></ul><ul><li>“ Improving” the Language: Groovy </li></ul><ul><li>Improving the Framework: Grails </li></ul><ul><li>Some Actual Code </li></ul>
    17. 17. But I Wasn’t Completely Right JVM Platform Libraries and Application Frameworks Your App / Your Web App Your Libraries Your Prototypes Down here, Java, super clear semantics, WORA etcetera win Hmm. Community properties probably only matter for largish things that you share or keep and reuse for a long time. Maybe we can do better than Java?
    18. 18. Lots of people having similar thoughts. The JVM is robust enough, and the platform is robust enough, and … that people are starting to seriously layer languages on top.
    19. 19. Short list of “interesting” languages: Jython JRuby Scala Groovy Kawa Clojure PHP NetRexx (??)
    20. 20. Completely a sidenote: If you’re curious about programming language design, this is the single best site on the web
    21. 21. Closures have been THE hot topic in commercial language design
    22. 22. Odersky’s claim: closures + first class containers + super strong typing are the bees knees
    23. 23. Complexity is bad. Java is near the edge of the cliff. 4.5M PDF and a Tiny Thumbnail? For Generics? Ruby has a similar problem (more later)
    24. 24. Desiderata for the Tiers JVM Platform Libraries and Application Frameworks Your App Your Libraries Your Prototypes Strong typing Absolutely clear semantics Minimal evolution of language None of the other stuff is necessary Looks like Java Clear, readable code Non-verbose language Complete integration with Java First class containers Closures Great XML support Rapid Prototyping (REPL) Metaobject Protocol
    25. 25. Only Groovy Makes the Short List <ul><li>Start with: Jython, JRuby, Scala, Groovy, Kawa, Clojure, PHP, NetRexx </li></ul><ul><ul><li>Only Scala and Groovy look even remotely like Java </li></ul></ul><ul><li>Both Scala and Groovy have first class containers, complete integration with Java, closures, rapid prototyping, and great XML support </li></ul><ul><li>Groovy’s metaobject protocol, and Grails, make it the winner </li></ul><ul><ul><li>Note that I’m completely avoiding the usual phrasing of the “dynamic typing” question, since I find it annoying </li></ul></ul>
    26. 27. Looks Like Java Go read the code examples It’s easy
    27. 28. Let’s Look at Concurrency Not Java def? 1 .. 8 sleep 30 But … it’s close
    28. 29. Complete Integration with Java <ul><li>Need to be able to use any library or jar </li></ul><ul><ul><li>Seamlessly create and invoke java objects </li></ul></ul><ul><li>Groovy adopts the Java model under the covers </li></ul><ul><li>Groovy compiles to Java classes so that Java applications can use the next-gen stuff </li></ul><ul><ul><li>When necessary </li></ul></ul><ul><ul><li>But if you buy the stacking diagram, not all that often. </li></ul></ul>
    29. 30. import groovy.swing.*; import java.awt.*; import javax.swing.*; class Model extends Observable { static CURRENCY = [&quot;USD&quot;, &quot;EURO&quot;, &quot;YEN&quot;] private Map rates = new HashMap() private long value void initialize(initialRates) { (0..CURRENCY.size() - 1).each { setRate(CURRENCY[it], initialRates[it]) } } // setting rate for currency void setRate(currency, f) { rates.put(currency, f); setChanged(); notifyObservers(currency); } // setting new value for currency void setValue(currency, double newValue) { value = Math.round(newValue / rates[currency]); setChanged(); notifyObservers(null); } // getter for value for particular currency def getValue(currency) { value * rates[currency] } } class RateView extends JTextField implements Observer { private Model model; private currency; public void setModel(Model model) { this.model?.removeObserver(this) this.model = model model.addObserver(this) } public void update(Observable o, Object currency) { if (this.currency == currency) text = String.format(&quot;%15.2f&quot;, model.rates[currency]) } } class ValueView extends JTextField implements Observer { private Model model private currency public void setModel(Model model) { this.model?.removeObserver(this) this.model = model model.addObserver(this) } public void update(Observable o, Object currency) { if (currency == null || this.currency == currency) text = String.format(&quot;%15.2f&quot;, model.getValue(this.currency)); } }
    30. 31. swing = new SwingBuilder() model = new Model() frame = swing.frame(title: &quot;Groovy SwingBuilder MVC Demo&quot;, layout: new GridLayout(4, 3), size: [300, 150], defaultCloseOperation: WindowConstants.EXIT_ON_CLOSE) { label(&quot;currency&quot;) label(&quot;rate&quot;) label(&quot;value&quot;) for (c in Model.CURRENCY) { label(c) widget(new RateView(), model: model, currency: c, action: swing.action(closure: { event -> event.source.model.setRate(event.source.currency, event.source.text.toDouble()); })) widget(new ValueView(), model: model, currency: c, action: swing.action(closure: {event -> event.source.model.setValue(event.source.currency, event.source.text.toDouble()); })) } } frame.show() model.initialize([1.0, 0.83, 0.56]);
    31. 34. First Class Containers <ul><li>Boils down to </li></ul><ul><ul><li>Easy construction syntax </li></ul></ul><ul><ul><li>Methods that take closures and perform common operations. </li></ul></ul><ul><ul><ul><li>find (returns first value it finds that matches) </li></ul></ul></ul><ul><ul><ul><li>findAll (returns collection of all matches) </li></ul></ul></ul><ul><ul><ul><li>every (boolean valued check on collection) </li></ul></ul></ul><ul><ul><ul><li>each (iterates through collection and hands elements to closure) </li></ul></ul></ul><ul><ul><ul><li>collect (changes collection) </li></ul></ul></ul>
    32. 35. weekMap = [ &quot;Su&quot; : &quot;Sunday&quot;, &quot;Mo&quot; : &quot;Monday&quot;, &quot;Tu&quot; : &quot;Tuesday&quot;, &quot;We&quot; : &quot;Wednesday&quot;, &quot;Th&quot; : &quot;Thursday&quot;, &quot;Fr&quot; : &quot;Friday&quot;, &quot;Sa&quot; : &quot;Saturday&quot; ] weekMap.each() { key, value -> println &quot;${key} == ${value}&quot; }
    33. 36. Gafter’s Def’n of Closure <ul><li>A closure is a function that refers to free variables in its lexical context </li></ul><ul><li>A function is a block of code with parameters. It may produce a result value </li></ul><ul><li>A free variable is an identifier used but not defined by the closure </li></ul>
    34. 37. In Practice <ul><li>A closure is a function pointer that knows all the variables that were in scope when it was defined </li></ul><ul><li>Can be passed around as an argument </li></ul><ul><li>Can be called at any time. </li></ul>def foo = { a,b,c -> bunch of code} foo(“e”, “f”, “g”)
    35. 38. Inner Classes are Close! <ul><li>Java solution: Define an anonymous inner class that implements a well-known interface </li></ul><ul><li>But </li></ul><ul><ul><li>Because they’re classes, they don’t quite behave the same way </li></ul></ul><ul><ul><li>Involve a lot more (physical) typing </li></ul></ul>
    36. 39. Don’t believe me? Neal likes Java a LOT more than I do
    37. 40. XML Support <ul><li><interactive example with groovy console> </li></ul>def CAR_RECORDS = ''' <records> <car name='HSV Maloo' make='Holden' year='2006'> <country>Australia</country> <record type='speed'>Production Pickup Truck with speed of 271kph</record> </car> <car name='P50' make='Peel' year='1962'> <country>Isle of Man</country> <record type='size'>Smallest Street-Legal Car at 99cm wide and 59 kg in weight</record> </car> <car name='Royale' make='Bugatti' year='1931'> <country>France</country> <record type='price'>Most Valuable Car at $15 million</record> </car> </records> ''' def records = new XmlSlurper().parseText(CAR_RECORDS) def allRecords = records.car println allRecords.size() println records.car[0].name() println records.car[0].@year println records.car[0].country
    38. 41. XML Support II <ul><li>XMLBuilder </li></ul><ul><li>Will be discussed in detail after MetaObject Protocol section </li></ul>
    39. 42. Rapid Prototyping: Scripts, Shell and Console <ul><li>Scripts – groovy doesn’t need to use classes. </li></ul><ul><ul><li>SwingBuilder example a few slides ago didn’t use classes for the executable bits. </li></ul></ul><ul><li>groovysh – command line shell (seen a few slides ago) </li></ul><ul><li>Groovyconsole – swing GUI for playing with scripts </li></ul><ul><ul><li>Supports cut and paste better than command line </li></ul></ul>
    40. 43. Metaobject Protocol <ul><li>A metaobject protocol (MOP) is an interpreter of the semantics of a program that is open and extensible. Therefore, a MOP determines what a program means and what its behavior is, and it is extensible in that a programmer (or metaprogrammer ) can alter program behavior by extending parts of the MOP. The MOP exposes some or all internal structure of the interpreter to the programmer. The MOP may manifest as a set of classes and methods that allow a program to inspect the state of the supporting system and alter its behaviour . MOPs are implemented as object-oriented programs where all objects are metaobjects. </li></ul><ul><li>Thanks Wikipedia ! </li></ul>
    41. 44. MetaObject Protocols: The Point <ul><li>At runtime, can find out about, and alter, class definitions </li></ul><ul><ul><li>Add or remove methods </li></ul></ul><ul><ul><li>Dynamically change implementations of methods </li></ul></ul><ul><ul><li>Handle “no such method” at the recipient, not the caller </li></ul></ul><ul><li>Groovy </li></ul><ul><ul><li>invokeMethod </li></ul></ul><ul><ul><li>ExpandoMetaclass </li></ul></ul><ul><ul><li>propertyMissing </li></ul></ul><ul><ul><li>methodMissing </li></ul></ul>OPINIONS VARY AS TO WHETHER ALLOWING THIS SORT OF THING IS A GOOD IDEA!!!!
    42. 45. Chris will talk more about GORM later on
    43. 46. Builders <ul><li>Lots and lots of things are tree-like data structures </li></ul><ul><ul><li>User interfaces (structure of Swing components) </li></ul></ul><ul><ul><li>HMTL Documents (XML documents) </li></ul></ul><ul><ul><li>Invoices have line items … </li></ul></ul><ul><li>Big-Ass Completely Unsupported Claim: Every DSL is a tree-like data structure + an interpretation. </li></ul><ul><ul><ul><ul><ul><li>Or Should Be! </li></ul></ul></ul></ul></ul>
    44. 47. What’s Martin Fowler been doing since the refactoring book anyway?
    45. 49. How to Build a Builder <ul><li>Implement a (Java!) subclass of BuilderSupport </li></ul><ul><li>Or just use methodMissing </li></ul><ul><ul><li>It’s really what the Java’s doing anyway. </li></ul></ul>protected abstract Object createNode(Object name) protected abstract Object createNode(Object name, Map attributes) protected abstract Object createNode(Object name, Map attributes, Object value) protected abstract Object createNode(Object name, Object value) protected abstract void setParent(Object parent, Object child) Groovy is designed to work with Java.
    46. 50. MarkupBuilder import groovy.xml.MarkupBuilder def writer = new StringWriter() def xml = new MarkupBuilder(writer) xml.records() { car(name:'HSV Maloo', make:'Holden', year:2006) { country('Australia') record(type:'speed', 'Production Pickup Truck with speed of 271kph') } car(name:'P50', make:'Peel', year:1962) { country('Isle of Man') record(type:'size', 'Smallest Street-Legal Car at 99cm wide and 59 kg in weight') } car(name:'Royale', make:'Bugatti', year:1931) { country('France') record(type:'price', 'Most Valuable Car at $15 million') } } println writer.toString()
    47. 51. Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation (2003 Recap) </li></ul><ul><li>“ Improving” the Language: Groovy </li></ul><ul><li>Improving the Framework: Grails </li></ul><ul><li>Some Actual Code </li></ul>
    48. 52. Rails as a Thunderbolt <ul><li>Convention over configuration </li></ul><ul><ul><li>Kind of like design patterns, except there’s only one pattern </li></ul></ul><ul><li>ActiveRecord simplifies DB access </li></ul><ul><li>Migrations simplifies DB upgrades </li></ul><ul><li>Capistrano simplifies deployment </li></ul><ul><li>Plugin architecture (framework as platform) </li></ul><ul><li>Ruby as the base language </li></ul>
    49. 53. The Rails guys invented the “movie to demo the framework” idea and their movies are still WOW OH WOW GOOD
    50. 54. <ul><li>PHP </li></ul><ul><li>PHP </li></ul><ul><li>Java (Coldfusion) </li></ul><ul><li>PHP </li></ul><ul><li>.NET </li></ul><ul><li>Perl </li></ul><ul><li>PHP </li></ul><ul><li>Java </li></ul><ul><li>.NET </li></ul><ul><li>PHP </li></ul><ul><li>Java </li></ul><ul><li>Java </li></ul><ul><li>PHP </li></ul><ul><li>Java </li></ul><ul><li>PHP </li></ul><ul><li>Ruby </li></ul><ul><li>Perl </li></ul><ul><li>Java </li></ul><ul><li>Java </li></ul><ul><li>PHP </li></ul>PHP: 8 Java: 7 .NET: 2 Perl: 2 Ruby: 1
    51. 55. In 4 years, Rails has made very impressive strides. Market leader in the “early stage startup” category.
    52. 56. Issues with Ruby <ul><li>Powerful language, currently in flux </li></ul><ul><ul><li>Transition from 1.8 to 1.9 is slow and painful </li></ul></ul><ul><li>Not clear what the language definition is </li></ul><ul><li>Syntax is awful. Like a modified PERL with additional incomprehensibility </li></ul><ul><ul><li>Okay, that was biased. </li></ul></ul><ul><li>The standard implementation is low performance and fragile </li></ul>
    53. 57. Backwards compatibility is not a huge priority
    54. 58. Backwards compatibility is not a huge priority
    55. 59. This is scary
    56. 60. Of course, Java is mostly developed by Sun ….
    57. 61. This is from a Ruby guy who doesn’t like JRuby very much …
    58. 62. Issues with Rails <ul><li>Focus on CRUD </li></ul><ul><ul><li>Works very well for the standard web architecture </li></ul></ul><ul><ul><li>Good for building standalone applications </li></ul></ul><ul><ul><ul><li>Integration scenarios not well supported </li></ul></ul></ul><ul><ul><ul><li>Legacy code not well supported </li></ul></ul></ul><ul><li>Far fewer man hours of development, qa, or deployment experience than many other frameworks </li></ul><ul><ul><li>Compare to Spring, for example </li></ul></ul>
    59. 63. Grails is “Groovy on Rails” <ul><li>Adopt many, if not all, of the key ideas of Rails </li></ul><ul><ul><li>Swap out Ruby for Groovy </li></ul></ul><ul><ul><li>Swap out Rails for Spring, Hibernate, SiteMesh, and lots of glue </li></ul></ul><ul><li>Application code is written in Groovy </li></ul><ul><ul><li>With “drop into Java for performance” drop-dead easy </li></ul></ul><ul><li>Leverage JVM + Java libraries for the infrastructure </li></ul>
    60. 64. Pieces / Parts <ul><li>GSP – “Groovy Server Pages” </li></ul><ul><ul><li>A lot like JSP </li></ul></ul><ul><li>GORM – “Groovy Object Relational Mapping” </li></ul><ul><ul><li>Hibernate + Bionicness. Really impressive. </li></ul></ul><ul><li>Core abstractions: </li></ul><ul><ul><li>Domain classes </li></ul></ul><ul><ul><li>Controllers </li></ul></ul><ul><ul><li>Views </li></ul></ul><ul><ul><li>Services </li></ul></ul>More on these later
    61. 65. GORM <ul><li><<Chris– a world class expert in GORM>> </li></ul>
    62. 66. Plugins and Extensability <ul><li>Grails is a platform for extensions </li></ul><ul><li>Makes a lot of sense given the point is to build a Rails that leverages Java </li></ul>
    63. 67. SWAG Estimate: About ¾ of plugins are mentioned here (BIRT, for example, is not)
    64. 68. Outline <ul><li>Who Am I / Standard Caveats </li></ul><ul><li>Java as the Foundation </li></ul><ul><li>“ Improving” the Language: Groovy </li></ul><ul><li>Improving the Framework: Grails </li></ul><ul><li>Some Actual Code </li></ul>
    65. 69. Twofish Model TFEL TFEL DB TFEL DB <ul><li>JBoss 4 on Java 6. </li></ul><ul><li>Everything clustered </li></ul><ul><li>Everything replicated </li></ul><ul><li>SOAP </li></ul><ul><li>Fat client SDK </li></ul>PS <ul><li>Layered apps </li></ul><ul><li>In our data center </li></ul><ul><li>Customer specific </li></ul><ul><li>Lightweight frameworks rock </li></ul>
    66. 70. <<IntelliJ>>
    67. 71. Annoyances (Love Mashup) <ul><li>Mainly from my incompetence with HTML. </li></ul><ul><li>Also: imperfect prototyping environment </li></ul><ul><ul><li>Changes in controllers and views reflected immediately </li></ul></ul><ul><ul><li>Changes in domain models often require restarting dev server </li></ul></ul><ul><ul><li>Changes in services or supporting code almost always require a dev server restart </li></ul></ul>
    68. 72. Plugins (Love Mashup) <ul><li>Cloud Foundry – easy deploy to Amazon </li></ul><ul><li>YUI – cleaner UI components </li></ul><ul><ul><li>To be honest, I used OSWD for the layout </li></ul></ul>
    69. 73. Annoyances (Twofish) <ul><li>Oddly enough, the Java stack </li></ul><ul><ul><li>JDK has an XML Parser </li></ul></ul><ul><ul><li>Grails has a copy of Xerces </li></ul></ul><ul><ul><li>Twofish Client SDK has a copy of Xerces </li></ul></ul><ul><ul><li>Endorsed directories are painful </li></ul></ul><ul><ul><ul><li>We can’t use the standard deployers </li></ul></ul></ul><ul><li>Intellij not yet supporting Grails 1.1 or Groovy 1.6 </li></ul>
    70. 74. Plugins (Twofish) <ul><li>Quartz plugin – Background processing </li></ul><ul><li>BIRT plugin – Enterprise class reports </li></ul><ul><li>Xfire plugin – makes handling SOAP requests trivial </li></ul>
    71. 75. Additional Reading
    72. 76. This is a great series of articles. Whenever anyone tells you a technology is going to be big, ask yourself: WWTT?

    ×