What surprises me about Rails and Grails users
It wasn’t all that long ago when I remember hearing people slamming Java Server Pages simply because your could write scriptlets. JSP was evil, the worst thing ever created, garbage, yada, yada, yada. Never mind that sometimes it was actually useful to do so, for doing visual things of course. So the power that be created tag libraries which helped a little bit, but creating taglibs was a pain. It has gotten a little easier with JSP 2 and all, but for the most part people don’t use them.
So what does this have to do with Rails and Grails? Well, going through some examples of both frameworks shows one thing I have yet to hear the purists cry about: generating content from within a class. Ah yes, reminds of the pre-JSP days when we were building HTML in a servlet! Not that this is a recommended practice of course, but the fact that this is even being shown is a surprise.
Why? The early adopters of tools like these tend to be the ones that are on the forefront of all the new technologies and let’s face it, can be pretty opinionated (yes that includes me…) and harsh when it comes to “not doing it right”. So while it doesn’t really bother me if someone wants to spit out some response text from a controller I’m shocked that more people haven’t cried foul. Maybe they are trying but have been drowned out by all of the partying going on over these two frameworks. Or perhaps, gasp, they grew up and realized it just isn’t that bad of thing after all.
Don’t miss anything, subscribe!
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.
Comments
I think you (author of the post ) are missing a very important point about JSP. JSP was meant to be a purely rendering technology. Look at the way it’s built and IMO you can see it pretty clearly. It’s meant for something else to prepare beans, place them into contexts and for JSP to place them on the screen (document, whatever else). Scriptlets in JSP can serve only two purposes: intentional (being able to say “yes, you can do logic in JSP, what are you talking about?!”) and unintentional (if you use scriptlets you get yourself into deep crud very quickly and very thoroughly).
There are two arguments: 1) whether or not logic should be mixed with rendering or should be separated into completely separate [packages/locations/technologies]. This can be argued either way, first one it cleaner, second allows for more rapid development; 2) JSP is a rendering-only technology and warts like JSTL’s SQL tags should be shot for. I am not sure how you argue with this one but by all means, I will be very interested in comments.
I think one of the reasons that JSPs were attacked for allowing scriptlets but Rails doesn’t get this treatment is what scriptlets (and most of JSP in general) does to the readability of the page. With scriptlets, you see braces ({}) all over your HTML, whereas with Rails you usually see HTML wrapped in blocks which can use do…end (more readable).
Also, JSPs don’t have a standard way of writing form elements. You usually end up putting scriptlets right in the middle of an HTML tag attribute. Rails has helpers that generate HTML form elements while not ruining the readability of the view.

LOL What the hell are you talking about? The “hello world” examples?
Nobody uses classes to generate HTML in Ruby or Grails. That hasn’t happened since the servlet spec came out.
Both Grails and Rails are MVC frameworks that use script pages for the view.