Re: Visual C++ vs Visual C#
Ben Voigt wrote:
My basic idea is that the first program should not contain any
language features which will not be taught immediately. I have a big
beef with java, where beginning programmers must learn a 15-ish-line
incantation that seems to be magic (public class, public static and
array [] on main, System.out.println). I see the idea of learning
C++ without learning C to be fraught with the same perils. The hello
world program in a class on C++ should be as simple as possible,
which means this:
#include <stdio.h>
int main(void)
Drop the 'void'. There is no need for it in C++.
{
puts("Hello World!\n");
return 0;
Drop the return statement. There is no need for it in C++.
}
Every single token in this program can be easily explained, there is
nothing that has to be learned by rote. Compare with a similar "pure
C++" program:
#include <iostream>
using namespace std;
Drop this. 'cout' and 'endl' deserve to be prepended with 'std::'.
int main(void)
Drop the 'void'.
{
cout << "Hello world" << endl;
return 0;
Drop the return statement.
}
We've added namespaces and shift operators for no gain,
What namespaces? Drop the notion, just prepend with 'std::' which
suggests that it's part of the standard library. Otherwise, you
just mashed 'cout' and 'return' into the same soup without merit.
You'll explain what it means later. Right now you can just say that
all standard names come with 'std::' in front.
And what shift operators? The student has no idea about that.
Those ('<<') are NOT shift operators. At best, they are "streaming
into (or out to)" operators.
And after fixing your program ends up
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
}
What's wrong with that? Nothing.
and even
"cout" doesn't mean nearly as much as puts (= put string). These
extra things are memorized instead of understood.
Who cares? In your former variation of the "Hello World" program
you have to introduce the '\n' and the fact that 'puts' is a function
(is it from the standard library? that fact is memorised instead of
understood.)
You (unfortunately for you) seem to be looking at learning C++ through
the eyes of somebody who did too much C before and cannot shake off
such nonsenses like '(void)'. If somebody wants to learn to fly before
walking, let them.
[..no need for pointers..]
Well, that's so. I am still missing the point you were making about
the need to start with C constructs here.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask