Re: Groovy and Grails vs. Java for Web Interface (see Java web applicationframeworks / architecture)

Discussion in 'Java' started by markspace, Sep 22, 2009.

  1. markspace

    markspace Guest

    Kenneth P. Turvey wrote:
    > When compared to
    > technologies like JSF, grails really eases web development



    I know almost nothing about Grails or Groovy. Could you justify this
    statement for me? What's "easier" about G&G? Maybe with some code
    examples you've written, since we're all about SSCCEs here.
     
    markspace, Sep 22, 2009
    #1
    1. Advertising

  2. markspace

    ck Guest

    Re: Groovy and Grails vs. Java for Web Interface (see Java webapplication frameworks / architecture)

    On Sep 23, 3:40 am, Stefan Weiss <> wrote:
    > On 22/09/09 21:24, markspace wrote:
    >
    > > Kenneth P. Turvey wrote:
    > >> When compared to
    > >> technologies like JSF, grails really eases web development

    >
    > > I know almost nothing about Grails or Groovy.  Could you justify this
    > > statement for me?  What's "easier" about G&G?  Maybe with some code
    > > examples you've written, since we're all about SSCCEs here.

    >
    > I would also be interested to hear about first-hand experiences with
    > Grails. From what I can see, it's not too different from (Ruby on)
    > Rails, and I had a hard time understanding the hype about that, too. I
    > can certainly see the appeal of Groovy (a dynamic language with support
    > for constructs like closures, which compiles to JVM bytecode and can
    > integrate with any existing Java library? sounds great), and I would
    > definitely like to try it out in a project. As for Grails... one of the
    > "killer features" of this sort of framework is that it will generate all
    > the basic CRUD methods for you from the database structure. As useful as
    > that sounds, I've yet to see a (reasonably complex) database where
    > auto-generated methods could possibly do what we need (most of the time,
    > there are several layers between the controller and the data storage).
    > The same goes for the built-in Ajax components - as soon as you require
    > anything beyond the basic actions, you might as well write it yourself.
    >
    > I've talked to some people who told me that Rails has cut their
    > development time in half, and I've also read reports from developers who
    > reverted to their original frameworks, because they found that they
    > constantly had to work around/against Rails [0].
    >
    > cheers,
    > stefan
    >
    > [0] Random example, Derek Sivers from CDBaby:
    > <http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back...>


    I would agree with Stefan on most of the points mentioned, choosing
    Grails or RoR would matter the most on complexity of the application
    that you are building. Second point, how much of experience or well
    versed you are with the tool that you are using. If you foist a Java
    developer to build application in RoR, Grails or any other dynamic
    language, it would depend a lot on his ability to adapt to "dynamic
    language". If a developer does not adapt to the changed environment he
    might not be taking benefits of dynamic language.
    My experience so far has been quite pleasant with RoR. Few things
    thats easy in RoR (might not be best performance wise) and might be
    applicable to Grails as well
    - Model maps to database columns, you don't map them in the code or
    configuration, "if you stick to conventions its even easier"
    - Defining relationship in models much easier than in Hibernate or any
    other Java ORM, "if you stick to conventions"
    - Its faster to check code change on running server, i.e is you made
    some change in controller you don't have to restart the server, (could
    be achieved in Java using something like java rebel).
    - Database migrations far better than any "Java web application
    framework"
    - Conventions far better than any of the "Java web application
    framework" I have come across so far
    - Simple applications can be developed very fast as compared to Java
    web application frameworks.
    - Code generation is a great help as it generates skeleton code and in
    appropriate locations, most of the Java web application framework lack
    in that. I am not saying that Code generation capability is going
    build "entire application" but it cuts down on developers time to
    navigate to folders creating files etc.
    - I personally feel that RoR/Grails is much structured and have well
    defined strategy regarding what file goes where
    - Build (Rake) is much efficient than most of the counterparts.

    I am not saying all this cannot be achieved in Java, albeit is there
    any framework in Java which does all this?
    As it would be true for any platform, if you are well versed with RoR,
    most of the tasks required in web application can be done faster in
    terms of "development time". That's not just because of RoR/Grails as
    a framework, but due to nature of dynamic language. Java is bound to
    be verbose and if you are choosing Java then you need to be prepared
    to write lots and lots of code and configuration. If you choose RoR/
    Grails, remember that it's much younger to its Java counterpart and
    you might not find as many API as you find in Java.
    --
    Ck
    http://www.chandankumar.com
     
    ck, Sep 24, 2009
    #2
    1. Advertising

  3. markspace

    Lew Guest

    Re: Groovy and Grails vs. Java for Web Interface (see Java web applicationframeworks / architecture)

    ck wrote:
    > - Defining relationship in models much easier than in Hibernate or any
    > other Java ORM, "if you stick to conventions"


    I could have believed that modeling relationships is easier in Ruby on Rails
    than in Hibernate or other ORM frameworks, but "much easier"? No.

    Vanilla foreign keys in Java are a one-word annotation in an entity class:
    @OneToMany, for example. (That it's an entity class requires one more word:
    @Entity.) The only thing easier than that would be for the code to figure out
    for itself that it connects to a database, and to infer the relationships for
    you, but even such as that would not be "much" easier.

    --
    Lew
     
    Lew, Sep 24, 2009
    #3
  4. markspace

    Lew Guest

    Re: Groovy and Grails vs. Java for Web Interface (see Java web applicationframeworks / architecture)

    ck wrote:
    > - Its faster to check code change on running server, i.e is you made
    > some change in controller you don't have to restart the server, (could
    > be achieved in Java using something like java rebel).


    Also achievable in Tomcat, for example.

    > - Database migrations far better than any "Java web application
    > framework"


    Please explicate. What are the differences, and how is Ruby on Rails (RoR)
    "better"?

    > - Conventions far better than any of the "Java web application
    > framework" I have come across so far


    Please explicate.

    > - Simple applications can be developed very fast as compared to Java
    > web application frameworks.


    I'm sure RoR is fine for simple applications.

    > - Code generation is a great help as it generates skeleton code and in
    > appropriate locations, most of the Java web application framework lack
    > in that. I am not saying that Code generation capability is going
    > build "entire application" but it cuts down on developers time to
    > navigate to folders creating files etc.


    That's a toolkit difference, not a language difference. There are Java
    toolkits that generate code, including both Eclipse and NetBeans.

    > - Build (Rake) is much efficient than most of the counterparts.


    What do you mean by "efficient" here?

    > I am not saying all this cannot be achieved in Java, albeit is there
    > any framework in Java which does all this?


    Yes. Java with one of the major IDEs deploying to, say, Tomcat.

    > As it would be true for any platform, if you are well versed with RoR,
    > most of the tasks required in web application can be done faster in
    > terms of "development time". That's not just because of RoR/Grails as
    > a framework, but due to nature of dynamic language. Java is bound to
    > be verbose and if you are choosing Java then you need to be prepared
    > to write lots and lots of code and configuration. If you choose RoR/
    > Grails, remember that it's much younger to its Java counterpart and
    > you might not find as many API as you find in Java.


    Would you find as robust an API as Java had in version 1.2, when it was still
    young?

    I'm not down on RoR, just on unsubstantiated, vague, subjective claims that
    it's "better" than Java for some undefined value of "better". You might as
    well argue that a screwdriver is "better" than a hammer for carpentry.

    --
    Lew
     
    Lew, Sep 24, 2009
    #4
  5. markspace

    Chris Seidel Guest

    Re: Groovy and Grails vs. Java for Web Interface (see Java webapplication frameworks / architecture)

    On Thu, 24 Sep 2009 13:08:31 +0200, ck <> wrote:

    > I am not saying all this cannot be achieved in Java, albeit is there
    > any framework in Java which does all this?


    Spring Roo?
     
    Chris Seidel, Sep 24, 2009
    #5
  6. markspace

    Lew Guest

    Kenneth P. Turvey wrote:
    > 1) Groovy is just more succinct. It often requires less code to do the
    > same thing for common tasks.


    I see your point. But there's also a philosophical difference.

    A Java app tends to be more n-tier. In your Groovy example you specify an
    amount of detail that a Java app would leave in the database, i.e., the DDL.
    The @Column annotation has an attribute 'columnDefinition' that lets you plug
    in most of that stuff with SQL syntax, but you normally wouldn't go that way.

    I also think that people worship "succinct" too much. Terse can be hard to
    read, and collapsed into a single tier can become unwieldy quite quickly.

    There's a state-space rationale for layering and decoupling applications.

    Spinning from the Groovy example:
    > class User {
    > String username;
    > String passwordHash;


    Please do not use TAB characters to indent Usenet posts.

    > ...
    > }


    Here's a way to do this in Java. It isn't exactly the same, of course. I
    transfigured from the Groovy idiomatically rather than literally to show how
    one might normally do it in Java. If anything I'm putting in more detail than
    you'd want to in a Java entity.

    Java would more verbosely put business rules either into entity validation
    logic within setX() methods, or in a separate business-rule layer. The
    verbosity seen in simpler scenarios becomes manageability as you scale due to
    separation of concerns.

    public class User
    {
    @Id
    @Column( nullable=false, length=15 )
    private String userName;

    @Lob
    @Column( nullable=false )
    private byte [] passwordHash;

    private String email;

    @Column( nullable=false )
    private String firstName;

    @Column( nullable=false )
    private String lastName;

    @Column( nullable=false )
    private Timestamp birthDate;

    @Column( nullable=false )
    private Timestamp memberSince;

    private String penName;

    @Lob
    private byte[] avatar;

    @OneToMany
    Set <Rating> ratings;

    @OneToMany
    Set <MyStuff> myStuff;

    // getters and setters elided
    // setters could verify things like regexes
    // but should leave that to another layer

    @Override
    public String toString()
    {
    return userName;
    }

    @Override
    public boolean equals( Object oth )
    {
    if ( this == oth ) return true;
    if ( ! (oth instanceof User) ) return false;

    final String otherName = ((User) oth).userName;
    return (userName == null? otherName == null
    : userName.equals( otherName ));
    }

    @Override
    public int hashCode()
    {
    return (userName == null? 0 : userName.hashCode());
    }

    }

    Who was the better writer: Charles Dickens, Ernest Hemingway or Miguel de
    Cervantes?

    --
    Lew
     
    Lew, Sep 26, 2009
    #6
  7. markspace

    ck Guest

    Re: Groovy and Grails vs. Java for Web Interface (see Java webapplication frameworks / architecture)

    On Sep 24, 5:08 pm, Lew <> wrote:
    > ck wrote:
    > > - Defining relationship in models much easier than in Hibernate or any
    > > other Java ORM, "if you stick to conventions"

    >
    > I could have believed that modeling relationships is easier in Ruby on Rails
    > than in Hibernate or other ORM frameworks, but "much easier"?  No.
    >
    > Vanilla foreign keys in Java are a one-word annotation in an entity class:
    > @OneToMany, for example.  (That it's an entity class requires one more word:
    > @Entity.)  The only thing easier than that would be for the code to figure out
    > for itself that it connects to a database, and to infer the relationships for
    > you, but even such as that would not be "much" easier.
    >
    > --
    > Lew


    I did not say anywhere that in hibernate its like writing a story. If
    you are using annotation yes its "easier", but in XML, no.
    --
    -z-
     
    ck, Sep 29, 2009
    #7
  8. markspace

    ck Guest

    Re: Groovy and Grails vs. Java for Web Interface (see Java webapplication frameworks / architecture)

    @Lew - My view was in context to web application framework and not
    Language comparison between Ruby and Java. Rest of the reply inline.

    On Sep 24, 5:16 pm, Lew <> wrote:
    > ck wrote:
    > > - Its faster to check code change on running server, i.e is you made
    > > some change in controller you don't have to restart the server, (could
    > > be achieved in Java using something like java rebel).

    >
    > Also achievable in Tomcat, for example.


    Tomcat is not the only option available. Further, reload your
    application 5 to 10 times in tomcat, in a project that uses Spring and
    hibernate (which many web application use these days else if you are
    using something else you simply reload the application anyway).
    Welcome "Out of memory exception". Then you would suggest increase
    heap size, increase Perm space, use another JVM etc. Yes one can and
    yes its an extra effort involved.

    > > - Database migrations far better than any "Java web application
    > > framework"

    >
    > Please explicate.  What are the differences, and how is Ruby on Rails (RoR)
    > "better"?


    Really? Apart from "carbon" (which in fact is no way close to db
    migration in RoR). I am not aware of any database migration, or any de
    facto in Java world. Could you explain which "web application
    framework" supports DB migration?

    > > - Conventions far better than any of the "Java web application
    > > framework" I have come across so far

    >
    > Please explicate.


    Is there much of conventions set in web application development in
    Java? There are plenty of Specs, but in real life you need to code to
    build products, and code would involve agreed conventions to make team
    effort a bit easy. Maven does bring in some convention in place. But I
    really don't find that still close to RoR convention

    > > - Simple applications can be developed very fast as compared to Java
    > > web application frameworks.

    >
    > I'm sure RoR is fine for simple applications.
    >
    > > - Code generation is a great help as it generates skeleton code and in
    > > appropriate locations, most of the Java web application framework lack
    > > in that. I am not saying that Code generation capability is going
    > > build "entire application" but it cuts down on developers time to
    > > navigate to folders creating files etc.

    >
    > That's a toolkit difference, not a language difference.  There are Java
    > toolkits that generate code, including both Eclipse and NetBeans.


    Does not matter, Java web application framework lags far behind in
    giving "much of code generation" capability. Please don't amuse me by
    citing ROO. It's no where near Rails. On a side note OP asked about
    framework and not language. In any case I was not talking about
    language and its feature.

    > > - Build (Rake) is much efficient than most of the counterparts.

    >
    > What do you mean by "efficient" here?


    You don't spend time to search for maven plugins or write ANT script
    to compile, build, deploy, test, load seed data, configure plugin to
    work with container of your choice etc. You are not given option in
    RoR, you simply use it.

    > > I am not saying all this cannot be achieved in Java, albeit is there
    > > any framework in Java which does all this?

    >
    > Yes.  Java with one of the major IDEs deploying to, say, Tomcat.


    If you insist, and have an agreement that all applications would and
    should run on "some major IDE" and Tomcat.

    > > As it would be true for any platform, if you are well versed with RoR,
    > > most of the tasks required in web application can be done faster in
    > > terms of "development time". That's not just because of RoR/Grails as
    > > a framework, but due to nature of dynamic language. Java is bound to
    > > be verbose and if you are choosing Java then you need to be prepared
    > > to write lots and lots of code and configuration. If you choose RoR/
    > > Grails, remember that it's much younger to its Java counterpart and
    > > you might not find as many API as you find in Java.

    >
    > Would you find as robust an API as Java had in version 1.2, when it was still
    > young?


    Actually this is a funny point raised. Why in world would I bother
    about what was available for Java 1.2? Nor did I make any claim or
    statement that Rails/Ruby has better API support than Java.

    > I'm not down on RoR, just on unsubstantiated, vague, subjective claims that
    > it's "better" than Java for some undefined value of "better".  You might as
    > well argue that a screwdriver is "better" than a hammer for carpentry.
    >
    > --
    > Lew


    Sorry that you felt like that. None of my statements were claims.
    Probably you missed reading the line where I mentioned "My experience"
    with Ruby on Rails. BTW I thought the question was more inclined
    towards "web application frameworks" and not language comparison. A
    language does not mandate features of a web application framework, nor
    can you include IDE as a part of FRAMEWORK.
    --
    Ck
     
    ck, Sep 29, 2009
    #8
  9. markspace

    ck Guest

    Re: Groovy and Grails vs. Java for Web Interface (see Java webapplication frameworks / architecture)

    On Sep 24, 5:20 pm, "Chris Seidel" <> wrote:
    > On Thu, 24 Sep 2009 13:08:31 +0200, ck <> wrote:
    > > I am not saying all this cannot be achieved in Java, albeit is there
    > > any framework in Java which does all this?

    >
    > Spring Roo?


    By "all this" I meant plethora of other things that RoR makes easy and
    ROO does not handle them at all.
    --
    Ck
     
    ck, Sep 29, 2009
    #9
  10. markspace

    ck Guest

    Re: Groovy and Grails vs. Java for Web Interface (see Java webapplication frameworks / architecture)

    On Sep 26, 10:50 am, Lew <> wrote:
    > Kenneth P. Turvey wrote:
    > > 1) Groovy is just more succinct.  It often requires less code to do the
    > > same thing for common tasks.

    >
    > I see your point.  But there's also a philosophical difference.
    >
    > A Java app tends to be more n-tier.  In your Groovy example you specify an
    > amount of detail that a Java app would leave in the database, i.e., the DDL.
    > The @Column annotation has an attribute 'columnDefinition' that lets you plug
    > in most of that stuff with SQL syntax, but you normally wouldn't go that way.


    There could be good reason "not to leave it in the database".
    Unfortunately hibernate also follows it, for example if you don't want
    a column to be null, you can leave that detail to db (most of the db)
    but hibernate lets you handle that.

    > Here's a way to do this in Java.  It isn't exactly the same, of course.  I
    > transfigured from the Groovy idiomatically rather than literally to show how
    > one might normally do it in Java.  If anything I'm putting in more detail than
    > you'd want to in a Java entity.


    "Might" is a dangerous term. You "might" lose clients for your
    uncertainty. Above all it really does not help if something "might be
    done like this", rather let your developers spend time developing
    features than spending time Gluing up frameworks.

    --
    Ck
     
    ck, Sep 29, 2009
    #10
  11. Re: Groovy and Grails vs. Java for Web Interface (see Java web applicationframeworks / architecture)

    ck wrote:
    [ SNIP ]

    > Is there much of conventions set in web application development in
    > Java? There are plenty of Specs, but in real life you need to code to
    > build products, and code would involve agreed conventions to make team
    > effort a bit easy. Maven does bring in some convention in place. But I
    > really don't find that still close to RoR convention

    [ SNIP ]

    Just out of curiosity, how many RoR conventions are there? I'm aware of
    the database table <=> model class conventions, the files/directories
    conventions, and the controller name convention, off the top of my head.

    In J2EE and .NET development certainly there are files/directories
    conventions. ASP.NET MVC has a whack of conventions concerning class
    names with respect to their functions. Naming conventions are ubiquitous
    and pervasive when it comes to accessing backing beans from JSF pages.
    And if using Eclipse JPA or NetBeans, JPA entities can be readily
    generated from database tables using what are, for all intents and
    purposes, naming conventions - the reverse holds true if you set up your
    entity classes first, and let the ORM create the tables on the database
    (which requires no IDE). Just as you would with RoR, if you deviate from
    conventions in JPA that's when you can use annotations or an orm.xml
    mapping file.

    All of the above are conventions in the RoR sense. Obviously on any
    significant J2EE or .NET project there are further agreed conventions,
    for example for further files/directory usages.

    AHS
     
    Arved Sandstrom, Sep 29, 2009
    #11
  12. markspace

    ck Guest

    Re: Groovy and Grails vs. Java for Web Interface (see Java webapplication frameworks / architecture)

    On Sep 29, 2:38 pm, Arved Sandstrom <> wrote:
    > ck wrote:
    >
    > [ SNIP ]
    >
    > > Is there much of conventions set in web application development in
    > > Java? There are plenty of Specs, but in real life you need to code to
    > > build products, and code would involve agreed conventions to make team
    > > effort a bit easy. Maven does bring in some convention in place. But I
    > > really don't find that still close to RoR convention

    >
    > [ SNIP ]
    >
    > Just out of curiosity, how many RoR conventions are there?


    Never counted. How many conventions are there in J2EE?

    > All of the above are conventions in the RoR sense. Obviously on any
    > significant J2EE or .NET project there are further agreed conventions,
    > for example for further files/directory usages.


    Agreed. Of what I am aware, "seam" does a lot of things implicitly.
    How better it is from RoR? I am not aware. I have worked with Spring +
    Struts2 + Hibernate + Velocity + JSP + ACEGI + Maven + Tomcat (or just
    use Appfuse). We ended up spending quite sometime (without using
    appfuse) to reach a consensus, and configure these things.
    What above combination *does not* dictate? Just to mention a few
    (could be more):
    - JSP/Velocity/Freemarker?
    - What folder it should reside?
    - If you use JSP you need to decide are you going to expose JSP
    directly? If no "how would you hide" them?
    - What package structure to follow
    - How do you keep the URL(s) clean?
    - Ajax? Ermm..

    So far "I" find it faster to develop web apps in rails. I have no
    hands with a massive system which has a complicated "business problem"
    to solve. In RoR you don't have many choices on "basic" stuff.
    Everything is just built in, web app framework, persistence, web
    services etc. In Java, a developer would have so much to learn about
    configuring each of those layers independently. Of course things are
    changing in Java on this front, albeit Rails did it sometime back.
    Just to reiterate I am not advocating rails as a panacea to solve
    *all* the problems in most efficient way. I find it easier to work
    with.
    --
    Ck
     
    ck, Sep 29, 2009
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roedy Green
    Replies:
    0
    Views:
    496
    Roedy Green
    Sep 24, 2009
  2. ma_kiem

    g:select tag in grails

    ma_kiem, Jul 20, 2011, in forum: Java
    Replies:
    0
    Views:
    833
    ma_kiem
    Jul 20, 2011
  3. Chris Thiel

    Rails vs JRuby/Rails vs Grails

    Chris Thiel, Apr 11, 2009, in forum: Ruby
    Replies:
    1
    Views:
    184
    Glen Holcomb
    Apr 13, 2009
  4. SkillsMatter Mike

    Groovy & Grails eXchange 2012

    SkillsMatter Mike, Nov 7, 2012, in forum: Java
    Replies:
    0
    Views:
    261
    SkillsMatter Mike
    Nov 7, 2012
  5. Sang Shin
    Replies:
    0
    Views:
    426
    Sang Shin
    Apr 11, 2013
Loading...

Share This Page