I am going to give some beginners a presentation about writing first program in Java. This program will be about printing "hello world". I'm not sure how can I explain the concepts such as main method (and public and static keywords and the args argument) and class definition. Any ideas how can I explain that so they understand exactly what they mean? I don't have problem to spend 1-2 presentations just in Hello world program but I want them to understand.
|
For beginners? Say that this is the magic incantation that the "java" command looks for when starting from the command line, and leave it at that. The "Hello World" is intended to show the smallest possible program which prints "Hello World" and then you can build on that with what you actually want to teach them. Compare it to a car. You actually only need to know "turn the key" to make the car start, but all the intricate machinery needing to make it actually happen is not necessary up front when learning to drive. |
|||||||||||||||||
|
|
Magic. On a more serious note, java is a bad language to start beginners off in. It is very heavily object oriented, but that concept is impossible to understand without a good grounding in procedural programming. If you can't understand function calls and follow logic through a main method to sub methods and back, then you aren't going to understand an additional abstraction layer. For actually explaining
Everything else can be put off for later, and explained in isolation. Treat it like legos, where you add a new piece to the student's toolkit each time. What the main method is and how methods work isn't important yet. Variables aren't important, since they won't be used. Your students have to understand that programs are logical. If this, then that. They need to see and reason about the code, not guess. Therefore, demonstrate flow through the code(a debugger is an excellent tool for this). That shows the program is just a machine, moving through motions in a predictable manner. Print is a magic incantation now, but easily leads to a demonstration of functions and function calls, and how abstracting away details is useful. |
|||||||||||||||||||||
|
I think you're missing the point of the Hello World program. It's supposed to be the bare minimum coding before you can see something. You teach the students how to output something to the screen, then build from there. If you start explaining about static methods and class definitions you will just confuse them. Simply explaining it with "The main method is what's run by the program" is enough. |
||||
|
|
I recommend to avoid explaining those points in the first lesson. Tell your audience that this is some technical stuff you will explain later. Concentrate on the commands which actually do something, like Arguments can be explained very soon after this. But before you start explaining concepts like classes, |
||||
|
|
|
Just break it down into sub areas like you would a project and explain the details of each "module".
|
||||
|
|
|
The trick is to explain the focus on explaining the most important points so that your beginner can start to get their head around what is going on - you can always explain the complicated details later. I would do it something like:
If your beginner can understand all that (and do give plenty of opportunity to ask questions!) then you are probably off to a good start. You can then extend the lesson in various different directions:
|
|||||||||
|
|
Start out with Groovy instead of Java. It has an interpreter, has very Java-like syntax and all the concepts from java port to Groovy. After a while you can introduce other Java features such as main (once they understand public, static and void perhaps). I believe your hello world becomes:
Then you can start adding concepts after that. Also there is an environment called BlueJ that is INCREDIBLE. For exactly this reason they remove the need for a "Main" by allowing you to execute methods directly. In this way you can create a class like this:
To run this you right-click on the Test class and instantiate it (It creates an instance in a bar below--awesome visualization) then right-click the instance, select the "helloWorld" method and select execute. It prints "Hello World" and you are done. This is pure, actual java--just launched in a different way. In this way you can avoid many of the concepts at first. It also has a great UML-like interface for defining classes that makes it very easy to keep track of how your classes relate. Either Groovy, BlueJ or both would be a MUCH better introduction than jumping into raw Java and both ARE java. |
||||
|
|
|
Usually I find that its easiest to just tell the newbies: "This is a main method. Code you put there will be what is run when you run the program". Just let them memorize the code behind the main method for now. Then I tell them " If you still want to explain it:
Try to first show them the program, and then explain it. Maybe if you explained what classes, methods, objects, and data are first, then you could explain this pretty easily. It's always fun to see theory unfold in practice. |
||||
|
|
|
I'm still a student and my first Java class was not so far. I remember that all notions were not been explain during the first class with HelloWord programm. So that how I learn :
In Java all the code is implemented in a class. They are stored in a file named as the class : HelloWord.java. Note : For the first class, don't explain what mean this
Same thing for Then you can explain the basics of how to write a method :
Explain that, in order to be runnable, a programm must contains one (and only one) main method with this exact prototype. They will understand later what every words mean.
Basic statement to print a sequence of character. In resume don't go to far for the first time, or it might be off-putting for begginers. Don't lose too much time on HelloWord and go straight to OOP basics it's the core of java. HelloWord example can't be really relevant. Btw you can take this example through the differents steps to add informations step by step until, for example you can really make them undertand what is the difference and the use of the three words of When I started Java I didn't even know what means half the keywords I was using or why I was exactly using them, but I was anyway able to make simple programms. After some trainings, students will quickly learn the details of each keywords if you ask them to do a bunch of progs by themselves. |
||||
|
|
|
Oh, and the whole thing is wrapped in a There is no way and you ought not to try to explain this first. But the very fact that you have to say "And you'll have to accept that as magic..." is something that will throw lots of learners. The problem of the teachability of programming languages and their paradigms is something that is shamefully neglected by most people putting together curricula. Either you get "teaching languages" that bear little resemblance to anything in the real world or you get languages chosen for ideological reasons ("industry uses this language" or "this language will lead them towards formal CS"). If you look at "what programming languages are teachable?" you see that BASIC and spreadsheets (data-flow) are, by far, the languages that are most successfully taught to a broad audience. Unfortunately, that doesn't advance anyone's agenda... Today, it seems to me that the language that is most appealing for teaching is Python. You can avoid it's syntactical and semantic complexities for awhile and it is easy to demonstrate meaningful programs (Web interactions, robotic interfaces, etc.). Obviously, this won't help you with your talk, but perhaps you can consider it for the future. |
||||
|
|
|
This may seem trite, but... There are several ways to get to "Hello, world!" You should choose how to get there based on what features you want to highlight. Want to highlight simplicity? Use a simple text view. From there it's all about the concepts you want to show? Hard go avoid libraries, but inheritance, how you pass variables, exception handling... |
||||
|
|
|
Easy--
Java is probably a bad language to teach absolute beginners. Things like "public"/"private" data and methods, and "static" just seem like unnecessary complications unless you know the problems they are trying to solve, but, you cannot have any idea of what these problems are as a beginner. You might be better of starting with a "super simple" language like groovy where you can ease your way into OO concepts gradually. |
||||
|
|
|
Beside such a Hello World program, you have to teach them to compile and run the program too. It is a lot of new stuff, which doesn't make much sense, which can't be combined with other inforamations, and is in the way at the beginning.
I once teached a class of newbies, with exactly that problem to pupils, which had, in their majority, never seen an int or an if before. But my paradigm was, to practice early. So I explained to them, that there is a dilemma. That there are many things to tell about every little piece of code, and that we need to use that boilerplate code, this kind of entry point in the beginning without understanding, but that they will lose their obscureness over time. I taught them the most basic concepts first: keywords, datatypes, assignment, declaration, initialisation, conditions, control structures, ... objects, classes, inheritance, ... visibility, API, pretty close to a book, and I could tell them, where in the book they will encounter which part which looks unclear. So the curious could look forward, to answer their questions right away, and I could produce some trust, that these things will be explained later, and that it isn't just an excuse; that maybe I don't know it myself. :) I then tried to explain in simple words what most parts are, except the I guess it worked pretty well and would do it in a similar manner again. |
||||
|
|
|
Well, that is very interesting. Why don't you first start with this. Depending on the language, I will just say Java for now.
You can also say that hello worlds are very boring if such is your opinion. Although, you can use others examples, I doubt mine are even slightly better than anyone else. I am not a teacher so I am not the right person. |
||||
|
|
This is Eiffel as you can see there is no word that is not needed or easy to explain. We define a class called HELLO_WORLD with entry point make, we define the feature make as do some printing (to the screen), the %N is a way to say add the special character [new line]. |
||||
|
|
|
I think Hello World doesn't tell you anything about java class concept, public,static keywords since there's no way for the students to compare the functionality if you don't use these keywords in your code. Hello World has become a conventional program for any language and actually it tells you nothing about the language but supposed to run the fears away from the beginner. (this is what I feel) So if you can use a little more advanced Hello World code, that would do.For an example, consider the following piece of code.
This may be a much better Hello World program which gives a sense of object orientation as well. or if you are talking to complete novices, probably this might be your second code example and try to explain how the same output appears but the internal structure of the code is a bit more complicated. Happy teaching... Good luck !!! |
||||
|
|

class Comment { public static void main(String[] args) { System.out.println("Maybe you shouldn't be teaching Java to people who won't understand what a Hello World program is already"); } }– Ben Brocka Feb 20 '12 at 16:12public static void main(args...). When you use Java to teach programming, you lose so much time teaching Java instead of programming that you won't have time left teaching programming. With Scheme, you have almost all of the time for teaching programming. You can probably throw Smalltalk and Haskell in there, too, and still end up with more time for teaching programming, and you will have exposed the students to three very different languages. – Jörg W Mittag Feb 20 '12 at 17:56