[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rails vs Java Struts

Armin Roehrl

10/8/2004 10:05:00 AM

Hi,

I am working on a short article about rails in German.

Could s.b. who has experience with Java Struts and rails
comment on it?

Thanks,
-Armin


25 Answers

Curt Hibbs

10/8/2004 10:40:00 AM

0

wrote:[mailto:armin@xss.de]
>
> Hi,
>
> I am working on a short article about rails in German.
>
> Could s.b. who has experience with Java Struts and rails
> comment on it?
>
> Thanks,
> -Armin

Also, would someone be willing to translate it to English?

Curt


Armin Roehrl

10/8/2004 10:53:00 AM

0

Curt Hibbs wrote:

>wrote:[mailto:armin@xss.de]
>
>
>>Hi,
>>
>> I am working on a short article about rails in German.
>>
>>Could s.b. who has experience with Java Struts and rails
>>comment on it?
>>
>>Thanks,
>> -Armin
>>
>>
>
>Also, would someone be willing to translate it to English?
>
>
I can try todo that .. no big deal.

>Curt
>
>
>
>
>



David Heinemeier Hansson

10/8/2004 11:21:00 AM

0

> Could s.b. who has experience with Java Struts and rails
> comment on it?

One of the first differences is one of kind. Rails has an answer for
all three letters in MVC. Struts is squarely focused on providing the
C. In Rails, that layer is handled by Action Controller (part of Action
Pack which also includes Action View).

A few other quick differences:

* All actions in Struts must be mapped in an XML file. All return
values use indirection (SUCCESS/FAILURE) that must be mapped in the XML
file. In Action Controller, this is all handled by reflection (the
framework figures out how the configuration should look).

* Action Controller cares deeply about Pretty URLs, such as
/customers/show/154. It's baked right into the framework. Default
Struts exposes technology in the URLs (*.do) and generally doesn't work
hard to care for the beauty of the URL. (Third-party add-ons can
alleviate that to some degree).

* Struts' actions are full-fledged classes, actions in AC are just
methods. The default number of lines for an action in Basecamp[1] is 5.
Look at any struts example and find any action. It's not even funny.

* Action Controller supports the concept of layouts natively. Struts
requires the aid of Tiles, which in turn requires its own set of XML
files for configuration (on top of what's already required in Struts).

* Validation in Struts requires the use of "model mirrors" called
ActionForms. These mirrors have a 1-1 mapping to your model files a lot
of the time, but uses a different syntax. This means you're Repeating
Yourself. In Rails, validation is pushed to the model, while the
_presentation_ of validation errors are kept in the Action Controller.

* Action Controller has deep support for filters/interceptors (running
shared code before and after all actions). Struts have a research
project called SAIF to get this type of support, but nothing in the
main framework.

* Action Controller has scaffolding to quickly bring a model class
"online" (provide CRUD operations without doing code).

...and then of course, Action Controller is built with a whole MVC
framework in mind. So it works exceedingly well Action View and Active
Record. There's definitely preferential treatment going on there, even
if Action Controller is a separate framework.

I hope that helped a bit. Have in mind that I'm pretty biased, though
:). Struts personifies much of my animosity towards the Java/J2EE
world. It has XML-files up to here, duplication and repetition coming
out of the wazoo, and very little to show for it when it's done.

What I _do_ like about Struts is how it some how got positioned itself
as the default controller in the majority of run-of-the-mill J2EE apps.
That's a freaking awesome piece of PR work there. I'm still learning on
that account ;)

[1] Basecamp was the first application to use Rails. It's a web-based
project management tool available at http://www.base....
--
David Heinemeier Hansson,
http://www.rubyon... -- Web-application framework for Ruby
http://www.in... -- A No-Step-Three Wiki in Ruby
http://macro... -- TextMate: Code and markup editor for OS
X
http://www.base.../ -- Web-based Project Management
http://www.loudthi... -- Broadcasting Brain
http://www.next... -- Development & Consulting Services



Moses Hohman

10/8/2004 1:29:00 PM

0

Yes, I wouldn't take Struts to be the shining example of Java MVC
toolkits, even if it is the most popular.

I also can't claim to know the entire range of them intimately, but I
have been liking the Spring Framework's MVC stuff, even if it does use
XML configuration files : )

-Your model can be your domain object, or not, depending on which you
think is a better choice
-You define how your action return value maps to your views (so that
you don't have to define success and failure views for every
controller)
-Implementing actions does not require implementing them one per class
(although often I do this, but that doesn't seem like such a terrible
thing to me)
-Spring MVC is also view agnostic, so you can pick the view technology
you like the best, the layout thing is left up to you (tiles, sitemesh,
whatever you like, and by the way tiles does not require use of XML
files, only if you are doing something fairly complicated do you need
them)
-And, in the greater Spring framework, there are some nice
simplifications for JDBC access that can simplify this code as well,
although these are not part of the MVC framework. The greater framework
also provides simplification for Hibernate, JDO and other ORM tools.
Technically I don't think an MVC framework should choose an unrelated
technology for you like that. Does Rails allow you to swap out
something in place of ActiveRecords? I have very limited experience
with rails (I've gone through the basics of the installation and
tutorial only).

Moses

On Oct 8, 2004, at 6:20 AM, David Heinemeier Hansson wrote:

> I hope that helped a bit. Have in mind that I'm pretty biased, though
> :). Struts personifies much of my animosity towards the Java/J2EE
> world. It has XML-files up to here, duplication and repetition coming
> out of the wazoo, and very little to show for it when it's done.
>
> What I _do_ like about Struts is how it some how got positioned itself
> as the default controller in the majority of run-of-the-mill J2EE
> apps. That's a freaking awesome piece of PR work there. I'm still
> learning on that account ;)
>



David Heinemeier Hansson

10/8/2004 1:37:00 PM

0

> Technically I don't think an MVC framework should choose an unrelated
> technology for you like that. Does Rails allow you to swap out
> something in place of ActiveRecords? I have very limited experience
> with rails (I've gone through the basics of the installation and
> tutorial only).

Sure it does. Instiki uses a Madeleine back-end and is hooked up with
an older version of Action Pack.

But I really disagree with the "those an unrelated technology" theme in
regards to Rails. I actually think the biggest asset of Rails is that
it _does_ chose a full tech stack for you. Who wants to program
control-flows? I want to create web-applications.

So in that sense Rails is more focused on the goal (a web-application)
than the means (just control-flow or just ORM).

I think that's a good part of the reason why Rails is gathering some
momentum now. It's a full solution to a problem (creating a
web-application). This idea of course isn't new. You mention Spring
which is also attempting to archive a full solution. And then there are
projects like AppFuse that attempts to tie a given stack together.
--
David Heinemeier Hansson,
http://www.rubyon... -- Web-application framework for Ruby
http://www.in... -- A No-Step-Three Wiki in Ruby
http://macro... -- TextMate: Code and markup editor for OS
X
http://www.basec... -- Web-based Project Management
http://www.loudthi... -- Broadcasting Brain
http://www.next... -- Development & Consulting Services



Moses Hohman

10/8/2004 2:25:00 PM

0

On Oct 8, 2004, at 8:37 AM, David Heinemeier Hansson wrote:

>> Technically I don't think an MVC framework should choose an unrelated
>> technology for you like that. Does Rails allow you to swap out
>> something in place of ActiveRecords? I have very limited experience
>> with rails (I've gone through the basics of the installation and
>> tutorial only).
>
> Sure it does. Instiki uses a Madeleine back-end and is hooked up with
> an older version of Action Pack.
>

That's good to know. Whatever Madeleine is. : ) I am a nuby.

> But I really disagree with the "those an unrelated technology" theme
> in regards to Rails. I actually think the biggest asset of Rails is
> that it _does_ chose a full tech stack for you. Who wants to program
> control-flows? I want to create web-applications.
>
> So in that sense Rails is more focused on the goal (a web-application)
> than the means (just control-flow or just ORM).
>

I think this is good, too. By "choose", I meant "force you to use", not
"provide a default option". I was just wondering whether Rails made it
difficult to swap out parts of your stack if you happened to prefer
another library for ORM or whatever, which I think a framework should
allow you to do. It sounds like Rails doesn't force anything on you, so
that's good.

Moses



gabriele renzi

10/8/2004 2:41:00 PM

0

Moses Hohman ha scritto:

> That's good to know. Whatever Madeleine is. : ) I am a nuby.

http://madele...

a lovely persistence system based on Object Prevalence concepts

David Heinemeier Hansson

10/8/2004 2:52:00 PM

0

> I think this is good, too. By "choose", I meant "force you to use",
> not "provide a default option". I was just wondering whether Rails
> made it difficult to swap out parts of your stack if you happened to
> prefer another library for ORM or whatever, which I think a framework
> should allow you to do. It sounds like Rails doesn't force anything on
> you, so that's good.

Indeed, indeed. You want people to reach their own conclusions.

(*Flute playing*, *Man dancing* -- yes, that's one for the RubyConf'ers
;))
--
David Heinemeier Hansson,
http://www.rubyon... -- Web-application framework for Ruby
http://www.in... -- A No-Step-Three Wiki in Ruby
http://macro... -- TextMate: Code and markup editor for OS
X
http://www.basec... -- Web-based Project Management
http://www.loudthi... -- Broadcasting Brain
http://www.next... -- Development & Consulting Services



Martin DeMello

10/8/2004 3:08:00 PM

0

David Heinemeier Hansson <david@loudthinking.com> wrote:
>
> I think that's a good part of the reason why Rails is gathering some
> momentum now. It's a full solution to a problem (creating a
> web-application). This idea of course isn't new. You mention Spring
> which is also attempting to archive a full solution. And then there are
> projects like AppFuse that attempts to tie a given stack together.

http://www.su... is interesting too.

martin

MiG

10/8/2004 3:20:00 PM

0


I think this is a good idea but it should work another way:
Not take snapshots of the whole system in constant periods and store all
classes in memory.

My idea is:
1. Command (object) to application object are marshalled and dumped,
that's ok.
2. But each application object will be automatically dumped if long time
unused.
3. The system should dump as well object class after long+n time unused.

In memory there should be only used classes and objects, not garbage.


MiG


Dne 8/10/2004, napsal "gabriele renzi" <rff_rff@remove-yahoo.it>:

>Moses Hohman ha scritto:
>
>> That's good to know. Whatever Madeleine is. : ) I am a nuby.
>
>http://madele...
>
>a lovely persistence system based on Object Prevalence concepts
>