[Rails] [ANN] "Ruby for Rails" now available in PDF!

Ken Kousen
Mon, 17 Apr 2006 16:33:36 -0000

Hi Ashley,

To an experienced OO developer, the R4R book feels like a "Dummies"
book.
That''s a bit off-putting at first, but appropriate for its target
audience.
When you get beyond that, though, the meat of the language really is there.
I would say, therefore, that if you think the Java/C++ types in your
organization won''t mind the basic stuff, go for it.

My experience is that if you take a room full of Java developers and build a
simple e-commerce app using Rails in about 20 minutes, they become
sufficiently dazzled that they''ll want to see more.

As for Ruby gotchas, here are a couple (I''m eventually going to
assemble a
web page of these things):

1. If you''re in a method and you call "super" by itself, it
passes the
current arguments to the superclass version.  If you call "super()"
instead,
no arguments are passed.

2. In order to use setter methods that end in =, you have to say "self.var
value".  If you just write "var = value", you''ve created
a local variable
and set it rather than modifying the attribute.  Inside a method,
"self" is
"this".

3. If you declare an attribute outside a method (the way you normally do in
Java), you''re actually creating an attribute of the _class_ (i.e., a
static
attribute) rather than of an instance attribute.  You need to create
instance attributes inside a method.  Outside a method, "self" is the
Class
(!).

That''s a subset of the bigger issue:  In Ruby, "self !=
this", except when
it does. :)  That''s actually a huge problem for Java developers.  In
Java,
static methods don''t even have a "this" reference.  In Ruby,
"self" outside
a method means the Class object itself.  The chapter in R4R that explains
all that is worth the price of the book right there.

I''ll mention others as I go along.

Ken

--
Kenneth A. Kousen, Ph.D.
President
Kousen IT, Inc.
http://www.kousenit.com
ken.kousen@kousenit.com
-----Original Message-----
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Ashley Moran
Sent: Sunday, April 16, 2006 6:04 PM
To: rails@lists.rubyonrails.org
Subject: Re: [Rails] [ANN] "Ruby for Rails" now available in PDF!


On Apr 16, 2006, at 10:18 pm, Ken Kousen wrote:

> I agree with this completely.  As much as I like the pickaxe, I
> have to
> admit that I learned more about Ruby from the first half-dozen
> chapters of
> R4R than from any other source.


Ken,

I''m pushing Rails where I work, as at least something we should
seriously look into before switching to Java.  I''ve read the pickaxe
cover-to-cover and back again (before I even knew about Rails), and
consider myself pretty clued up language-wise.  But the developers I
work with are all Java/C# types.  Do you think buying a copy of this
would be the best way to get them up to speed if we go Rails?  I want
to keep my role as language tech support to a minimum, as the fact
using Rails was my suggestion means *I''ll* be responsible for *them*
learning to use the framework effectively!


> If you already know an OO language, you''ll have to filter out all
the
> beginning OO stuff.  Once you get beyond that, it''s amazing.
>
> I also can''t believe how many traps there are in Ruby for Java
> developers.
> I''m so glad I''m reading this (I''m not done yet)
before trying to
> finish the
> RoR projects I''ve started.

I was showing my boss some little tricks in irb the other day (the
"try this in Java" type) and he asked me if there were any gotchas.
At the time I couldn''t think of any (but then I''m not a
developer
myself so I haven''t used it for serious work).  What do you think are
the worst?  Might be nice to forewarn everyone - they can be a right
bunch of skeptics where I work :)

Ashley
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org