No subject
Mon Sep 28 21:33:24 BST 2009
looping and flow structures, variables, data structures, functions,
parameters, and so on.
When you're ready, you can add classes and object-orientedness to an
existing program, and move forward with that. You can move on to
closures, and anonymous functions, and metaclasses, so on on ever up.
Python has all of the features of powerful modern programming
languages, but none of them are compulsory, so you can bring them in
at the student's pace.
To compare to Java, the first program a student has to write is this one:
public class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello world");
}
}
So, you give them that, and they put it in a file, and then you have
to explain that in order to run it, the file must be called
HelloWorld.java (with the right case, please!), and then they have to
"compile" it with "javac HelloWorld.java", and then run THAT with
"java HelloWorld" (WITHOUT the .java now, please).
Then the student says:
1. Why does the file have to be called a specific thing, when any
other program file can be renamed whatever.exe and still work (like
python did)?
2. What does "compile" mean, and why is running it different?
3. What does "public" mean?
4. What is a class?
5. What is "static" and "void" and "main"?
6. What is there a set of braces inside the other set of braces?
(Charitably assuming they understand the begin-end concept of braces.)
7. What is the "(String[] args)" part for, and what does it mean?
8. Why do I go "System.out.println" to tell it to print something?
And maybe also:
9. Why do I have to put the semicolon in - can't you see it's the end
by the newline and the close-brace?
And you know what you have to say? You have to say "Look, never mind
all that, you'll understand later. Treat it as magic for now. Just
put it in and you'll see it run."
What this means is that the student's first lesson in programming is
that some things are just "magic", and you don't need to understand
them, you can just plug them in to whatever the situation is, and they
*should* work.
This is a very very bad first lesson, but it's one that many many
people have learned. It is, for example, why a lot of people in a
bash shell will type "rm -rf" if they want to delete something,
regardless of what it is. They couldn't tell you what "-rf" means, or
whether it's the same as "-fr" or as "-r -f", or whether it's even
necessary or not. They were told that "rm -rf" is how to delete
something, and since they already know that computers require magic
incantations that can't be understood, they just plug it in.
And that's why python is a great teaching language.
More information about the ubuntu-za
mailing list