Going beyond JSP with Ruby and Seaside 66
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."
Another template option (Score:4, Informative)
If you're in the northern Virginia area you might be interested in the next NovaRUG [novarug.org] meeting; there'll be a presentation on RJS there. Good times...
Flame on! (Score:5, Insightful)
Re:Flame on! (Score:2)
Yeah, I mean seriously, you could lose your cat [foxnews.com]!
Re:Flame on! (Score:4, Insightful)
Wrong. Ruby on Rails came to prominence because of DHH's brilliant marketing--poking Java guys with a stick.
Re:Flame on! (Score:2, Informative)
Re:Flame on! (Score:3, Interesting)
Wrong! It's no just for the 'backend' these days! And you thought the old farts weren't 'with it'.
http://www.cobolscript.com/ [cobolscript.com]
Re:Flame on! (Score:2)
Re:Flame on! (Score:1)
And don't forget COBOL for .NET [netcobol.com]! Among its features:
Here are some [netcobol.com] screenshots [netcobol.com].
confusing syntax, anyone? (Score:1, Troll)
Wheee! 2 different kinds of strings... yet another invitation for novices to create spaghetti code that I will have to clean up later, thanks!
Re:confusing syntax, anyone? (Score:3, Insightful)
You really oughtta learn LISP. Instead of spending half an hour looking at some code and concluding that it's more confusing than the language you've been working with for the last 5 years, work with it long enough to 'get it' and then make a proper comparison.
Wheee! 2 different kinds of strings... yet another invitation for novices to create spaghetti code that I will have to clean up later, thanks!
Explain to me how str
Re:confusing syntax, anyone? (Score:3, Insightful)
has_many
vs
has_many 'comments'
I see no source of spaghetti code from this!
Yay, it's better than JSP. (Score:5, Insightful)
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!"
Re:Yay, it's better than JSP. (Score:1)
Re:Yay, it's better than JSP. (Score:3, Insightful)
Attacking JSP is a strawman, but so is this. Presentation requires logic. Ruby makes an excellent templating language. If we try to replace it with a secondary crippled syntax just to avoid people putting business logic in their templates, then we run the risk of forcing people who know what they're doing to mix presentation logic in with their business logic. Designing languages to preve
Re:Yay, it's better than JSP. (Score:2, Informative)
Do you really mean the actual Ruby language or the Ruby templating language. Because even Ruby has a templating language (rhtml).
I think there's a bit of confusion on your part about the purpose of templating languages. You seem to believe that they exist to allow crippled logic to prevent programmers from doing things they should know not to do anyways. But this is only a side-effect of their true purpose. Templating languages evolved from people writing web
Re:Yay, it's better than JSP. (Score:2)
blah-blah
<c:else>
blah
</c:if>
Re:Yay, it's better than JSP. (Score:2)
Is Ruby better than Java for templating? Depends.
Is RHTML any better (or even that different) than plain ol' JSP. No. There, I said it.
Re:Yay, it's better than JSP. (Score:2)
Starting to show??? (Score:2, Insightful)
But thankfully for Java programmers, there's a ton of other better alternatives that can be used. Freemarker, V
Re:Starting to show??? (Score:2)
You listed alternatives but many bussinesses dont trust free software or consider such projects proprietary if they dont come from Sun. Sco did alot of damage to the mindset of phb's on one of my former employers. I know sun came up witht he JCP community process which have made nice tools llike the beanshell part of the next java.
JSp is what most bussinesses still use and where the jobs are out. No wonder MIS grads are looking at ASP.NET w
Re:Starting to show??? (Score:2)
You'd be surprised at how well accepted projects like Spring [springframework.org] are among PHBs. Spring is quickly getting a reputation for allowing projects to deliver on time and budget (if not under). I was privileged enough to attend the Spring Experience conference last December and there were a num
To be expected (Score:4, Insightful)
Re:To be expected (Score:2)
I think the quality of his writing has declined, starting with "Better, Faster, Lighter Java". He never talks about possible tradeoffs of choosing a design or technology, it is always "And see, this is the magic silver bullet that solves everything, three lines of code, bam, next project".
eh... (Score:2, Insightful)
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.
Re:eh... (Score:1)
yes, there are some languages that are obsolete/dead. there are some that are still alive just because they're too entrenched to replace. but there's no one god-language that is better than all others. pretty much every language has SOME facet that is unique/different.
i'm not a seaside expert. i'm not a jsp expert. but i'm sure i could do some research, find differences, and come up with scenarios where jsp would be a better choice. maybe seaside is a better choice in most cases,
Once again, wishful thiking (Score:2, Insightful)
All non-Java develo
Re:Once again, wishful thiking (Score:2)
How is this unfounded statement any better than what's written in the article?
Re:Once again, wishful thiking (Score:2)
That's not quite what I asked. As a presumably experienced programmer, you will doubtless know that some languages are more suitable for some tasks than others. One would not construct a web application in assembly, for instance.
The claim that "Ruby is not a match for Java" reeks of gener
Re:Once again, wishful thiking (Score:2)
Obviously. I program in Java for a living. I'm quite aware of amount and quality of libraries available for Java.
However, in terms of general web development, Ruby's featureset is fairly complete. There isn't much it lacks. I mean, sure, if you
Re:Once again, wishful thiking (Score:2)
That's why I prefer Python, myself ;)
Gah! You decry over-generalisations, then make one of your own!
Re:Once again, wishful thiking (Score:2)
Sure, and why should that be a problem? Once my library is in the hands of a developer, what he does with it is completely up to him. If he attempts to extend an undocumented internal function, what happens is not my problem. Warrenty void if opened.
Re:Once again, wishful thiking (Score:2)
Someone with that level of incompetance would find a way to screw things up even with strict class permissions. I'd also be leery about working for a company who would employ people without a technical interview to determine if they knew what they were doing.
Sure, for untrusted users. But if you consider the programmers in your team to be
Re:Once again, wishful thiking (Score:2)
Firstly, Ruby has class permissions the same as Java. This isn't anything to do with Ruby.
Secondly, there are mistakes, and there are mistakes. If I decided to stick a electrical cable in my m
Re:Once again, wishful thiking (Score:2)
JSP != Java (Score:4, Insightful)
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.
Re:JSP != Java (Score:2, Informative)
unicode (Score:5, Informative)
Seaside (Score:4, Informative)
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 ;-).
Re:Seaside (Score:2)
Right on, man!
I do Smalltalk when I can- I'm with you, it *is* the best language we have right now. I just started a job doing Java servlets and
Straw Man (Score:4, Informative)
Why continuations are useful for web programming. (Score:2, Informative)
I don't pretend to grok continuations (that's what Seaside does I hear), but an article [cincomsmalltalk.com] 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 "re
Re:Actually... (Score:1)
Continuations can be used to build everything (don't know, maybe everything), but from what I've managed to gather, there are problems with continuations as they are used in Scheme at the moment (don't know about any other language).
I've been trying to read through and understand this [nhplace.com], but haven't got far yet. Basic idea is I guess "how does a continuation escape from an unescapable unwind-protect?". Unwind-protect is like "finally" in Java, it has to run *always* - but continuations never return, so it's
Re:Actually... (Score:1)
I prefer using Java for web apps, thank you. (Score:3, Interesting)
Re:I prefer using Java for web apps, thank you. (Score:1)
Thanks for the info on Echo2, I just looked at their demo apps and tutorial and...
Wow, I am impressed with Echo2. I'm not usually a fan of Java web-frameworks simply because my experience has been that they require the you to program in Java and then do the HTML and Javascript too, but Echo2 doesn't, very cool.
And, as for Web 2.0 and giving the web a true application feel, very few frameworks or sites actually accomplish that without tons of Javascript, however Echo2 really does without the develope
Thanks for the laugh (Score:4, Interesting)
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.