Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Java

Mastering the Grails Powerful Tiny Web Framework 89

Someone from IBM tips this article on their Developerworks site about Grails, a modern Web development framework that mixes familiar Java technologies like Spring and Hibernate. "Grails gives you the development experience of Ruby on Rails while being firmly grounded in proven Java technologies. This article show you how to build your first Grails application with the lessons learned from Rails and the sensibilities of modern Java development."
This discussion has been archived. No new comments can be posted.

Mastering the Grails Powerful Tiny Web Framework

Comments Filter:
  • Someone from IBM tips this article on their Developerworks site about Grails, a modern Web development framework that mixes familiar Java technologies like Spring and Hibernate.

    "Grails gives you the development experience of Ruby on Rails while being firmly grounded in proven Java technologies. This article show you how to build your first Grails application with the lessons learned from Rails and the sensibilities of modern Java development."
  • by tcopeland ( 32225 ) <(tom) (at) (thomasleecopeland.com)> on Saturday January 26, 2008 @07:16PM (#22196894) Homepage
    ...getting interviewed about Groovy here [javaworld.com].

    There's some other good stuff there too, although the interview with Dr. Stonebreaker about column-oriented storage is kind of light on technical detail.
  • by Anonymous Coward
    I've heard that while the true Grail will bring you life, the false one will take it from you.
  • by filbranden ( 1168407 ) on Saturday January 26, 2008 @08:23PM (#22197254)

    It seems that Rails set a milestone for development frameworks, and nowadays everything new has to be based or inspired or copied from Rails. Seems that Rails really made a breaktrough there, in fact, it seems to be responsable for most of Ruby's popularity. Rails has been translated several times to other languages, like Python (Django, also TurboGears to a lesser extent) and Java (Groovy to a lesser extent, now Grails that it's a ripoff even on the name).

    This makes me think that sometime ago the buzzword of the moment was J2EE, and everything everyone made had to be J2EE compliant. Even C# and .NET was a big Microsoft ripoff of Java and J2EE to fight against the big migration of programmers to Java.

    Which leads me to the fact that soon the buzz around Rails will be over, as much as nobody creates a new J2EE-based framework, now everything is taken for granted. So, what will be the next milestone? The next technology that will have people talking? Have everyone trying to clone its own?

    • by Shados ( 741919 ) on Saturday January 26, 2008 @08:52PM (#22197384)
      Who knows. The thing with Rails though, is that it brought a bunch of technologies that were big standards in the enterprise world, and packaged it as one...

      Its not much more than an MVC framework, an OR Mapper, and a 4th Gen tool wrapped as one... But in many circles, like in the PHP world, or in the more hobbyist groups of the other platforms, these things were not known. Basically, the people that browsed internet forums weren't used to it, and Rails brought it to them ine one buzzword compliant package... Its still not very special...

      So now, you have a bunch of frameworks in Python, PHP, .NET, or Java, that were really just derivative of the J2EE-based world, package themselves, tweak one or two "conventions", and change their name to BlahRail... but the tool is really the same as it used to be. Its just more buzzworld compliant now.

      So I guess Rails did set a milestone. A "buzzy" one. My current employer trips in his feet all over Rails (we're a .NET shop), and every few days shows me yet another "OMG!" feature of Rail...that actually was already implemented in our main product long before that buzzword came out... Oh, aside ActiveRecord::Migration. That we actually added after Rail. Thank god it brought to light that hugely complex and powerful feature! (That took exactly 6 hours to reimplement)
      • AJAX.

        Not that AJAX is a bad idea, but that it needed a word. And that word irritates the hell out of those of us who knew it as DHTML, or simply as Javascript.

        Or, how's this: "Blog".

        It's a journal, or it's a column. Either way, the only thing that makes it special is that it's on the Internet.

        Or how about this: "Myspace".

        This one makes me absolutely livid. It's Geocities 2.0, and you can just hear the resounding SMACK of a million programmers at once wondering why they didn't do it first. Not "think of it",
        • by Shados ( 741919 ) on Saturday January 26, 2008 @10:12PM (#22197726)

          and you can just hear the resounding SMACK of a million programmers at once wondering why they didn't do it first
          Here's where its different. With Rails, you have thousands of hobbyist and wannabes going "Why the hell didn't I think of that?!?!", and the rest of us looking at our existing frameworks going "Check...check...check...OH WAIT I don't have this...oh wait, I didn't WANT it because last time we tried we lost a 5 million$ in wasted time.... check...check....hrm...so what is it exactly?"

          Again, I remember bursting out laughing when my boss bragged about how superior Rails was because it had... a unit testing framework! "We don't have to make our own! It can even generates the base unit tests!!!!. Oh, and it can actually handles the Data Access Layer on its own!!!".

          Or the priceless one: "Rail puts MVC on the map!". I mean, thats even WORSE than your Ajax example.... its like if 3 years from now some framework came out with Ajax, and everyone thought it made Ajax mainstream... MVC has been a buzzword (and an overrated one) for so long, I've been wanting to cry even BEFORE Rail...

          Rails is definately great stuff, not saying any different... but really, it only makes a buzz among people who didn't know much before... At least Ajax mainstreamed async http requests in javascript (even though we were doing it in 2001ish here, we didn't have all the ajax framework available and had to do it on our own...but what Rails offer...we haven't had to do it for almost a decade...)
          • With Rails, you have thousands of hobbyist and wannabes going "Why the hell didn't I think of that?!?!", and the rest of us looking at our existing frameworks going "Check...check...check...OH WAIT I don't have this...oh wait, I didn't WANT it because last time we tried we lost a 5 million$ in wasted time....

            Maybe that happened with AJAX, too. But like Rails, it's possible (though not necessarily easy) to leave out the parts you like.

            Example: Call it "AJAX", use that style of programming, but use JSON ins

    • *cough* (Score:3, Interesting)

      by Balinares ( 316703 )
      > Rails has been translated several times to other languages, like Python (Django...)

      Absolutely not. Django preexisted the Rails buzz by years (it was an internal application at LJworld initially), and one of the reasons it's so good is that, unlike many, it is precisely not trying to mimic Rails.

      That doesn't invalidate your point, though. I just thought I'd point it out, because, you know, to reach the next milestone, you first need to stop targetting the current one, and as you point out, not many are
      • by catch23 ( 97972 )
        I don't know why Django is compared with Rails here. Normally Pylons would be compared with Rails. Pylons would be the "rails" equivalent in python. Pylons was created after the whole rails thing unlike django...
  • Grails? (Score:5, Funny)

    by Loconut1389 ( 455297 ) on Saturday January 26, 2008 @08:57PM (#22197402)
    I guess they didn't want to call it Jails?
    • by jo42 ( 227475 )
      At least they didn't call it Jrails.

  • Our apologies

    The IBM developerWorks Web site is currently under maintenance.

    Please try again later.
  • Fail (Score:1, Flamebait)

    by Wiseman1024 ( 993899 )
    This sounds like a poor man's Rails. Why would I want to develop smartly using such a limited, powerless, unexpressive language? All the productivity you could want gets lost by working with Java and its bloated, overengineered, god awful API and toy object model that gets forced upon you all the time.

    The sensibilities of modern Java development? What a poetic way to say "we've dumbed it down and made it a living toy-OOP hell". Besides, modern Java development is usually Google code search copypasta with so
    • Agreed--I'd subscribe to your newsletter. Java is a major scourge of the industry.
    • ... except when it doesn't. Java doesn't have to be over engineered,and I would hardly call its object model a toy ( cough perl/php objects are toys cough cough). Now is Java overkill for your simple blog app demo thats done so quickly in rails? Probably. You know right tool right project.
      • by chromatic ( 9471 )

        Java doesn't have to be over engineered,and I would hardly call its object model a toy ( cough perl/php objects are toys cough cough).

        I'm not an expert on PHP objects, but Perl objects are typesafe through collections, they do support dynamic invocation, and they do support the method missing operation.

        Are you claiming that Java's lack of those features makes it not a toy?

        • I was thinking of method overloading specifically when I wrote that comment without thinking too much about it. I'll let you take up the Toy label with the good folks at Sun, IBM, or Apache.
      • Re: (Score:2, Interesting)

        by Wiseman1024 ( 993899 )
        Java has to be overengineered, because you need to use its API (or rework it all from scratch). Its object model is a toy: it lacks countless of features such as multiple inheritance, mixins, dynamic modification, parametric polymorphism, functional properties, introspection, operator overloading, and the list goes on and on. If you want an example of a non-toy object model, i.e. one that doesn't get in your way, but actually allows you to build powerful abstractions, supplant builtins and reuse code that m
        • by Raenex ( 947668 )

          If you want an example of a non-toy object model, i.e. one that doesn't get in your way, but actually allows you to build powerful abstractions, supplant builtins and reuse code that might even not yet exist, take a look at Python's.

          Python is dynamically typed -- all that flexibility comes at a price. Where's the compiler-checked documentation in Python? Where's the keystroke or mouse-click to get to the implementation? To find all references? To rename things? For auto-completion?

          Where's the IDE that finds errors while I'm typing?

          • Re: (Score:2, Insightful)

            by Wiseman1024 ( 993899 )

            Where's the compiler-checked documentation in Python?

            It's supposed those using Python seriously aren't supposed to need that kind of babysitting.

            Where's the keystroke or mouse-click to get to the implementation?

            What? That's not a feature of Python, nor Java, nor any language that I know of. You are talking about editors. And again, there's a point to make: a good language shouldn't require any special editor features because it's a mess. You can edit large Python programs with anything you want, as it never gets as bloated and complicated, and the abstraction capabilities are much better.

            Back to the language, can you in J

            • by Raenex ( 947668 )

              It's supposed those using Python seriously aren't supposed to need that kind of babysitting.

              One man's productive facilities are another man's "babysitting". Of course the C++ guys talk like this too, and would say the same thing about Python when it comes to stuff like garbage collection. Engineering is all about tradeoffs.

              You are talking about editors.

              Static typing makes the stuff I'm talking about easy to implement.

              You can edit large Python programs with anything you want, as it never gets as bloated and complicated, and the abstraction capabilities are much better.

              There is no limit on complexity, and even for a small project it's nice to have easy one-click access to stuff instead of grepping through code or poking around documentation.

              Renaming symbols is as easy in Python as it would be in Java, only that you don't even have to go through all of it if you want something renamed just for you.

              I frequently find better names f

          • Re: (Score:3, Informative)

            by leighklotz ( 192300 )
            > Where's the keystroke or mouse-click to get to the implementation?
            EMACS and tags; Meta-.
            > For auto-completion?
            EMACS and dabrev; I bind it to Meta-Space.

            > Where's the IDE that finds errors while I'm typing?
            EMACS and flymake; It works for Java, PHP, perl, python, etc.

            Here are screenshots of it working with python, all candy-colored for your editing pleasure, with mouseovers or minibuffer reports of errors as you type:

            http://blog.printf.net/articles/2007/10/15/productivity-a-year-on [printf.net]
            • by Raenex ( 947668 )
              Looks spiffy, but I have my doubts when it comes to the dynamic typing of Python. For example, looking at the screenshot, could I click on the "buildscript" parameter and go to its definition? Inside the def, could I type buildscript.set<auto-complete>, and get only the completions that apply to whatever buildscript is? Or does it put all the names into one big namespace?
    • Re:Fail (Score:5, Insightful)

      by fireboy1919 ( 257783 ) <rustyp@@@freeshell...org> on Sunday January 27, 2008 @01:35AM (#22198524) Homepage Journal
      Couple of things:
      toy object model that gets forced upon you all the time
      1) Hibernate makes Active Record look like a toy. If you have to deal with database systems that don't fit all the constraints of active record, you're pretty much out of luck. Not so with Hibernate. Hibernate basically converts a relational database into an object oriented database because of the availability of HQL. It's very different from just getting an OOP API on top of a relational database - which is essentially what Active Record is.

      Incidentally, if you've got legacy data with a compound key, how hard is that to deal with in Rails? It's pretty easy with Hibernate. (hint: extremely difficult)

      2) Spring eliminates glue more than anything else. Inversion of control is an advanced concept to do this, and unless your system has something like it, you have to write glue code (usually in your controller). There is nothing I know like it for any other language (ironically, there are several Java projects that do this. That alone makes it worth using languages that compile to Java bytecode even if you aren't using Java.

      Those are the modern sensibilities - design patterns that haven't yet caught on in any other language.
      As to the bloated, overengineered bit, I'm not entirely sure what you're referring to. Why don't you tell the whole class?

      3) This sounds like a poor man's Rails.

      More like a rich man's rails - where "rich" means "well educated in design pattern theory." For that matter, Java projects tend to be better funded and less buggy than rails projects, so rich man's rails probably fits in the traditional sense of "rich."
      • by chromatic ( 9471 )

        There is nothing I know like [Inversion of Control] for any other language...

        I'm not sure if you mean "I only know Java", "I didn't know that IoC is a 20 year old pattern", "I don't know that IoC and event-driven programming are almost completely isomorphic", or something else. Can you elaborate?

        • "I only know Java"
          I've used 14 languages and counting for development projects, including at least one of each of the interesting language types I know about (script, HDL, functional, pure imperative, assembly, compiled, bytecode compiled, purely graphical), . Ruby is among them. If you know another language or VM that gives IoC capability, why not share with the whole class? Java is heavy for my development tastes, and if I could get IoC in a 5MB footprint, I'd be all over that language.

          "I didn't know t
          • I've used 14 languages and counting for development projects, including at least one of each of the interesting language types I know about (script, HDL, functional, pure imperative, assembly, compiled, bytecode compiled, purely graphical), . Ruby is among them. If you know another language or VM that gives IoC capability, why not share with the whole class?

            It would probably be shorter to list the languages that don't give IoC capability; just about every modern language does that. Whether a particular fra

          • by catch23 ( 97972 )
            wow, has the computer been around for 80 years already? Unless you're talking about OOP in God's language, in which case OOP existed the day organisms existed and were capable of creating proteins via RNA.
      • More like a rich man's rails - where "rich" means "well educated in design pattern theory."

        I was going to reply with something else, but this just made my day. Are all Java programmers this funny?

        Tip: "Design patterns" are circle-jerk material for Java copypast- I mean programmers. "Design patterns" are fundamentally wrong. If you see a pattern of *any* kind, you need to make it a function, a macro, or some other kind of abstraction, not copypasta it over and over. And if your language does not allow you to do this, then you need to look for a better language.

        (In a way, this modern jerk off of d

        • You seem to have an awful lot of angst and misguided ideas about java development. Did James Gosling touch you in your 'no-no' spot when you were a kid? You also either aren't grasping the concept of design patterns, or you're not capable of adequately communicating your ideas.
          • It's hilarious how you keep talking about design patterns after I've pointed out that they're just glorified copypasta Java programmers jerk off to (and add to their immense collection of buzzwords). And it's not just their fault Java is full of copypasta wankery - the language is far too much of a toy to allow enough abstraction to turn them into library elements.
            • You're obviously too ignorant to have any sort of real conversation with. The message you replied to was the first one I've written in this thread. You also seem to love the phrase "copypasta". It sounds ludricous. Seriously, stop.
              • "You" can also refer to several people. For example, "You java programmers".

                And... copypasta! Copypasta! Copypasta! I hope it's annoying enough; this way you'll feel worse the next time you need to copypasta some "professional best-practices scalable enterprise business design pattern". I'm tired of having to maintain crappy code that needs to be modified in the same way in several different places because they didn't generalize (or the language didn't allow generalizing) properly.
                • You're obviously either a child or socially retarded. Either way, you still don't grasp the concept of design patterns. You're crying about shitty programming, not design. Go read "Design Patterns: Elements of Reusable Object-Oriented Software," then come back and perhaps we can have a real conversation.
      • ..."well educated in design pattern theory."

        Stop hyping design patterns so much (you and the rest of the world, because I've been seeing it showing up on resumes more and more). The patterns themselves don't matter. Nobody cares if something uses 13 different design patterns to get a job done. They care about understanding how a system works, and design patterns provide the necessary vocabulary to talk about it, nothing more.

    • by Zarf ( 5735 )

      All the productivity you could want gets lost by working with Java and its bloated, overengineered, god awful API and toy object model that gets forced upon you all the time.

      Um, Grails works with Groovy not Java. Groovy does Functional Programming [codehaus.org] stuff like code currying [wikipedia.org]:

      def joinTwoWordsWithSymbol = { symbol, first, second -> first + symbol + second }
      assert joinTwoWordsWithSymbol('#', 'Hello', 'World') == 'Hello#World'

      def concatWords = joinTwoWordsWithSymbol.curry(' ')
      assert concatWords('Hello', 'World') == 'Hello World'

      def prependHello = concatWords.curry('Hello')
      // def prependHello = joinTwoWordsWithSymbol.curry(' ', 'Hello')
      assert prependHello('World') == 'Hello Worl

    • This sounds like a poor man's Rails.


      Its almost exactly the opposite: its more of Rails, repackaged to appeal to enterprise users.

      Why would I want to develop smartly using such a limited, powerless, unexpressive language?


      What makes you say that Groovy is a "limited, powerless, unexpressive language"?
  • Bah! I want to write my own DAOs, and worry about customising each one for different backend databases because their JDBC implementations handle things differently, never mind the SQL differences!

    Actually at least you are in control when you do that. Somebody else's programming and database schema paradigm are quite often quite different from your own. It is good for everyone to have to all the parts so that they know how it works. Sure, they might use an off-the-shelf framework later on, but they need to k
    • Everybody seems to rave about how great these new frameworks are, but they don't do a lot of things that are important at the enterprise level. One thing you mentioned was accessing the data layer from some other application. They came up with n-tier architecture a long time ago because it made a lot of sense. Put all your data access in 1 component, all your business logic in another component, and put your presentation logic in a third component. That way, if you want to access your data or business l
    • by Shados ( 741919 )

      Bah! I want to write my own DAOs, and worry about customising each one for different backend databases because their JDBC implementations handle things differently, never mind the SQL differences!

      Besides, on top of everything you said, there ARE things like Hibernate...your own schema, and no need to worrie about the JDBC stuff! And I don't know about Hibernate, but many similar tools will handle stored procedures just as cleanly to boot, so it will even work at the enterprise level.

      • by hattig ( 47930 )
        I'll grant Grails one thing - having read the documentation - it does allow you to specify the database mappings within the "class" that you write. I once worked with JDO and the mappings from the model to the database were done in the motherf*cker of XML files, and the automated schema it generated was pretty damn dire if you wanted to work in the psql command line.

        Note that I think that a good developer - in any language - should also be a good database architect and be able to create a good schema with i
        • by Shados ( 741919 )

          it does allow you to specify the database mappings within the "class" that you write

          Yeah, once upon a time that was the more common way of doing it, and most homebrew OR mappers used that (since its a lot easier to code really). As far as I can tell, the issue with that comes from separation of concern and dependency injections and all that.

          If you want to change the class, you need to have the mapping redone too. A nice in between, for example, in the .NET World is LLBLGEN Pro. The mapping is computed

  • If you're at all interested in Groovy or Grails, see Scott in person. His writing is good, but his speaking is better (obviously imo). He exudes an enthusiasm for and mastery of the subject which is lacking in many speakers in the tech circuit these days.
  • IBM's dW website always goes down Saturday evening for maintenance. I think it goes down a little early, but it's always down for at least some time.
  • Grails... (Score:1, Interesting)

    by Anonymous Coward
    So one day several years ago the suits came to me and told me I had to stop using Perl and start using Java. It was hell. I lived in J2EE hell, JSF hell, Portlet hell, Workflow engine hell, Seam hell, then I spent some time with EJB3 and that felt less like hell.

    Then the clouds parted, the angels sang, and there before me stood Groovy and Grails.

    Groovy is pure joy in a bucket. It was so much less painful to transition to Groovy. Grails made so much more sense than JSF and Seam. Jetty was so much easie
  • I have long been awaiting for something like this. Having all the server functionality in a small java framework I will definitively give it a try.. http://www.developeronline.blogspot.com/ [blogspot.com]

It is not best to swap horses while crossing the river. -- Abraham Lincoln

Working...