Hacker News new | ask | show | jobs
by mavroprovato 4537 days ago
Just because you should not explain to students what "public static void main(String[] args)" is the first day does not mean that you can never teach them. Actually, if your students cannot understand what this line is after one full class of Java, then the problem is with the teacher, not the students.
4 comments

> Actually, if your students cannot understand what this line is after one full class of Java, then the problem is with the teacher, not the students.

I think you're dead wrong about that. Assuming somebody with no programming background at all, here is a (definitely not exhaustive!) list of things that must be learned in order to understand that line:

Method visibility, what is a "method", what is a "function", what is a "class", probably what is an "object" (because it is otherwise difficult to understand why a "class" is a useful construct), "static" methods, either need to hand-wave the use of the term "static" for methods associated with a class or know a reasonable amount of history and/or computer architecture, the idea of a "return type", oh, the idea of a "type" come to that, "void" itself, "main" and generally the idea of a program entry point, function arguments, the "String" type, what is a "character", how are characters made into a "String" (arrays and encodings with various amounts of hand-waving), the "[]" syntax, and arrays of arbitrary length.

A class period is, what, 2 hours? No, it doesn't matter how good you are as a teacher, you can barely cover all that material in a single period, let alone do so in such a way that the students have any idea what you're talking about. Teachers finding themselves a month (or three!) down the road telling their students "now you have enough background to go back and understand the very first line of code you wrote!" is absolutely an anti-pattern.

[edit: formatting and typos]

Plus, each of those concepts needs a motivation and a context in order for it to stick in their minds.
Yeah, maybe you can get through slides with all the basic data about all those topics, but you have no chance of actually teaching them.
Having learned C and C++ before even touching Java, "public static void main(String [] args)" arbitrarily shoved inside a class is still an aspect of the Java that absolutely annoys the crap out of me. Before you even print "Hello world" to the screen, you're exposed to an obscene amount of opinionated design (classes! classes everywhere!). Given a competent instructor, students should learn to "break out of main()" as quickly as possible. However, the class where I actually learned Java formally had an adjunct professor who would put EVERYTHING into one class so that students wouldn't have to learn about code organization so early (IMO a huge mistake).

All of that aside, I find it amazingly stupid that a best practice for Java has you creating a specific class like MyCoolAppRunner with only one MAGIC function whose only job is to load ANOTHER class to handle the actual app. IMO C and C++ get it right by having main() exist in the ether by itself -- it indirectly abstracts the stack and heap in a way that makes MUCH more sense than the way Java handles things.

The important part is not the 'never.' The important part is that the _very first thing_ you tell new programmers is "Don't worry about this, it's magic, just ignore it."

This sets a certain kind of tone and expectation about programming that's quite poor.

Or you can say: "Don't worry about this now, we will explain it later" :-)
Compare to this:

    #include <stdio.h>
    
    int main() {
        printf("Hello world!\n");
        return 0;
    }
Woo! Your first program and I count, at most, 2 things that could be described as "magic" for someone who's never seen C before (the stdio library and double quotes being syntactic sugar for an array of chars). Even then, those two things are deterministic, so they won't remain magical for long.
"But what does 'return 0' do?" "It returns the value zero to the calling process." "Calling what?" "The process. Usually it will be the shell." "Wait, you just said process, what is this 'shell'?"
... which still gives the same impression: code is magic.
I strongly disagree with you. Public, static and void refers to three concepts that are not easy to grasp for starters. After a course they might more or less know what is the magic doing but in most cases they don't understand the underlying mechanism.

On the other hand, you will get students distracted by all those concepts and they don't spend time in what it matters on that level (learn how to make the machine to compute)

This doesn't happen in Scheme (for instance) where everything is clear and simple, two qualities that are great for starters and let them to focus in the algorithm part rather on the language shenanigans.