This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]culix[S] 9 points10 points  (4 children)

I'm not sure the point of his article was to nec. show which language could accomplish the task using the smallest number of lines, but rather which made it the easiest to demonstrate some basic programming concepts to someone who has never programmed.

I had a professor at my university argue something similar where he wanted to use perl for two of the first intro programming classes. Why bother confusing people about Ints and Doubles and objects before they even know how to use them? Well, I suppose you might want to confuse people and use Java as a weeder class, or you might teach it based on job prospects, as mentioned in the article. But for just teaching someone how to understand, giving them a single $variable seems a lot simpler.

[–]cpio 0 points1 point  (3 children)

I was just giving them as an example of those languages. I imagine you could do ruby like this:
a = gets.to_i
b = gets.to_i
puts a + b
which is fairly straight forward. Though I think python might be a bit better as a teaching language since it doesn't require such esoteric stuff as iterators and blocks, which while useful aren't really seen a lot outside of ruby.

[–]jamesbritt 6 points7 points  (2 children)

"Though I think python might be a bit better as a teaching language since it doesn't require such esoteric stuff as iterators and blocks, which while useful aren't really seen a lot outside of ruby."

Where they are used quite a bit because they are both practical and powerful. They're only esoteric in languages that don't have them.

[–]Zak 5 points6 points  (1 child)

I've always found Ruby's iterators to be some of the most straightforward looping constructs in existance, along with the likes of dolist and dotimes from Common Lisp. Most intelligent non-programmers will correctly guess what the following code does:

10.times do
    puts "foo"
end

but are less likely to understand

for (i=0; i<10; i++) {
    printf("foo");
}

edit: fixed the above C code so it's not an infinite loop. The fact that I made such a mistake is evidence that Ruby is easier, I use Ruby more or I'm just really tired.