News for hackers. Stuff that matters.
Re:Why teach with Ruby? by steveklabnik on Thursday October 14, 2010 @11:08AM (#1791139)
This post was a lot of work, and I'd love to hear your thoughts, HN. Please tear me apart. :)
Re:Why teach with Ruby? by michaelchisari on Thursday October 14, 2010 @11:42AM (#1791288)
It seems a lot of the "magic" with Ruby comes from Rails, and I would say that teaching a new language using a framework is probably going to be pretty overwhelming to any beginner.

One thing I would worry about with Ruby as a teaching language is that the syntax is somewhat unique. I don't think this is a terrible thing, the basic structure is similar once you get past the syntax, but I think it can trip people up if it's their first language, and then they move on to Java/C++/Perl/Python/PHP which seem to follow more of a continuity.

I think, from my experience, I actually think learning a couple different languages at once can be really advantageous. I pretty much learned Pascal, C and Assembly at the same time, working in the demoscene, and linking them all together.

The important part of programming isn't the syntax, it's the structure and the concepts. You can always look in the manual for syntax, but structure and concepts are the hardest parts to grok.

So maybe my suggestion is to have side-notes for the examples that say, "here's how you do this in PHP, here's how you do it in Java, here's a breakdown of the differences and similarities."

On the other hand, I may be completely wrong, because I'm biased based on how I learned programming, and not everyone learns that way.

With all that said, this is a pretty great piece.

Re:Why teach with Ruby? by SlyShy on Thursday October 14, 2010 @11:47AM (#1791311)
As a TA for an intro to programming class taught using Java, I wish, wish, wish we were using Ruby instead. I spend 70% of my time teaching people Java's obtuse syntax, rather than teaching the underlying concepts. Once a programmer has developed the concepts, she can code in nearly any language, but she really has to learn the concepts. Ruby's syntax is straightforward enough that little kids get it down in days, so students can actually learn computer science rather than Java science.
Re:Why teach with Ruby? by mike-cardwell on Thursday October 14, 2010 @11:55AM (#1791355)
It depends what you're learning. If all you're learning is to memorise blocks of code, then Ruby is probably easier to learn because there's less of it. If you're trying to learn what a programming language is actually doing, I don't think Java is any more difficult than Ruby. If anything, most Java code is a lot more clear about exactly what is going on.

FWIW, I learnt and tutored Java at University and have recently been learning Ruby and Ruby on Rails for fun.

Re:Why teach with Ruby? by SlyShy on Thursday October 14, 2010 @12:04PM (#1791391)
Learning what a programming language is actually doing is good, but arguably that is a different course than an intro to CS course.

One big advantage Ruby has over Java is that irb is simply a snap to use.

Re:Why teach with Ruby? by michaelchisari on Thursday October 14, 2010 @12:02PM (#1791385)
We also can't underestimate how much of an effect being familiar with a certain style and syntax has an effect on our judgment of languages which break from that style.

Since I started with Pascal and C++, and then branched to Perl and PHP, the first time I looked at Ruby code, it looked like gibberish. But Java and Google Go immediately looked very familiar to me.

I've since learned Ruby better, and it's kind of come into focus, but I think that's definitely something to keep in mind when we're teaching programming to others.

Re:Why teach with Ruby? by michaelchisari on Thursday October 14, 2010 @11:52AM (#1791332)
I think the hallmark of any good teaching language is the ability to get up-and-running quickly, and Ruby (and PHP and Perl and Python and scripted languages in general) have that over Java, C++, and others.

But I think it's important to compare and contrast languages for just that reason, so that when moving to a language which requires a lot of preparation before you can even echo "Hello, World", the student doesn't get frustrated.

Re:Why teach with Ruby? by sigzero on Thursday October 14, 2010 @11:53AM (#1791341)
I agree...it should the language and language only if you are teaching a beginners class.
Re:Why teach with Ruby? by jablan on Thursday October 14, 2010 @12:37PM (#1791528)
Thanks for the post, and I completely agree. However, there is one thing about Ruby that could have been better, considering Ruby as a didactic language: TMTOWTDI (more than one way to do stuff) concept which Ruby borrowed from Perl: although it arguably helps with "the principle of the least surprise", I find it confusing when it comes to learning: multiple names for the same methods, {/} and begin/end block syntax, completely superfluous for keyword first come to mind, and even optional parantheses for method calls could be confusing, especially when they collide with operator priority.

Slightly unusual syntax, comparing to the mainstream languages, shouldn't worry anyone, since 1) it's really not that different (we're a bit spoiled there, as languages are lately crafted to mimick each other as much as possible - to facilitate "brain drain" from rivaling camps) 2) the aim is not to "learn to make money by programming", but to learn to code 3) opinions here are highly biased, because we already learnt programming our way.

Re:Why teach with Ruby? by happy4crazy on Thursday October 14, 2010 @12:20PM (#1791458)
I've been teaching myself programming over the past six months or so, and I'm very glad that I started with Ruby.

The syntax is clean, and I think it's awesome that Ruby's object model is so elegant. I agree that the magic parts are frustrating at first, but it's pretty neat that you can spend a couple weeks reading, e.g. Paolo Perrota's Metaprogramming Ruby, and then actually know how it works!

In terms of conceptual and syntactic elegance, I personally prefer Ruby to, say, Python. I watched most of the videos for MIT's intro CS class (available on academicearth.org), which uses Python, and just never particularly enjoyed it. It just struck me as messier than Ruby. That said, I'm sure I should give Python another chance.

But at the end of the day, I think the main advantage of Ruby over something like Java, at least as a teaching language, is that you get a REPL. My memory of complete-noob-hood is still fresh enough to say that being able to do interesting things in a REPL is HUUUGE. And even now that I've got a bit more programmatic maturity, I wouldn't have gotten nearly as far with Haskell as I have without GHCi.

So... I wonder what it would be like to teach a class using Javascript? Marijn Haverbeke's book, Eloquent Javascript, is pretty awesome, and I bet you could teach a pretty sweet class using it in conjunction with something like Node (for its REPL, in addition to all its other webby goodness). Hmm...

Re:Why teach with Ruby? by kenjackson on Thursday October 14, 2010 @11:59AM (#1791370)
Good post, although I disagree with it :-)

One thing that bugs me is the Hello World example. While I completely agree that the Ruby is example is far cleaner, the Java/C/C++/C# example doesn't add much confusion in my experience teaching intro programming. The concept of classes is often confusing, but setting aside the code isn't much of a mental challenge for any student I've met.

It just feels like its the wrong place to have the discussion of magic. The places I see students get tripped up is with iterators, recursion, classes, byref, and metaprogramming.

I think the standard ceremony vs convention concern that people in the blogosphere love to talk about is generally a non-issue for almost everyone except those people who like to blog about it. Show how those other issues are made simple, yet don't miss important facts, with Ruby (or whichever language you think is most effective) and you've made a powerful case (note, I think this is largely the argument as to why SICP is so well regarded as it did a decent job on most of those).

Re:Why teach with Ruby? by steveklabnik on Thursday October 14, 2010 @12:39PM (#1791532)
> The concept of classes is often confusing, but setting aside the code isn't much of a mental challenge for any student I've met.

While I have little formal teaching experience, I hung around in the undergraduate lounge in school, which is where students came for help. I ended up helping a lot of non-majors with their first CS class, which was popular because it filled a general requirement for an Arts and Sciences degree.

These two classes were in Java and in VB6, and they struggled with anything that wasn't near-rote application. They had trouble with the scoping of variables, they didn't know when to use functions appropriately... if you say 'what does x = 5 do?' they can answer, but they can't apply that to writing new programs.

My friends who are TAing courses now have several students who end up turning in homework that doesn't even compile. Maybe students at your school are just smarter than mine, but a lot of people struggle here.

> It just feels like its the wrong place to have the discussion of magic.

It's true, I am conflating 'magic' slightly. I don't mean 'they can't properly metaprogram,' I mean it in the "any sufficiently advanced technology is indistinguishable from magic" sense. They struggle to apply what they see as magic incantations to new problems, because they don't have a solid foundation to work with.

Re:Why teach with Ruby? by kenjackson on Thursday October 14, 2010 @01:39PM (#1791778)
So I taught intro CS for CS majors. I can totally believe that for a subset of non-CS majors this could be more problematic.

My old submission program wouldn't let them turn in programs that won't compile (nor will it let them submit without it passing the example tests I gave them).

This was about eight years ago... Maybe students just aren't as smart anymore ;-)

Re:Why teach with Ruby? by BCGC on Thursday October 14, 2010 @09:56PM (#1793392)
Absolutely agree :)

But seriously, if the students turn in programs that won't even compile, I'd say the blame should be on the TAs and the Profs!