Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To learn classes and objects at my university, students are required to develop a simple game (nine-mens morris or something similar) using Java. Java is used because of its libraries and tool support. What is the counterpart for C++.

Background: I am a researcher at a university working with drones. The programming language for the research group is naturally C++. However, like most universities the introductory language of choice where I work is Java. The problem is when the students join the research group, it is hard work to "unlearn" Java for C++. IMHO, it hurts more than it helps.

I want to propose teaching C++ instead; but I need to offer an alternative for learning classes and objects.

share|improve this question

closed as primarily opinion-based by gnat, Snowman, MichaelT, durron597, Thomas Owens May 18 '15 at 13:29

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

I would guess that the university isn't going to change the curriculum to accommodate your research group. I'll also point out that C++ is an object oriented language, so I'm not sure what you mean by '... I need to offer an alternative for learning classes and objects'. – Steve Evers Apr 16 '13 at 14:19
Classes and objects work about the same in C++ as they do in Java. I'd imagine that a much bigger hurdle for your students will be shifting from a language that pretends that there are no pointers and memory management happens automatically to one where pointers are often explicit and programmers need a better understanding of memory management. You can try to avoid the problem by using references and smart pointers as much as possible, but its probably better to just teach those topics. C++'s heavy use of templates may also need to be addressed. – Caleb Apr 16 '13 at 14:46
@aiao I don't doubt that students have trouble making the switch; I'm just saying that your students probably understand the idea of classes and objects just fine. It's the other parts of C++, such as memory management, that are more likely to give them trouble. – Caleb Apr 16 '13 at 15:51
Fair enough. But then, like @Caleb says, your problem is unrelated to 'classes' and 'objects'. Maybe you should retitle your question to "teaching low-level memory management to Java programmers". – Andres F. Apr 16 '13 at 16:00
possible duplicate of Is C++ not suitable for OOP? – gnat Apr 16 '13 at 16:21
up vote 4 down vote accepted

For educational purposes, the best alternative to your Java-games-tasks when using C++ is to omit any GUI related tasks, so you can focus on problem solving and general programming concepts, without the need to introduce any big C++ framework. Stick to the command line, then you can use an arbitrary compiler (like GCC or MSVC++ Express) without any additional libraries.

I am pretty sure "nine-mens morris" can be programmed using command line only (though, of course, a graphical version may look much nicer). However, a good program for that kind of game is a non-trivial task, even without any GUI. Make sure to start with simpler tasks first if this is a beginners course.

If you really need GUI programming for educational purposes, you need to pick a C++ GUI framework. If that's the case, I suggest to go with Qt. Free, cross-platform and IMHO one of the best C++ GUI frameworks currently available. The only drawback is that Qt is huge (like the Java standard libs). And that may introduce problems you most probably don't want to be solved in your introductory courses.

There are other alternatives available, but all serious ones are not easier to handle than Qt (for example, in the MS Windows world native C++ GUI programming can still be done by using MFC, but honestly, you don't want to use that for a beginners course).

Finally, if you need some arguments for teaching something different than Java, read this post Joel Spolsky.

share|improve this answer

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