Going beyond JSP with Ruby and Seaside
An anonymous reader writes "The Java community has used JavaServer Pages (JSP) technology through most of the last decade, but signs of rust are starting to show. Longstanding conventions inhibit Java programmers from using Java code within Web pages now. Other languages handle Web development much better than Java. This article discuss how code generation works in Ruby, and it delve into a more radical component-based approach in Seaside."
...that seems to be up and coming in the Ruby world is RJS templates. We're using them for the new indi site and they seem pretty handy. The Javascript to Ruby translation is not perfect, of course, but they make some AJAX-ish things nicer: page.visual_effect :highlight, 'sidebar_heading', :duration =>3.
If you're in the northern Virginia area you might be interested in the next NovaRUG meeting; there'll be a presentation on RJS there. Good times...
The Army reading list
Come on! How many times must we endure these kinds of debates? Just use the right tool for the job. You could say there are signs of nothing but rust on COBOL yet it's still very heavily used in financial applications (back end). There is nothing gained by making inflamatory statements, just state the benefits of Seaside and Ruby and leave other languages out of it.
"The difference between stupidity and genius is that genius has its limits." -- Albert Einstein
I'm sorry, but to me this is just yet another confusing syntax for the same old tricks.
Wheee! 2 different kinds of strings... yet another invitation for novices to create spaghetti code that I will have to clean up later, thanks!
stuff |
"There is nothing gained by making inflamatory statements, just state the benefits of Seaside and Ruby and leave other languages out of it."
:)
You must be new here.
BTW Seaside is a nice tool.
I know I'm going to have a hard time convincing the PHP audience of this, but the conventions preventing people from using code in JSP are a good thing. You're going to have a hard time selling me a solution that makes it easier to mix my business logic and presentation, even if it's written in a language I like (like Ruby or Smalltalk).
It's better than JSP? Yay. So is everything else developed in the last ten years (and some systems developed before). The Java community has moved on to alternative presentation technologies -- WebWork, JSF, GWT, and the myriad XSLT frameworks come to mind.
Now, if it's more productive than GWT or JSF...well, then we'll talk. But don't attack the strawman of JSP. That's like saying "Ruby is better than Perl 4!"
The signs of rust have been showing since it started to get any kind of serious use. JSP is basically an abomination. It makes the simple stuff hard and the hard stuff require using scriptlets. And it makes it far too easy to put far too much application logic in JSP code. JSP 2.0 has helped a bit, but it's a bit like putting a prom dress on 600 lb hooker...she looks better, but only slightly.
But thankfully for Java programmers, there's a ton of other better alternatives that can be used. Freemarker, Velocity, Tapestry and Cocoon are all vastly superior options to JSP. Tapestry was a component-based view-layer framework long before Seaside or any other Smalltalk server-side framework. So comparing it to JSP is a bit like comparing apples to Ford Pintos.
Picking on JSP is like kicking a starving puppy...try picking on one of Java's guard dogs (listed above) and they'll put up a stronger fight.
"Don't blame me, I voted for Kodos!"
One look at the author being Bruce Tate, and you wonder why they didn't just link to his book at the top of the article instead of the bottom. Way to go Brucey!
"I'm sorry, but to me this is just yet another confusing syntax for the same old tricks."
The same thing could be said for the English language. Down with english! Bring back Latin.
"but it's a bit like putting a prom dress on 600 lb hooker...she looks better, but only slightly."
I think your mom looked really nice in that dress, and we had a great time together. Don't be such a dick about this relationship, I am not trying to replace your dad.
not "better", "differently".
if i only learned one thing in my later classes in college, it was that a language is a tool. some languages make some tasks easy. some languages are better used given specific circumstances. there are differences between jsp and ruby. sure, maybe ruby does somethings better, but there are also definite advantages on the jsp side, as well.
Not a single article from Bruce Tate manages to convince me of "killer funcionalities" in their Ruby solutions (only a web framework cannot match the whole Java for making it worth migrating), it seems more like a mediocre developer in love with his new toy trying to get the attention he needs. His sensationalitic approach makes him look like a fraud, an untalented programmer that proclaims himself as the spokesperson of something. Maybe a "fraud with a big mouth" is what he is after all.
All non-Java developers keep in mind that all this loser says has nothing to do with the general perception inside the Java community. The only general perception there's is that he's an idiot.
Once again he shows a pathetic template system, which could be easily done in Java but no one is crazy to do it because it's crap, and a framework like many others.
BTW, he needs to study Java web development, that goes beyond JSP. Not to mention the many options we have, including templating, but also a tool support unseen in the Ruby world, that makes web development as easy as drag'n drop.
Ruby is not a match for Java, give up. Why 10 out of 10 articles written about "dynamic languages" must have sensationalistic and impossible claims involving Java?
And opensource is not trustworthy. I see many people complaining about Java's commitment to compatibility between versions (including Bruce Tate) and then they recommend Opensource as a solution! That's CRAZY. Would you like to know that you need to rewrite that big application of yours because of a new version that has just came out??
How do they expect to be taken seriously?
The main article here says 'there are better languages for web than java', or something to that effect. How irrelevant. This article is about JSP, not Java. One could in theory write a ruby language bytecode compiler/interpreter for Java and use it there.
JSP has issues, yes, but some of us dont even use it for our web VIEWS, which are independent of the java backend, (if you're an architect worth hiring, anyway) -- for which Java is unparalled in doing the job. Try to scale like Java does with Ruby at the backend. Good luck.
The author must be living in 1995. Ever heard of ASP.NET? he jumps from JSP/ASP to the 'revolution' of LAMP and Seaside. Really convincing arguments there with side-by-side comparisons of the latest technologies. Lame.
I live and work in Switzerland and our sites have to handle 4 or more languages. When Ruby has unicode support built in, I'll take another look at it. Until then, it's Java, python and php for me.
I've never used either JSP or Ruby on Rails, so I can't make any kind of informed comparision. I have, however, done some stuff with Seaside and the article focusses on the HTML generation aspect of it and completely misses what makes Seaside great.
Seaside's HTML generator is (IMHO) kind of clunky, actually. Something like PHP, where you embed the code in an HTML file, is cleaner and simpler. But, if you need Seaside, the HTML generation is going to be a small part of your application.
What makes Seaside so utterly cool is that the back button works.
Let me explain:
In Seaside, you generate your page programmatically and you specify what happens when a link is clicked or a button pressed via a callback.
For example:
html anchorWithAction: [self increase] text: '++'.creates a link. The stuff between the square brackets gets executed when the user clicks the link. In the above example, the current page just gets refreshed. If you want to go to another page, you'd use the "call:" method:
html anchorWithAction: [self call: OtherPage new] text: 'Some other page'.Called components can also return values, so you can call out to another page, get a result and use it in your action:
html anchorWithAction: [self setBackgroundColor: (self call: ColorPicker new)] text: 'Change background color'.So hopefully from this, you can see that Seaside works sort of like a boring GUI toolkit. You design the screens and add callbacks to the controls. When the user clicks on a link or presses a button, the associated callback gets invoked.
This would be pretty simple for all concerned were it not for that pesky back button. In the final example, the callback first takes the user to another page (a ColorPicker component) and then, when the user selects "Okay" in that, returns the result and passes it to "setBackgroundColor:".
But what if the user hits the back key while in the ColorPicker? This happens right in the middle of the callback. Can Seaside unwind the entire callback?
Yes, it can. Backing out Just Works.
But, I hear you say, what if there's information I don't want unwound? Say, a shopping cart?
Simple. You can tell Seaside which objects don't change after a backout.
Aside from the back button, you also get access to your entire programming system in the framework so you can do some pretty powerful things in between those square brackets.
Also, the web server is part of the system so you can bypass the framework and do lower-level stuff. For example, I once wrote an image generator. It analyzed its URL, generated the appropriate GIF and returned it.
Plus, of course, it's written in Smalltalk which is the greatest programming language ever ;-).
Geez - the "Trouble with JSP" article TFA references is over 6 years old(!). Java web development has come a long way since then! Just for starters, thinkg JSP with JSTL or Velocity templates plus your favorite MVC framework. Or how about Struts + Tiles? Saying that JSP is bad because of scriptlets is like saying...ASP.NET is bad because of VBScript.
I don't pretend to grok continuations (that's what Seaside does I hear), but an article I have found to be really illuminating explains this in quasi-Basic. The Basic-ish code in that example by the way, is written in what we call continuation passing scheme (CPS). That's basically the extra function tacked onto the argument list passed to functions [instead of f(arg1,arg2), we call f(arg1,arg2, c) where c is the continuation. f does not return as such, but calls c when it is ready to return. Instead of "return some_value;", we call "c(some_value)"].
Of course, continuations are not the solution to everything, but there's a lesson to learn from their usage.
CPS is often what functional programming languages compile into - no one writes code like that manually. You take a program, transform it into CPS, keep doing that, resubstituting variables names, expanding macros, and simplifying functions as necessary, until you are left with a couple of variables (-> registers), and a whole lot of assembler instructions - it has been compiled into assembly language. Now that's a nice compiler!
I prefer to use one environment for my apps. After all, the browser is a glorified 'window system' no different than X-Windows in concept...and the best toolkit for this job right now is Echo2.
Continuations are the solution to everything. IIRC, all other control structures that have yet been invented can be implemented with continuations: Exceptions, coroutines, nondeterminism, you name it.
(Oh, and it's Continuation Passing Style. Not that it matters all that much.)
Longstanding conventions inhibit Java programmers from using Java code within Web pages now.
That's because you don't want to mix business logic with presentation logic. Any "programmatic" logic you need for presentation can be accomplished with the JSTL, hence most people disable scriptlet support. Only novices would advocate placing code into templates. I shouldn't complain though, as I can rely on these novices fucking things up so much that I can always find work replacing their abominations with something scalable and maintainable.
generating HTML from within programming language was a bad idea. Even worse in an unreadable language like smalltalk. When are they going to let that horrible syntax die? I never bought that smalltalk was intuitive enough to be a "teaching language". IBM owns smalltalk now. ST useless.
I for one welcome this wholeheartedly, especially after my long-standing battle with JSF, with which I have found it very difficult to make even very simple things work, and that with a team of developers! It's enough to make me want to go back to Perl/CGI. It has been a thorn in my side for a year now and I am ready for something new. I realize that Java-related technologies have a steep learning curve, but this is ridiculous! Even if it takes me 6 more months to learn Ruby and Seaside, I'm up for the challenge, so at least I can use more than one damn form on a page.
I don't mean to vent about JSF, but this simply emphasizes the need to for new, easy-to-use, and reliable technologies; It also illustrates a failure in the industry - and I firmly believe that it is JSF.
use -K for source encoding
Don't know if that helps you, though.