Re: Ruby on Rails?
Casey Cady <[email protected]> Thu, 27 Oct 2005 13:33:59 -0700
| Newsgroups | gmane.comp.web.webobjects.general |
|---|---|
| Message-ID | <[email protected]> |
I've been recently playing with Ruby On Rails, and I have quite a
different take on it.
I haven't done too much with it, but I like it so far. (For the
record I'm currently doing
WO 4.51 development during my "day job")
The language itself has some pretty good features. It has the
ability to metaprogram and has the equivelent of Objective C
categories (called Mix Ins). It is interpreted, which is both good
and bad. It's very strongly object oriented. It tends to be very
declarative. For example, method names can end in ? or !. By
convention, methods which return a bool end in ? (ie. String.empty?)
while destructive methods end in ! (ie. the string class has both a
capitalize and a capitalize! method, with capitalize! modifying in
place).
Rails is one of the more promising web libraries I've seen. I
completely disagree with the categorization of the generate scripts.
One of the philosophies that Rails seems to hold to, is that you
should be able to do whatever you want, but Rails will encourage you
to do something the right ("right" being subjective, of course) way
by making it easier. The easiest way to start a new Rails project is
to run the Ruby script. All that does is generate a standardized,
sane directory structure from which to start with. The easiest way
to create a new model class is to call the generate model script,
which puts a class in the model directory, named appropriately. The
file is about 3 lines long:
class foo < ActiveRecord::Base
end
You could easily have done the same thing by hand. However, the
generate script also creates a test fixture, which is a nice
convenience.
So, you don't "need" to generate code. It's pretty convenient.
As far as DB handling goes, ActiveRecord is kind of interesting in
that it encourages your table names to be in a particular format, as
you get free functionality if they are. for example, for the above
"foo" class, it would try to find a table named "foos". It knows
about english plurality rules (sort of...name a class "sheep" and
it'll look for a table named "sheeps"). Of course, you can specify a
table name if you don't like the default guesswork. I'm still trying
to decide if I like it or not.
Incidentally, specifying relationships in Rails is pretty clean:
class foo < ActiveRecord::Base
has_many :bar
belongs_to :baz
end
..etc
Views are specified using rhtml files, which are pretty much what you
would expect from an html template.
The controller classes look like this:
class ManagementController < ApplicationController
def index
list
render :action => 'list'
end
def list
@bug_pages, @bugs = paginate :bug, :per_page => 10
end
def show
@bug = Bug.find(params[:id])
end
end
Each of those method definitions corresponds to a url. in other
words, http://foo.com/railsapp/management/index will run the index
method.
At this point I'm still poking my way around, but I definately have a
different perspective than is in the message below. At the very
least, I think it's worth an open minded look.
"Agile Web Development with Rails" is a pretty good book for
exploring Rails.
Casey Cady
On Oct 27, 2005, at 12:36 PM, Mont Rothstein wrote:
> I asked this same question not long ago on a different list. Below
> is the
> reply I received.
>
> The list the was posted to is the developer list for
> http://sope.opengroupware.org and open-source re-implementation of
> WO 4.5 in
> Obj-C.
>
> -Mont
>
> On 28. Mai 2005, at 05:34 Uhr, Mont Rothstein wrote:
>
>> * I was wondering if you have looked at Ruby on Rails and if you had
>>
> *>* what you thoughts on it were compared to WO.
> *
> I'm not sure its a good idea to turn this list into a RoR discussion
> list ;-) So I just give some ideas I have about it. Not that I never
> tried it in real live (wasn't too easy to setup on OSX), I've just
> seen some demos and read the tutorial on the website to get an idea
> on what it does and how.
> When the tutorial started with a script which _generated_ code, my
> first thought was "WHAT A CRAP". If you need to generate code,
> something is usually inherently broken in the concept.
>
> - first: its obviously clear that RoR is very much overhyped and
> delivering
> nothing which wasn't available before (even in simple frameworks).
> - second: IMHO its also very clear the Ruby itself is very much
> overhyped
> for the same reason. (it has everything I dislike about Python but
> few
> things I like in addition)
> Personally I would like to see some framework which pushes JavaScript
> to its limits, that would be a nice thing to see (but probably
> horribly slow as well)
>
> - if you really like Ruby, it should be very nice for small and fast
> hacks
> - if you know Java tech (J2EE, Struts etc), RoR should rock
> - if you know PHP, RoR should be nice (if you master Ruby in this
> case ;-)
> - if you know ASP.NET <http://ASP.NET>, RoR should be boring
> - if you know Zope, RoR should be quite boring
> - if you know (full) WO, you will be yawning
> This explains why some people love it and others don't understand it
> (eg I've seen Miguel de Icaza asked in some Mono forum for an
> explanation of the RoR hype ;-).
>
>
> Unfortunately its hard to describe WO because it contains soo
> incredibly many tools. So what are major WO features hardly available
> in other frameworks:
> - real web components (also for request processing, not just for page
> composition!)
> - very cool data binding facility (associations)
> - a really fast compiled language _and_ a good scripting language
> _and_ Java
> - well, this was only till WO 4.5 ;-)
> - since WO5 something in between (Java ...)
> - the most complete database access framework I know, from very simple
> (EOAdaptor) to very high level (EOEditingContext, hierarchie
> mapping etc).
> - Direct2Web, Direct2Java. While Ruby allows you to write simple apps
> with
> very little code, D2W allows you similiar applications with no
> code at all
> but with much more functionality and proper consistency (eg
> database
> independence, long running transactions, etc).
> In short: RoR contains maybe 5% of the functionality contained in WO.
> Note that a "I don't need that functionality for my simple app"
> doesn't count, since most of the stuff is framework functionality
> which makes zero-code apps like with WO possible.
> Notably all those functionality in WO have very clean and
> approachable interfaces and is very well modularized (unlike such of
> Java), so its no big monster, its just a big collection of cool
> modules.
> Also I didn't even mention Apple-only tools like WOBuilder which is
> InterfaceBuilder for WO templates and allows you to drag and drop
> connect reusable WO components.
>
> Note that with "WO" I don't mean SOPE. SOPE doesn't really compare
> for the avarage user because it (currently) just has the compiled
> language and you will be slower for fast hacks just due to that (you
> need to be able to use all the component reuse features to compensate
> for this).
> It further misses a complete implementation of D2* technologies as
> well as of EOF (well, you use AJR, which should be close).
> Only when we have integrated WebScript, EOF and D2W (SOPE 5?) we can
> start kicking away other "attempts" ;-) Right now SOPE is good for
> either complex applications which doesn't just consist of some HTML
> controller code or for applications which need to have very fast
> request handling.
>
>
> Well and if you want to write fast hacks and don't want to use WO (eg
> because of $$$ or Apple), IMHO Zope 2 is a better solution. Its
> mature, as easy as RoR, has a nice community and provides quite a lot
> of modules for various purposes (PDF generation, SXW parsing, form
> handling, etc ...)
>
> Another thing is using a relational database with RoR just doesn't
> make any practical sense. It can't deal well with huge database nor
> with existing/evolving databases. And for small databases there are
> much better technologies than RDBMS (eg ZODB, plain File, RAM etc).
> That RDBMS-is-good-for-everything is deprecated wisdom (it was
> different in 1995 when 20MB was all the system memory available).
>
>
>> * Anyone else taken a look and have an opinion?
>>
> *
> I know that Sebastian loves RoR and has written some application with
> it, we already discussed that to death ;-) Unfortunately its hard to
> discuss with RoR (or Zope) fanatics since most of them never used a
> *real* application server before ;->
>
> Greets,
> Helge
> _______________________________________________
> WebObjects-talk mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-talk
>
>