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


Forgot your password?

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."
This discussion has been archived. No new comments can be posted.

Going beyond JSP with Ruby and Seaside

Comments Filter:
  • by tcopeland ( 32225 ) * <tom@thomaslee[ ]eland.com ['cop' in gap]> on Thursday July 06, 2006 @12:59PM (#15668048) Homepage
    ...that seems to be up and coming in the Ruby world is RJS [codyfauser.com] templates. We're using them for the new indi [getindi.com] 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 [novarug.org] meeting; there'll be a presentation on RJS there. Good times...
  • Flame on! (Score:5, Insightful)

    by Mark_Uplanguage ( 444809 ) on Thursday July 06, 2006 @01:02PM (#15668080)
    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.
  • 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!
    • I'm sorry, but to me this is just yet another confusing syntax for the same old tricks.

      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
    • are you talking about symbols? If so your spaghetti code conclusion makes no sense to me.

      has_many :comments
      has_many 'comments'

      I see no source of spaghetti code from this!
  • by cbiffle ( 211614 ) on Thursday July 06, 2006 @01:10PM (#15668176)
    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!"
    • personally i think ruby, and therefore rails, is better because I think dynamic languages are generally better than static ones.
    • You're going to have a hard time selling me a solution that makes it easier to mix my business logic and presentation

      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
      • by Anonymous Coward

        Ruby makes an excellent templating language.

        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

        • Presentation does not require much of logic. Most of it can be expressed with simple custom tags (supported by JSP 2.0):
          <c:if cond="mycondition">
          Besides, you can get smart autocomplete and error checking in your favorite editor for custom tags. Yes, sometimes you'll need to use Java scriptlets. But if you have to do it only once for 10-20 pages then this is not a big problem.
      • Ruby makes an excellent templating language.

        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.
    • JSPs aren't in the same class as WebWork or JSF. JSPs are a presentation technology while WebWork and JSF are web frameworks. Web frameworks are for organizing your web application while presentation technologies are for dumping out HTML (or whatever) to the client.
  • by curunir ( 98273 ) *
    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, V
    • Which is why I am a fan of opensourcing java because its stagnating.

      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
      • Only Sun's Java offerings are really stagnating. The real improvements are happening outside of Sun. If Sun were to give up control of Java by open-sourcing it, it would do wonders for Java, but it is by no means necessary.

        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)

    by hexghost ( 444585 ) on Thursday July 06, 2006 @01:15PM (#15668230) Homepage
    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!
    • Yes, I think this actually the tenth or so "Ruby -yay! Java -boo!" article by Bruce Tate that Slashdot posts. I think he writes about two a week for IBM devworks.

      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)

    by aleksiel ( 678251 )
    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.
  • by Anonymous Coward
    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 develo
    • Ruby is not a match for Java, give up.

      How is this unfounded statement any better than what's written in the article?

  • JSP != Java (Score:4, Insightful)

    by iangreen ( 793707 ) on Thursday July 06, 2006 @05:15PM (#15670819)
    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.
  • unicode (Score:5, Informative)

    by theolein ( 316044 ) on Thursday July 06, 2006 @07:58PM (#15671930) Journal
    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.
  • Seaside (Score:4, Informative)

    by cgreuter ( 82182 ) on Thursday July 06, 2006 @09:18PM (#15672419)

    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 ;-).

    • If I had me mod points, I'd mod the above post even higher...

      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 ... well, I miss Squeak and Seaside. I miss beign able to run the image on my local machine rather than the server, and sprinkle in inspectors, etc etc to trouble shoot problems. I feel like I'm working with a line editor like sed and assembler with Java, productivity-wise. Oh well! Maybe I'll convince t
  • Straw Man (Score:4, Informative)

    by cyranoVR ( 518628 ) * <cyranoVR@RASPgmail.com minus berry> on Thursday July 06, 2006 @09:58PM (#15672616) Homepage Journal
    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 [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

  • by master_p ( 608214 ) on Friday July 07, 2006 @03:43AM (#15673745)
    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.
    • 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)

    by LizardKing ( 5245 ) on Friday July 07, 2006 @07:03AM (#15674118)

    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.

"The number of Unix installations has grown to 10, with more expected." -- The Unix Programmer's Manual, 2nd Edition, June, 1972