Curriculum for Teaching Ruby to C++ Professionals

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.

Thanks,
Steve

Stephen W. wrote:

Duration: 90 minutes max
Audience: bright C/C++ programmers, many with Python experience
Goal: Teach the language rapidly, and Bedazzle

For me as a newbie to the language - the thing that really got to me was
why’s poignant guide - the explanation of blocks, dwemthys array (for
meta-programming) where both brilliant.

I found just working on some of teh ruby quiz challenges to be great fun
and a good way to learn how the language works

Kev

On Mon, 2006-02-27 at 17:11 +0900, Stephen W. wrote:

Ruby may be useful for internal tools for us, but it’s not embeddable because of
the GPL.

http://www.ruby-lang.org/en/LICENSE.txt

Ruby is dual licensed.
There are various people who embed ruby in their application and licnese
their code as license they choose.

"You can redistribute it and/or modify it under either the terms of the
"GPL (see COPYING.txt file), or the conditions below

The statement above means Ruby is dual licensed. You can have ruby
licensed as GPL, or use the following terms excluding any stated rules
which are contained within the GPL.

"1. You may make and give away verbatim copies of the source form of the
" software without restriction, provided that you duplicate all of
the
" original copyright notices and associated disclaimers.

The statement above means you can give ruby source away freely provided
you
don’t edit out any copyright.

"2. You may modify your copy of the software in any way, provided that
" you do at least ONE of the following:
"
" a) place your modifications in the Public Domain or otherwise
" make them Freely Available, such as by posting said
" modifications to Usenet or an equivalent medium, or by allowing
" the author to include your modifications in the software.
"
" b) use the modified software only within your corporation or
" organization.
"
" c) rename any non-standard executables so the names do not
conflict
" with standard executables, which must also be provided.
"
" d) make other distribution arrangements with the author.

You may modify ruby. You MUST do one of the following: (a)release
sources to
the general public, (b)use your modified version internally, or
(c)rename executables
so you don’t have to give out your changes, (d)make other agreements for
distrubution
arrangements with author.

"3. You may distribute the software in object code or executable
" form, provided that you do at least ONE of the following:
"
" a) distribute the executables and library files of the software,
" together with instructions (in the manual page or equivalent)
" on where to get the original distribution.
"
" b) accompany the distribution with the machine-readable source
of
" the software.
"
" c) give non-standard executables non-standard names, with
" instructions on where to get the original software
distribution.
"
" d) make other distribution arrangements with the author.

you may distribute ruby, or your modified ruby. You MUST do one of the
following: (a)Distribute your copy with a link to ruby-lang, (b)include
the source to ruby, or (c or d), same as above attached with a link to
http://www.ruby-lang.org

"4. You may modify and include the part of the software into any other
" software (possibly commercial). But some files in the
distribution
" are not written by the author, so that they are not under this
terms.
"
" They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and
some
" files under the ./missing directory. See each file for the
copying
" condition.

Some are not licensed under dual, please refer to the files themselves.

" 5. The scripts and library files supplied as input to or produced as
" output from the software do not automatically fall under the
" copyright of the software, but belong to whomever generated them,
" and may be sold commercially, and may be aggregated with this
" software.

The statement above means you can license your scripts under your
license of choice. The ruby runtime does not infect your license.

"6. THIS SOFTWARE IS PROVIDED “AS IS” AND WITHOUT ANY EXPRESS OR
" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE.

You can’t sue matz, the company who funds ruby development, nor any
other person contributing to the ruby project.

Okay, license explained. Any questions?


Tsume

Stephen W.:

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

If they can have laptops, and be networked (802.11?) you can use DRb to
great effect. Remember Why’s presentation at FOSCON last year?

Trudy sings, too | Scott Laird | Flickr (note the screen in the
background - I heard the audience controlled the colour of the
rectangles
there.)

You can do things like write classes on the fly and have the others use
them. You can have their code affect the big screen.

As far as actual content is concerned… let me mention Matz’ Ruby U.
Guide, which I don’t hear about too often. It covers Ruby well, and is
brief.

http://www.ruby-doc.org/docs/UsersGuide/rg/

Then, there are a few Rubyists who have done presentations and blog
posts on
coming to Ruby from Java. They provide key points on Ruby idiom you may
miss
as a Java (or C++) programmer.

Jim W.'s 10 Things Every Java Programmer Should Know About Ruby
http://onestepback.org/articles/10things/

Francis H.'s blog: Coming to Ruby from Java
http://fhwang.net/blog/40.html

Cheers,
Dave

On Mon, Feb 27, 2006 at 05:11:29PM +0900, Stephen W. 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

On Feb 27, 2006, at 12:37 AM, Tsume wrote:

Okay, license explained. Any questions?

Oops, thank you Tsume!

–Steve

On Tue, 2006-02-28 at 00:12 +0900, Stephen W. wrote:

On Feb 27, 2006, at 12:37 AM, Tsume wrote:

Okay, license explained. Any questions?

Oops, thank you Tsume!

If you have any problems embedding Ruby in any program, we would be glad
to help. Happy adventures.

Tsume

On Feb 27, 2006, at 12:58 AM, Dave B. wrote:

Stephen W.:

So, I’m seeking advice on how to approach my presentation.

Thanks to both Dave and Kev for the advice!

–Steve