Introducing "The Kid"
I started mentoring a 12-year-old kid. Since he is 12, I'll not put his name here. I'll call him "the kid".Well, the kid is a smart kid. He reads a lot and he remembers most of what he reads. He spent the past couple of months messing around with HTML and has put together a few pages. Now the kid is ready to start programming. He wants to learn Java. He's folks approached me and asked me if I would tutor or mentor him. I said, "Sure," because it is always good to share something with someone that wants to learn and they are old enough and ready to learn.
The kid has a Mac. I have a Mac. (I actually have several Macs.) But I've been developing on Windows for about 15 years, but I've dabbled in the Mac programming a bit over the years. Currently, I'm trying to do more development on the Mac.
The kid's family and my family along with another family had a BBQ at the kid's house. One of my sons is a good friend of the kid, and we all go to church together -- this is probably one of the reasons the kid's parents asked me to be his mentor. While we were at the BBQ, the kid shared with me where he is and what he is doing.
The Simple Stuff ... with a Problem
As I said, he has been reading a lot, but he's reached the point where he needs help sorting out what he has read. He's been reading a book about Java programming. It turns out that the book is 8 years old ... which is really old as far as a typical computer book goes. The problem is that he has been having trouble getting the simple little programming examples to run on his Mac.
The first simple example is the classic "Hello World" program.
public class Foo {
public static void main(String args[]) {
System.out.println("Hello, World!");
}
}
The problem on the Mac is that it has a GUI so the output to standard out does not show up. Now, of course, there are ways and environments that can be used on the Mac to see the text sent to standard out. But the kid does not know what standard out is nor why it does not show up.
The Not-so-simple Stuff
The kid was running XCode and discovered that all sorts of other stuff is added to the program when a Java application project is created. He wanted to see the simple little example work without all the other stuff. I figured that as soon as he saw that running, he would want to create an actual application. I showed him how to get the simple little example working, and he then wanted to create an actual application.
Making the Hello World Program Work
Here's is how I had him run the example.
- Start Terminal -- Today, the default for this is to run the Unix Bash shell.
- Create a folder for the example -- We created a folder called "javadev" using the command "mkdir javadev".
- Change the current directory to the javadev folder -- We used the command "cd javadev".
- Create a file called "Foo.java" containing the Hello World program -- We used TextEdit to create this file. I used vi on my machine just to show that it doesn't matter what is used to create the file.
- Compile Foo.java into a .class file using the "javac" command -- We typed in "javac Foo.java" which created the Foo.class file.
- Run Foo by using the "java" command -- We typed "java Foo" and the words "Hello, World!" showed up in the Terminal window.
Other Unix Commands
Along the way I had him use the "mkdir", "cd", "pwd", "cat" and "ls" commands. The kid, of course, asked where to find a list of these commands and what they are and how to use them and etc. And, as I stated, as soon as the Hello World program ran, he asked how to make an application.
Other Stuff
I pointed out to the kid where there is a lot of information about Java programming on Apple's developer site. From there, there are links to a getting started guide which in turn links to Java tutorials at Sun's site which in turn links to information about running the Hello World program using the NetBeans IDE.
We briefly talked about classes, constructors, static & non-static methods, and public & private scope of methods.
What's Next
I wanted to show him how the XCode project is put together and what he can do with that ... but we ran out of time. I believe that the kid is going to continue reading and trying stuff. In particular he is planning on messing with variables, computations and some of the other stuff that is basic to all programming.
We'll just have to see what this next week brings.
No comments:
Post a Comment