Teaching ruby as cs intro?


#1

My school teaches intro to programming with Java or C#, intro to cs
with Scheme, then requires two semesters of C to scare us into being
good and careful. Learning about Ruby has been a way nicer
experience and I think it would draw more kids into the major if it
was taught early on. What do you think?

Here’s my draft of what I’m sending to the Teaching and Learning
committee. Suggestions welcome.

Professors,

Ruby is a very powerful, very concise and readable, and I think very
easy to learn language. You should seriously consider teaching this
language at an introductory level. It combines the flexibility of
scripting languages, the modularity of object-oriented languages, and
the recursive/iterative chaining of functional languages. Perhaps it
would be overwhelming to present all these capabilities to young
students too quickly; nonetheless there’s enough documentation on the
web that motivated students could move beyond the problem sets and
start writing their own useful apps within their first semester (Ruby
is also rather addictive). There is an interactive shell (invoked
by /$ruby eval.rb ), so students would get instant feedback during
their initial debugging that would really help them quickly
straighten out their mistakes.

While it doesn’t run fast enough for every application, Ruby saves
quite a bit of programmer time, and it’s concise nature makes it
simple to maintain. The community is very agile and develops
programs at a surprising pace. Often these releases seem to have a
very modular nature that allows them to be incorporated usefully into
other apps, so in other words, the time-saving capabilities of using
Ruby are great and increasing. I cannot wait to see what libraries,
software, and websites are available this time next year (hopefully
by then I’ll be able to understand all their code too). Along with
lessons on theory, syntax and conventions, I suggest that you offer
some lessons on checking documentation and wikis, and installing and
using libraries. In fact, many wiki pages might be well-written
enough that you could lecture right off of them, reducing the burden
of preparation (also, if the lecturer ran across a question she
couldn’t answer, she could post to the Google group comp.lang.ruby
and probably have an answer before the lecture was over). This
combination of simplicity, facility, documentation, and human
explanation is something Yale students could use to great benefit in
the coming decades, whether or not they take additional CS classes.

I encourage you to investigate Ruby for your own uses - you may find
that it plays very nicely with the codebase you already have. I hope
you and your students will find it as useful as I have.

-Mike

http://www.rubygarden.org/ruby?RubyIdioms <- a taste of Ruby
http://www.ruby-doc.org/docs/ProgrammingRuby/ <- a free textbook
(newer version available)
http://www.ruby-forum.com <- discussion of real-world uses
http://www.zenspider.com/Languages/Ruby/index.html <- papers from
Ruby conferences


#2

Hi Mike,
maybe you could give them a small example of the concise nature of ruby
by writing a small java program and then rewriting it in ruby?

for example:

On 10/11/05, Florian F. removed_email_address@domain.invalid wrote:

Easy: “puts” is a command that puts a string out on your console.
}
the variable name. Then the string "Hello, " is appended to the string
BufferedReader reader = new BufferedReader(isr);
String name = null;
try {
if ((name = reader.readLine()) != null) {
System.out.println("Hello, " + name + “\n”);
}
} catch (IOException e) {
System.err.println("Caught: " + e);
}
}
}


#3

Mike S. wrote:

by /$ruby eval.rb ), so students would get instant feedback during
software, and websites are available this time next year
(hopefully
by then I’ll be able to understand all their code too).

I’d delete that ^^^ sentence as it somewhat contradicts your statement
about clean syntax etc. :slight_smile:

the coming decades, whether or not they take additional CS classes.
http://www.ruby-forum.com <- discussion of real-world uses
http://www.zenspider.com/Languages/Ruby/index.html <- papers from
Ruby conferences

Sounds good all in all. I’d put the main focus on the clean OO and
syntax, rich std lib and wide range of programming paradigms covered as
these are the items that best support chosing ruby as learning language
IMHO.

Let us know the outcome!

Kind regards

robert

#4

Selon Mike S. removed_email_address@domain.invalid:

My school teaches intro to programming with Java or C#, intro to cs
with Scheme, then requires two semesters of C to scare us into being
good and careful. Learning about Ruby has been a way nicer
experience and I think it would draw more kids into the major if it
was taught early on. What do you think?

I completely agree. It would also be good to teach it early because it
introduces concepts that are wrongly considered high-level in a familiar
setting. I’m talking about closures, iterators, continuations, etc…
Most of
those concepts are usually taught only much later on, while the students
have
got used to languages that don’t have them. The result is that they get
to be
considered as arcane and complicated features one should use only when
one
cannot do things in a classical way, while they are actually pretty
simple and
powerful concepts (closures in particular are very intuitive) which just
suffer
from bad press. It would be good that students get to learn those
concepts
quickly, as they seem to be getting more and more common, and they will
need to
understand them. And Ruby, with its non-intrusive syntax, is the best
candidate
for teaching them.

Just my 2 eurocents anyway :slight_smile: .

Christophe G…

http://rainbow.conlang.free.fr

It takes a straight mind to create a twisted conlang.


#5

On Nov 23, 2005, at 9:49, Mike S. wrote:

My school teaches intro to programming with Java or C#, intro to cs
with Scheme, then requires two semesters of C to scare us into
being good and careful. Learning about Ruby has been a way nicer
experience and I think it would draw more kids into the major if it
was taught early on. What do you think?

I agree whole-heartedly that Ruby would make an excellent
introduction to programming, but as it stands, I don’t think your
letter would get any serious consideration unless someone on the
committee was already evangelising Ruby and could say “look, students
want it too”. Stylistically, it reads a bit like this:

“You should use Ruby because it’s great, it’s great, ok, maybe some
things aren’t great, but really it’s great, and all the things about
it are great, so you should use Ruby.”

I’d suggest separating the various ways why Ruby is great, and giving
particular examples. Since you’re suggesting that it’s used in the
early stages of the program, concentrate on things of interest in
that context. To be clear: neither “writing useful apps in [one’s]
first semester” nor an active developer community are as relevant to
an introductory course as “how can a student learn general
programming principles from this language”.

I think that in much of your letter you’re explaining why Ruby a good
language to learn, instead of explaining why Ruby would be a good
language to teach, and the two are not necessarily the same thing.
For example, Java forces students into using OO in a very explicit
way and Scheme forces students into using functional programming.
Students may (and do) use them in extremely degenerate ways[1], but
these excursions tend to be easy to spot, easy to correct, and most
importantly, easy for the instructor to explain and the student to
understand.

Introductory exercises in programming aren’t usually about the output
of the program, but about how you get there. One of the difficulties
of using languages like Ruby (or Python or Perl) in introductory
settings is that because the language paradigms aren’t as apparent in
the syntax, the point you’re trying to illustrate (loop invariants,
binary search, recursion vs. iteration, etc) can get lost in the mix,
or obscured by a language idiom, and it’s very difficult for an
instructor to explain what’s “wrong” because nothing really is wrong,
it’s just not what we were trying to show the student with that
exercise.

If you wanted to explain the strengths of Ruby as a teaching tool, I
would devote more time to describing the theoretical aspects of the
language. I might mention, in particular, closures and blocks
(http://www.rubygarden.org/ruby?ClosuresAndBlocks and http://
www.whytheluckystiff.net/ruby/pickaxe/html/tut_containers.html),
noting they’re similar to Scheme, as well as iterators and mixins.

That all said, being easy to learn is itself a good reason to
consider a language for teaching. On this aspect, I’d discuss the
relative readability of the syntax - perhaps with a reference to the
Poignant Guide, particualrly this bit: http://poignantguide.net/ruby/
chapter-3.html#section1 or maybe with a short example from Java:

for ( Iterator i = mySet.iterator(); i.hasNext(); ) {
String element = (String) iter.next();
System.out.println(key);
}

my_set.each { |element|
puts element
}

Along with lessons on theory, syntax and conventions, I suggest
that you offer some lessons on checking documentation and wikis,
and installing and using libraries.

Remember that they won’t restructure the entire program to use Ruby
in introductory courses. If the program does a lot of C in later
courses, I don’t think changing their prerequisite courses to use
Ruby over a more C-like language would fly. I’d suggest finding a
potential niche for Ruby in your program, and giving reasons why it
might fit there. Though I don’t know the program there, good choices
might be programming courses for non-programmers, or a course on bio-
informatics (look up bio-ruby). Suggestions of this nature tend to
carry more weight than just suggesting “teach Ruby”. This approach
would also make the “useful apps fast” point carry a lot more weight,
since students taking those types of courses aren’t necessarily in a
CS stream, but do want some useful skills to support their core studies.

As a final bit of feedback, I would specifically leave out this bit:

In fact, many wiki pages might be well-written enough that you
could lecture right off of them,

No matter how lazy your professors actually are, noone enjoys the
implication that they can’t do their job on their own, or could be
replaced by a small shell script.

Best of luck.

[1] I recently tutored a course which introduced Java to a group of
AI students, some of whom had only ever used Prolog. Looking at the
code they generated was an invaluable experience for me as an
instructor. How do you explain classes and objects (or even scope)
to someone who thinks of every variable as effectively global?


Matthew S. removed_email_address@domain.invalid
Institute for Communicating and Collaborative Systems
University of Edinburgh


#6

On Wed, 23 Nov 2005, Matthew S. wrote:

[Lots of good points trimmed]

Remember that they won’t restructure the entire program to use Ruby in
introductory courses. If the program does a lot of C in later courses, I
don’t think changing their prerequisite courses to use Ruby over a more C-like
language would fly.

If the teaching uses a lot of C in later courses, it might be argued
that the Ruby facilities for embedding C code are well developed and
intended to be easier than some languages.

    Hugh

#7

Mike S. wrote:

There is an interactive shell (invoked by /$ruby eval.rb )

irb ?

http://www.rubycentral.com/book/irb.html


#8

On Nov 23, 2005, at 4:49 AM, Mike S. wrote:

http://www.rubygarden.org/ruby?RubyIdioms <- a taste of Ruby
http://www.ruby-doc.org/docs/ProgrammingRuby/ <- a free textbook
(newer version available)
http://www.ruby-forum.com <- discussion of real-world uses
http://www.zenspider.com/Languages/Ruby/index.html <- papers from
Ruby conferences

If this list of resources is part of what you plan on sending, I
would leave off that first URL. One reason we have an idioms page is
because the meaning of the code in the idioms is not readily
apparent. I think a far better leading url would be pointing to a
small, non-obfuscated ruby program that performs a task common in a
CS teaching environment. Something clean and readable and
appropriately commented. Something that is probably understandable to
a CS professor who doesn’t know ruby but does know coding, and hence
may be able to appreciate the language.


#9

Christophe G. removed_email_address@domain.invalid writes:

introduces concepts that are wrongly considered high-level in a familiar

Just my 2 eurocents anyway :slight_smile: .

Just wanted to throw that in:
http://www.ccs.neu.edu/home/matthias/Presentations/FDPE2005.html

Ruby would make a great second language there, I think.


#10

In message
removed_email_address@domain.invalid, Gregory
Brown removed_email_address@domain.invalid writes

I agree, Ruby should be taught at universities, I also agree that it
should be taught rather early, but surely not as an intro to CS
course. Computer science is about fundamental operations of the
computer and manipulations of that… that’s what makes C ideal for
such things. Programming is about solving tough problems cleanly and
efficiently, and Ruby is great for that.

I agree with this. Every software engineer that I have worked with that
I respected and knew that I could rely on to get the job done has been
someone with a fundamental understanding of the low-level workings, word
sizes and so on (I’m well into my 3rd decade on this now). They’ve all
been bitten by rounding and truncation errors due to hardware
limitations imposed by the processor and pointer failures and so on.
Their understanding is deeper than the people that didn’t do the
fundamentals.

11 years ago I went to a job interview once where they showed you some
code and asked you to list what was wrong with the code. It contained
all sorts of syntax errors and some subtle logic errors. I missed most
of the syntax errors (as I wasn’t looking for them) but found all the
logic errors including one that no other applicant had ever found. The
reason I found that error was because of my background working in
assembler and C on embedded systems where you had to know the word sizes
and so on. They commented about me missing the syntax errors and I
pointed out the compiler would find those but would never find the logic
errors. I got the job. This story isn’t to fluff my ego, its to
demonstrate the value of this low level knowledge. For the bug concerned
the code had an error that caused to only count the first 4 bits of the
32 bit word it was scanning.

For the tools that Software Verification make and which I have a hand in
the research behind them we could not make or perform the reverse
engineering and hooking required without this knowledge. All the Ruby
experience and high level concepts in the world would not help in this
task.

Teach them the fundamentals, with real experience using C or assembler -
something where they can make mistakes due to hardware limitations. Then
teach them Ruby (and keep them away from Java).

Stephen


#11

On 11/23/05, Mike S. removed_email_address@domain.invalid wrote:

My school teaches intro to programming with Java or C#, intro to cs
with Scheme, then requires two semesters of C to scare us into being
good and careful. Learning about Ruby has been a way nicer
experience and I think it would draw more kids into the major if it
was taught early on. What do you think?

What I’m about to say might come as a surprise to many, but I
personally don’t believe Ruby is an excellent language for an
introductory computer science course. (Before the axe comes down,
bear in mind that in 02 years, the University of New Haven WILL have a
Ruby centric class, due to my prodding )

Now back to the point at hand. Good computer science and good
programming are NOT the same thing. The lines between programming
and Software Engineering blur somewhat, but not even completely,
wheras theoretical computer science and programming are barely in the
same field.

I originally thought when entering my university, wow, CS is going to
make me a better programmer. It doesn’t. In fact, the limited
scope of the courses would actually hinder people from becoming good
programmers if they did not go beyond what was taught in class.

Ruby is wonderful to work in… it’s reasonably easy to learn, and we
all know of it’s clean syntax, inherent beauty and simplicity, etc.

But have you ever stopped to wonder about how it works? How readily
could you drop to it’s C source and understand how various features
were implemented. As someone who’s taught programmers and
non-programmers alike how to do ruby, I find it is far easier to show
them how specific things are used (closures, iterators, etc) than it
is for me to explain what’s going on under the hood.

If CS (especially elementary CS) is all about the things that are
going on under the hood, well… Ruby is downright horrible for that
because it is designed specifically to seperate us from the low level
frameworking that needs to be done to do something simple like
something.sort

I agree, Ruby should be taught at universities, I also agree that it
should be taught rather early, but surely not as an intro to CS
course. Computer science is about fundamental operations of the
computer and manipulations of that… that’s what makes C ideal for
such things. Programming is about solving tough problems cleanly and
efficiently, and Ruby is great for that.

I have long suggested that my university teach a course on practical
programming tools, practices, and languages. I think this could be
an entire track of courses, delving into the agile methodology,
revision control systems, continuous integration, unit testing,
‘Agile’ languages such as Ruby and Python, installation of 3rd party
libraries, packaging and preparing software for release, etc. There
is a wealth of knowledge in these topics, but when you mix in
academia, who knows what will happen to them. Still, this is worthy
of seperating from the more fundamental ‘computer science’ which has
excellent application to research and other related fields but limited
if not minimal relevance to practical applications.

Nevertheless, I do think it’s great you’re fighting to get Ruby into
your university. However, instead of fighting, you might try
petitioning for additional courses to be added, rather than changing
courses rather radically. This is generally easier on everyone, and
doesn’t hurt anyone who loves to munge around in C all day :wink:

Well. theres my rant for the day. Hope this wasn’t too much
flamebait.


#12

On Nov 23, 2005, at 16:07, Gregory B. wrote:

If CS (especially elementary CS) is all about the things that are
going on under the hood, well… Ruby is downright horrible for that
because it is designed specifically to seperate us from the low level
frameworking that needs to be done to do something simple like
something.sort

Computer science is about fundamental operations of the
computer and manipulations of that… that’s what makes C ideal for
such things.

Firstly, it’s important to remember that CS is a very, very broad
topic, taking in material which 50 years ago would have been taught
in anything from Philosophy (logic) to Mathematics (combinatorics and
algebra) to Engineering (elrctronics) departments. I think that part
of your disagreement stems from what amounts to a naming problem -
part of the reason they’re moving to the term “informatics” at the
uni here and a few other places in Europe.

I think, though, that you’re being to narrow in your definition of CS
being limited to the fundamental operations of a computer. Given
that definition, I’ll readily agree that Ruby may not be a
particularly good tool to study that level of operation of a computer
(though one of the most informative undergraduate courses I ever did
was modifying an actual Real World compiler).

I’d argue that more properly, you could define CS as the study of
fundamental operations of computation, which you can then abstract
to any given level, whether it’s the physical level of logic gates or
the abstract heights (or depths, depending on your predilections) of
the lambda calculus.

Given this definition (which is closer to what’s called “informatics”
here), it’s for the exact same reasons you think Ruby is a bad
language, that I think Ruby is a good language. Ruby (and languages
like it) let you focus on a particular level of abstraction without
the burdensome externalia of pointers, memory allocation, etc. I
find Ruby particularly good because it can be useful across a large
section of this set of abstractions. It can be usefully simple for
teaching things like quicksort, binary search, and the like, while
being rich enough to be illustrate (and implement) domain-specific
languages, metaprogramming and the like.

I originally thought when entering my university, wow, CS is going to
make me a better programmer. It doesn’t. In fact, the limited
scope of the courses would actually hinder people from becoming good
programmers if they did not go beyond what was taught in class.

Hereafter is my own little rant, because I hear this sort of
complaint all too often, usually phrased as “If I’ll never have to
implement quicksort, why should we do it in class?”

One of my professors once said something to a (first-year) class I
was in that has stuck with me ever since, not just in reference to
university, but actually as very good advice on how to live your life
in general. It went like this:

“In high school, you went to classes to be taught. In university,
you go to classes to learn.”

The implication is that being taught is passive, whereas learning is
active. One is done to you, and the other one you do for yourself.
By extension, what goes on in class is the beginning of what you
should learn, not the end. This active approach to learning (whether
in a university setting or not) is something that you will find in
anyone who excels in their field, whether that’s informatics,
medicine, or fine art.

(as a closing note, I’ll add that this isn’t meant to reflect on the
original poster, since it’s fairly obvious that he’s quite active in
his own education)

matthew smillie.


#13

On 11/23/05, Gregory B. removed_email_address@domain.invalid wrote:

Yes. absolutely. I am in favor of splitting the naming of the
topics. I interpret ‘computer science’ as “science of the computer”
and “software engineering” as the study of engineering software, and
“information technology” as the focus on technology.

Whoops… I realized that this might not be clear… I meant that
software engineering was the focus on designing and building software
using the engineering process, not necessarily designing like… a set
of modeling systems or something :slight_smile:


#14

On 11/23/05, Matthew S. removed_email_address@domain.invalid wrote:

such things.

Firstly, it’s important to remember that CS is a very, very broad
topic, taking in material which 50 years ago would have been taught
in anything from Philosophy (logic) to Mathematics (combinatorics and
algebra) to Engineering (elrctronics) departments. I think that part
of your disagreement stems from what amounts to a naming problem -
part of the reason they’re moving to the term “informatics” at the
uni here and a few other places in Europe.

Yes. absolutely. I am in favor of splitting the naming of the
topics. I interpret ‘computer science’ as “science of the computer”
and “software engineering” as the study of engineering software, and
“information technology” as the focus on technology.

In my university (and many others) the traditional computer science
program is exactly that, the science of computers. It is not software
engineering nor IT nor informatics.

I think, though, that you’re being to narrow in your definition of CS
being limited to the fundamental operations of a computer. Given
that definition, I’ll readily agree that Ruby may not be a
particularly good tool to study that level of operation of a computer
(though one of the most informative undergraduate courses I ever did
was modifying an actual Real World compiler).

I simply believe that CS as an amorphous concept is misleading because
it does not tell you what you can expect from a program.

I’d argue that more properly, you could define CS as the study of
fundamental operations of computation, which you can then abstract
to any given level, whether it’s the physical level of logic gates or
the abstract heights (or depths, depending on your predilections) of
the lambda calculus.

I’d agree that CS is the study of computation more so than computers
(thanks for the better wording!), but I do not believe this scales to
practical programming. Good science? sure. Important base for
becoming a good programmer? YMMV, but generally, yes. Practical
programming experience? Absolutely not.

Given this definition (which is closer to what’s called “informatics”
here), it’s for the exact same reasons you think Ruby is a bad
language, that I think Ruby is a good language. Ruby (and languages
like it) let you focus on a particular level of abstraction without
the burdensome externalia of pointers, memory allocation, etc. I
find Ruby particularly good because it can be useful across a large
section of this set of abstractions. It can be usefully simple for
teaching things like quicksort, binary search, and the like, while
being rich enough to be illustrate (and implement) domain-specific
languages, metaprogramming and the like.

Pointers and malloc, etc. are part of the science of computation.
Ruby is part of informatics, and of practical programming.

Domain specific languages, metaprogramming, etc are all wonderful
programming examples. They’re not good computer science. I believe
that programming is more of an art than a science to begin with, and
that a strong CS base CAN help you, but they are not necessarily
inter-related, and therefore should be seperated in academic majors.
(with the necessary degree of overlap)

The bottom line is… if I want to learn to be a good programmer, I
want a major that will help me do that. My CS major is essentially
preparing me to be a good thinker and computational scientist, which
has some merit, but certainly is secondary to my goal.

“In high school, you went to classes to be taught. In university,
you go to classes to learn.”

The implication is that being taught is passive, whereas learning is
active. One is done to you, and the other one you do for yourself.
By extension, what goes on in class is the beginning of what you
should learn, not the end. This active approach to learning (whether
in a university setting or not) is something that you will find in
anyone who excels in their field, whether that’s informatics,
medicine, or fine art.

I go to class in my university to get a degree, sadly. I go to
ruby-talk and work to ‘learn’.
I fully agree with your sentiment, and though it may not have been
evident in my post, I do certainly advocate students to do the legwork
on their own.

As far as ruby goes… I’ve learned plenty by doing. I’m currently
working on a number of projects that are on RAA and RubyForge. I
won’t babble on about that though.

However, you won’t see much of my computer science creeping into my
Ruby activity, because it simply is not relevant. I’d hope some day
to do some research in computational theory, and I am doubling in math
for exactly that reason, but my only point is though this background
does play a secondary role in preparing me to be a better programmer,
it is a primary education I seek from my institution, and I (among
others) are left wanting in this area. Computer Science is not
programming. At least not at the University of New Haven.