Gregory Seidman
2/27/2006 1:53:00 PM
On Mon, Feb 27, 2006 at 05:11:29PM +0900, Stephen Waits wrote:
} Hi Rubyists,
}
} I'm a game programmer by profession. I'm setting up a little "Learn
} Ruby" course for the rest of the programmers at work. Ruby may be
} useful for internal tools for us, but it's not embeddable because of
} the GPL. That's not really important though, because I've *mostly*
} pitched Ruby as "just being fun" for awhile now, and figure it's
} finally time to share.
}
} So, I'm seeking advice on how to approach my presentation.
}
} Duration: 90 minutes max
} Audience: bright C/C++ programmers, many with Python experience
} Goal: Teach the language rapidly, and Bedazzle
}
} Please chime in with your thoughts.
A lot depends on how deeply these people know C++. If they understand not
only how to use templates but also how to develop templates, then they
already understand duck typing. That is probably the deepest difference
they will have to get used to (that and the fact that there is no compiler
to perform static analysis and catch type errors).
They also need to understand how context and scope work. I mean a
couple of things by that. First off, everything not explicitly in a class
or module definition is considered to be in the scope of the Object class
definition. Second, there is no distinction between interface and
implementation, which means that directives (i.e. code execution, such as
attr_reader) can occur within a class/module definition. This is a HUGE
concept for a C/C++ person.
Then there's the whole hidden concept that the reason class names start
with capital letters is that they are constants (or act enough like them as
makes no difference). A class is a first-class object (which is also true
in C++ with RTTI, but only sort of), and a variable can reference it, e.g.:
class Card
#...
end
class BlackCard < Card
#...
end
class RedCard < Card
#...
end
Cards = { :spades => BlackCard,
:hearts => RedCard,
:diamonds => RedCard,
:clubs => BlackCard
}
two_clubs = Cards[:clubs].new(2)
Beyond that, it's just syntax and idiom. (Well, and the idea that the base
types include regexes, ranges, strings, and maps, a.k.a hashes.)
} Thanks,
} Steve
--Greg