Chris said:
Kai-Uwe Bux said:
Chris said:
Course in Java: [...]
And we can process concurrently...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Java memory model is so damn strict that it makes it impossible to
create any high-end synchronization algorithms. Period. But then, does
the average Java programmer even know this fact? I bet 99% do not.
Simple example of how learning Java first can, and will, burn you:
C++ teacher: Now we are going to learn about variable length arrays. C++
has
for instance the deque<> template, you see ...
Student: How does C++ actually implement that template?
C++ teacher: That is implementation defined according to the standard.
All I
can tell you for sure are the following guaranteed complexity bounds...
That teacher is crap. Give me a break. A good C++ teacher should make his
students create a vector class from scratch. Heck, the instructor can
teach his students how to implement a vector that meets the C++ Standard.
The instructor can teach the student how to create a memory allocator that
meets the C++ standard to plug into the standard vector the student will
be creating.
The classroom can define a namespace:
myclass_std
And the course would be about actually implementing Standard C++. Then the
students can implement Standard vector, and Standard queue, and use them
in further applications.
Any thoughts on this approach?
When you learned driving a car, did your instructor insist on assembling it
first from parts? Don't get me wrong, I think such a class would be fun and
a great way to learn quite a bit (been there, done that, learned a lot).
However that class would not be a language course. It would be a course in
data structures.
That C++ allows you to implement your own deque does not mean you should. It
does not even mean should know how to do it (there may be *other* reason
why you should know how to implement deque, but those are unrelated to C++
and are better taken care of by other classes in the curriculum).
In my opinion, a C++ course should focus on good programming idioms like
RAII, templated inheritance and policy classes, the use of standard
containers instead of pointers and arrays; the students should learn about
exception safety issues and how templates (user provided code) and
exceptions (when user provided code throws) aggravate the use of raw
pointers; the students need to explore the virtues and vices of being
virtual or of being private, protected, or public; and the list continues.
Those are issues a C++ needs to cover because these items are forced onto
the agenda by the language. A C++ course is neither a substitute for an
introduction to computer architecture nor a class on data structures and
algorithms.
Student: I hear the C++ Standard has a nice vector template?
Teacher: Well, yes it does. And you will learn exactly how to create a
Standard C++ vector template from scratch. This class will teach you how
to implement useful parts of the C++ Standard. The class uses the
namespace myclass_std for the minimalist Standard C++ template library you
will be creating.
Sound good to me, no?
As I said, sounds terrific for a class in data structures. But that is quite
different from teaching C++. The problems of implementing queues, maps,
sets, hash tables, and even something like vector are mostly unrelated to
the language (although it is true that templates help tremendously in
making such structures generic).
Best
Kai-Uwe Bux