News for hackers. Stuff that matters.
Re:My Students Laugh, HaHa, Laugh, at the HN Naysayers ;) by callahad on Tuesday January 25, 2011 @09:23PM (#2141836)
I have no doubt that you can get 11-14 year olds to understand Java's Hello World in a single hour, but understanding a pre-written snippet of code is a wholly different beast from being able to make appropriate predictions and inferences based on knowledge gleaned from that code.

Could your students explain how main() was called? Could they create their own functions and invoke them based on what they had learned? And how forgiving would Java be of minor errors, say, creating class a class named HelloWorld inside a file named Hello.java? Why does the filename even matter, if the class's name is defined right inside the file, or vice versa? And if the class is in a block inside the file, why can't they just create another block like the first one and have two classes in the same file? Why do they type 'javac HelloWorld.java', but not 'java HelloWorld.class'? How can java find the HelloWorld class if you're not pointing it to the class file? Why is 'javac' so damn picky about the file name matching the class name when you don't point 'java' to any files at all?

Seriously, there's a ton of voodoo in there. Things break in surprising ways, and it's hard to synthesize new knowledge based on prior experience.

Take Python, on the other hand. You can address things in a much more controlled order, with each step yielding practical information, starting with

  print("Hello, world")
which tells the students how to call a function, and pass it an argument. Every other time they call a function or pass it an argument will look like this. Then you can show them how to make their own function:

  def hello():
    print("Hello, world")
But nothing gets printed? Hey! You've just explained defining a function, and based on the previous example, they can probably suggest how to invoke hello(). At this point, they can easily make and call new functions of their own. Then you can go on to introduce the basics of OOP:

  class Greeter():
    def __init__(self, name):
      self.name = name
    
    def say_hello(self):
      print("Hello, " + self.name)
Sure, the "self" is a little magical there, but hey, you're comparing this to Java. Plus, you've got an interactive console that you can jump into and poke at the darn thing. Hey, what do I get when I say g = Greeter("Saundby")? Oh a "Greeter object". That makes sense. What can I do with it? Well, we made a say_hello, so what's g.say_hello? Oh, a "method Greeter.say_hello of <Greeter object>." And hey, it's the same Greeter object as g!

What if the students want to make a new class? They just put it in the same file, like you would expect. What if they want to rename the class? They just do it.

And you run it with "python filename.py" which appears to work exactly like how every other command that operates on files. There's no explicit compilation step to forget or trip over.

Yes, you can teach kids to read and understand a Java program, but what do you gain by handicapping yourself and foregoing the pedagogical tools, like an interactive console, available elsewhere? Similarly, what do they gain by being deprived of such a wonderful and frictionless means of exploring and experimenting with the language?

Re:My Students Laugh, HaHa, Laugh, at the HN Naysayers ;) by kenjackson on Tuesday January 25, 2011 @11:59PM (#2142211)
Seriously, there's a ton of voodoo in there.

And your solution is Python?

Not surprisingly, as a kid my 1st language was BASIC. My second language was 6502 assembly in 6th grade. I can honestly say that things didn't really click until I learned assembly -- things like line numbers bugged me, and some of the syntax in BASIC confused me (why does a function call have the same syntax as an array?). And then I studied digital logic circuits, with a brief diversion into CRT displays and video support in computers (I was really concerned about how did the information go from the computer to the screen) in junior high, and then C in 9th grade.

Python has a lot more vodoo than BASIC did. And whitespace having meaning is truly confusing, especially as a kid when its unclear that there's really a distinction between different types of whitespace (this used to kill me with Makefiles when I first started with those).

I guess my point is is that what a seasoned pro thinks of as voodoo is often very different than what a child just learning to program thinks is voodoo... especially young kids who like to ask lots of questions.

Re:My Students Laugh, HaHa, Laugh, at the HN Naysayers ;) by callahad on Wednesday January 26, 2011 @01:19AM (#2142373)
I illustrated the post with Python since it's my language of choice, but honestly, many of Python's benefits as a teaching language apply equally well to other modern languages.

If we can agree that experimentation is one of the most powerful ways to develop an understanding of a system, then by going with Java, you're consciously eschewing languages which support that goal by being:

1. Interpreted. It's hard to overstate the value of an interactive interpreter, which is in many respects akin to having a second instructor available for the students, on-demand. It can instantly answer questions about its environment, it makes exploration and experimentation trivial, and it's great when lecturing, as you can immediately explore any "what-if's" that your students raise.

2. More expressive. Aphyr demonstrated this pretty eloquently in another comment, but the less code that it takes to accomplish a task, the less code you have to understand before you're able to build something useful, and the easier it is to experiment as you go.

3. Multi-paradigm. If you're teaching someone programming, you want to be able to expose them to procedures, functions, objects, methods, recursion, etc. If you can do all of that in one language, you lower the mental barrier that your students must overcome before grasping each successive topic.

I believe that those facilities are great assets for both exposition by the teacher and exploration by the students, and I do not immediately see a compelling argument in Java's favor which sufficiently justifies foregoing the above pedagogic benefits. If the goal is to teach and create understanding, then surely the instructor should employ the tools that most readily support that objective.

Re:My Students Laugh, HaHa, Laugh, at the HN Naysayers ;) by aphyr on Tuesday January 25, 2011 @11:51PM (#2142186)
Seriously, there's a ton of voodoo in there. Things break in surprising ways, and it's hard to synthesize new knowledge based on prior experience.

I've written a nontrivial amount of Java including a sizable Android app (aside: thanks Dobrow!) and still can't complete basic tasks like mutexing, sockets, or file IO without looking them up on StackOverflow. Eclipse is the only thing that makes that language's rigidity even barely tractable for me.

Re:My Students Laugh, HaHa, Laugh, at the HN Naysayers ;) by saundby on Wednesday January 26, 2011 @01:44AM (#2142407)
You're inferring a lot. And overestimating what can be covered in a single period in a room full of 12-14 year old kids, no matter what language is used.

Part of why the class takes so long to cover a HelloWorld program is that I explain each item, provide counter-examples (wrong class name, wrong signatures for main(), multiple main()s, adding other classes and methods to the file, etc. And seeing the error messages that come with different and interpreting them. We're not just copying a canned program off the board into a text editor (even at that, how good a transcriptionist do you think a 13 year old is? They can find _amazing_ new errors in 10 PRINT "HELLO".)

And yeah, there's still a lot of black magic. But I contain it, identify it, and cut away at it through the course of the class. Coming back repeatedly to the same subjects as I do so turns out to be a pretty effective way of fixing concepts in students' minds.

I appreciate that you might do it differently. Python was among the languages I considered for the class, I've blogged my reasons for going to Java. I revisit my choice of language after each school year. Each year so far, I've come back to Java as best serving the purposes of my classes from among the choices I have, warts and all it does the job.

I do expose the students to python, we go out to python.org and spend time on the online interpreter. We also try out ruby and C using online versions.

The sorts of expansions on the basic lesson that you describe are things that I already do. It just doesn't happen in the same class period as the HelloWorld program. There isn't time, and even if I did add more to one period, it then wouldn't stick, at least not in the class format I've got to use.

I also think you have some misapprehensions about how much material you can throw at a classroom full of kids using balky old computers. No matter what language I use, there's a limit to what you can reasonably expect to cover while still providing time for students to go through the mechanical parts of the exercise (typing and running the program, interpreting the results).

So far I haven't found Java to be an obstacle in that regard. And Java allows me to do what I want in class.

You also want to know why I use the tools I do in class. That's a whole different discussion. But the short answer is that we use the tools we already know, to keep the number of new things to a minimum at any one time. We'll be introducing an IDE later (Greenfoot.) I'll be using its facilities to teach object oriented concepts more fully than I can with text, as well. Plus, once we've gotten used to using it as an IDE, we'll be rolling in the elements of the Greenfoot framework. That will give us graphics and sound, which we'll use to get immediate feedback on the operation of our code.

I discuss my use of the command line when introducing programming in another of my posts. The purpose of the class is to know the system as well as they can from as many angles as they can, among them programming. This isn't a programming class, it's a general computers class that I've decided to expand beyond "keyboarding" and MS Office boredom.