Hacker News new | ask | show | jobs
by bigtunacan 3977 days ago
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".

2 comments

> 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.

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.

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

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.

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.

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.
That's too many hoops for a child learning programming to jump through. There is a real difference in simplicity between Ruby and C#.
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.
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).