2
$\begingroup$

The class I teach (a class whose teacher I assist1, to be precise) is learning intermediate Java this year (data structures, basic OOP and a few lessons about how Java actually works).

A few of the students have some familiarity with C and it would seem as though this makes some points or subjects difficult for them to understand (such as preprocessor, explicit pointers etc.).

This raises the issue of helping these students overcome the differences between a C mindset and a Java one. It was proven time and again that simply saying "That's just how Java works" is not enough (and frankly not very helpful).

So I'm looking for explanations (or analogies or examples) that might help students see the differences between the two mindsets in a clearer way.

Which points must be present in such an analogy, to properly show the main differences between the two?


1 I'm a teacher assistant in a high school.

$\endgroup$

2 Answers 2

2
$\begingroup$

I don't actually think it is necessary to show the differences (or the similarities). Treat Java as a new thing rather than trying to connect the new thing to the old (for these students only). Instead teach Java as a stand alone complete language. My preference would be to teach it from a high level rather than a low level, stressing abstractions via classes and (for you) the interfaces defining the data structures.

There is no reason in a Java course to discuss pointers or the preprocessor. Objects are "referred to" by reference variables, not "pointed to" by pointers. Learn and use the Java vocabulary for things. Once sends a message to an object, not "calls" a method.

In this way, your C students have a leg up on syntax, and the places where the "look of the language" helps them without getting into, likely only partially correct, analogies that may confuse them.

Work on the big ideas, encapsulation, abstraction, information management (hiding), polymorphism, etc, not the (possible, but likely not completely correct) explanation of the implementation. Treat a variable as a reference, not a "box". An object is a thing. The thing responds to messages, just like people do. Use Java analogies, not C based or assembly based analogies. There is no need of the higher to lower mapping. It will confuse some of your students. It buys you nothing. It may be the way you learned, but it is not optimal.

The purpose of a compiler for a high level language is to make it unnecessary to consider the mapping to the machine. Too many people forget that and try to teach as if that mapping is essential to understand to use the language. For them, computing is always and only about moving bits. They have learned nothing since 1955. Learn the language, learn the abstractions. Fly, don't crawl.

$\endgroup$
1
  • $\begingroup$ Since it's the purpose of Java to abstract those kind of things, it is just better to stress it out to the students : "different language for different purposes". $\endgroup$
    – Walfrat
    Nov 6, 2017 at 13:02
1
$\begingroup$

I agree wholeheartedly with @buffy. However there are some things that could be of use.

Explain that C is a bottom up language, that its philosophy starts at the machine. Java is, to some extent, a top down language. Its philosophy starts at the human.

I have worked with students that show me their code, and it is covered with static. They tell me that they have tried to remove the statics but get errors. (This is because a static method can not use non-static methods/data.) This traps them in the non-OO world.

Therefore write the OO bootstrap code for them. Start with OO, don't do anything that is not OO (except the OO bootstrap).

public static void main (String [ ] args) {
    new Program().run(args);
}

The following would especially confuse those that have not done C, so don't tell the whole class.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.