News for hackers. Stuff that matters.
Re:Hello Ruby – Almost there by bigtunacan on Monday August 03, 2015 @09:28AM (#9995590)
This is a book for teaching young kids. Trying to start them off with a language like Java or C# would be a terrible idea; not because they are bad languages, but because they have such a high learning curve.

With something like Ruby we can start the child right off with

puts 'Hello World'

Immediately they have a positive feedback cycle. At this stage they don't need to know that a top level object has been implicitly created for them and this statement is part of that object. We'll get to that stuff later. Start off basic with some simple lines of working code. Move up to conditionals, loops, add in methods later in a sort of procedural fashion. Eventually higher level concepts will be introduced.

Also to this point of yours, "It doesn't have first-level functions, instead it has blocks (which can take parameters to serve the same use as functions but aren't)."

That is one of those things that comes from someone that hasn't spent enough time with the language. While the treatment is slightly different, the outcome is the same. Ruby supports closures and passing methods to methods.

Before you retort with, "But blocks/procs aren't 'really' methods", you might also want to step back and realize that Ruby also allows any method to be passed as well using &Object.method(:method_name); that basically says "Oh hey; pass this method just like a block".

Re:Hello Ruby – Almost there by pluma on Tuesday August 04, 2015 @07:32AM (#10002680)
> Trying to start them off with a language like Java or C# would be a terrible idea

I'm not sure how you got the idea that I argued for Java or C#. I only mentioned them to rule out the argument that being widely used is a necessary or sufficient quality when determining what language you should teach to a beginner.

In the same vein I think we can also agree that Pascal is a horrible choice although it is still frequently used as an introduction to programming.

Re:Hello Ruby – Almost there by bigtunacan on Tuesday August 04, 2015 @11:32AM (#10004054)
No, I think we were on agreement on that point. You said, "If market use were the main concern you could probably argue for Java or C# (although I think starting with a class-based language locks you into the wrong mental model)."

I took your main argument to be that Ruby is a bad first language to teach kids and Python is a good first language to teach kids.

I was agreeing with you on Java/C# not being a good choice. I disagree with your opinion on Ruby being a bad first choice. I thought your argument was also that Python was a good (better than Ruby) choice. I actually agree that Python is ALSO a good first choice to teach children with; I do not believe it is a better choice than Ruby; rather I would say they are equally well suited.

Re:Hello Ruby – Almost there by WorldWideWayne on Monday August 03, 2015 @12:06PM (#9997097)
Sure, C# has a terrible learning curve because you'd have to type `Console.WriteLine("Hello World")` instead of `puts 'Hello World'`.

`Console.WriteLine` is also totally unclear as to what it does compared to `puts`, which basically says exactly what it does. /s

Re:Hello Ruby – Almost there by matchu on Monday August 03, 2015 @12:17PM (#9997244)
The difference isn't the actual print operation; it's all the boilerplate that has to go around it.

In Ruby, `puts "Hello World"` and you're done. The most you have to explain is puts and string literals.

In C#, you have to create a class with a static main method. You're then left to choose between explaining classes and methods ("what's static? what's void?"), or skipping that and just treating them as the magic incantation for running a program. Pedagogically, neither is satisfactory.

Ruby wins the Hello World simplicity contest, hands down. The question is whether the long-term benefits of C#'s program structure are worth the increased overhead in the Hello World experience.

Re:Hello Ruby – Almost there by eyejay on Monday August 03, 2015 @12:29PM (#9997383)
I think a huge plus for Ruby is the limited amount of specific punctuation required for calls like this. For you average middle or high school student this might not be a big deal, but as soon as you start working with elementary school students every small barrier to entry is a huge deal.

Books like this shouldn't be designed for the children that would enjoy hunting through and finding the missing quotation mark - those children already have tons of resources out there for them. I think Ruby is a great choice, specifically for this reason, and I wish there were more resources like this available when I was setting up K-5 CS curricula a few years ago.

Re:Hello Ruby – Almost there by WorldWideWayne on Monday August 03, 2015 @12:46PM (#9997576)
You don't have to create a class with a static method if you use LinqPad which can run like a REPL. It can also pickup a file with that single line in it and execute it, so there is virtually no difference.
Re:Hello Ruby – Almost there by twblalock on Monday August 03, 2015 @01:35PM (#9998068)
That's too many hoops for a child learning programming to jump through. There is a real difference in simplicity between Ruby and C#.
Re:Hello Ruby – Almost there by WorldWideWayne on Monday August 03, 2015 @01:47PM (#9998204)
Installing a program is not too many hoops. You have to setup a computer for ruby too and the kids aren't doing that part.
Re:Hello Ruby – Almost there by bigtunacan on Monday August 03, 2015 @02:34PM (#9998658)
If I'm on a Mac there is no setup; Ruby is pre-installed. Also, if they are just starting out and they don't want to keep things around there is tryruby.org.

For kids using Windows I usually have them sign up for a free account on Cloud 9; again virtually no setup required.

Also, now you are trying to compare LINQPad, a tool, to just using a language?

In your example you used `Console.WriteLine("Hello World")`, excuse me if I'm wrong since I don't write much C# anymore, but isn't that an invalid statement? I'm pretty sure that's missing a semi-colon at the end. Try explaining that to an 8 year old; because that's the age of kids I start working with.

10.times do

  puts "Hello World"
end

That is just easier to explain to a YOUNG child than the following

// Sorry: Using Java here since I don't do much C#, but I think we're in the same ballpark

public class HelloWorld {

  public static void main(String[] args) {

    for(int i=0; i<10; i++){

      System.out.println("Hello World");

    }

  }
}

None of what I said was an insult against any language; it was based on my experiences trying to teach programming to elementary aged kids (8 to 11 year olds).

Re:Hello Ruby – Almost there by WorldWideWayne on Monday August 03, 2015 @03:25PM (#9999115)
The kids could also not have Macs and there are similar services for running C# online, so those reasons don't hold any water with me.

What you're argument boils down to is that `10.times.do` is better than `for(int i=0; i<10; i++)` because all things being equal, that's the real difference. You could argue against braces, but the I could also argue against the lack of braces. So the real difference is how you write the controlling section of the for loop.

Now on that point alone, I'd say that `10.times.do` is certainly easier to parse, but easier is not better. Why teach them a bad habit? Learning `for(int i=0; i<10; i++)` is actually better for kids since it hides less and it is actually much more useful in the real world since that's how the most widely used languages do it. Or, are you one of those adults who thinks that hiding the real world from kids is a good idea?

I guess you could also say that there is a reason we make things slightly easier for beginners of any age. Like having training wheels. But that is so you don't get hurt and the computer is not going to hurt anyone if the program doesn't compile. I also honestly don't think age matters here after they've been through the second grade.

EDIT: Also, yes, you can leave the semi-colon off in a LinqPad expression. But I also don't see a problem with explaining what a semi-colon is to a second or third grader, in the context of programming. I could also say "good luck explaining those oddly placed periods to those same kids" and it would make as much sense.

Re:Hello Ruby – Almost there by dragonwriter on Monday August 03, 2015 @07:25PM (#10000584)
> Learning `for(int i=0; i<10; i++)` is actually better for kids since it hides less and it is actually much more useful in the real world since that's how the most widely used languages do it.

C-style for loops are useful, though I think the historical window (that started with the dominance of C) where the most popular languages lack a direct and succinct way of expressing simple do-it-n-times iteration is closing.

Ruby's particular form may be different than others, but lots of current languages have succinct, direct methods for expressing the same thing. By the time a young child learning to code today is a professional programmer, having nothing better than C-style general for loops to express that common idiom will probably be unusual in non-legacy languages.

Re:Hello Ruby – Almost there by matchu on Monday August 03, 2015 @05:41PM (#10000074)
Ruby offers an abstraction that other languages don't. That doesn't mean that using the abstraction is a bad habit.

I agree that C-style for-loops can be handy, but the prevalence of this shorthand doesn't make it good pedagogy to skip right to it. Not everybody is ever gonna enter the real world of programming, and not all of those people are going to use languages with C-style for-loops, and, even then, for-loops aren't fundamental; they're just a shorthand.