Divick said:
I believe you are referring to me, you left off the attribution. I'm cool!
> There is no need to start holy war over this. It is
a very subjective issue.
I intended no such thing, I was just short with my answers.
> Why to program in Java or C is based on my
personal experience, which would definitely differ from person to
person. I can definitely give you 100 reasons / logic to do so but what
matters in the end is to get job done.
I learnt Java first, and then C, and then C++. I think I was lead
astray in both situations.
Regarding C, there are more elegant ways of solving problems as simple
as the classic "Hello World" in C++, than in C, so if you start with C,
you're already on the wrong foot. Then we move onto arrays vs.
std::vector, and char* (char[]) vs. std::string. From the moment you
start learning C, you must unlearn many aspects and re-learn them in
C++, because the C++ way is neater and safer.
With Java, it's simplicity is great, but when you come to learn C++, you
realise that there are many paradigms in Java that have neater
equivalents in C++. Take for example exceptions and "finally", ok, it
solves some problems, but not all - RAII is SO much neater. Because
Java is less expressive than C++, it can be seen as simpler. The
problem comes when means you forget to do things in C++ when you start
writing code, like managing memory properly.
One such reason is that you get to know the beauty of certain thing
only when you know what is worse or better than it. If you have not
programmed in other languages, then you don't really have that
experience which can differentiate between good and bad.
Yeah, but there is only "One true way"
.
Seriously though, it's a waste of time, if you want to learn C++, learn
C++. It's easier than learning some concepts from a bunch of languages,
and then un-learning them to do C++.
Well I don't want to delve in the philosophy of language design but I
think there are definitely certain things that are better done in some
language than other.
Of course. C++ is not a universal hammer. C is good for some things -
usually in preference to C++ only when you don't have a C++ compiler for
your platform, IMO, but thats me.
Java is equally good for LOTs of things. I'm using it for some
web-application stuff I'm doing, and I prefer it to C++ in that case,
because there is an existing framework that already does 90% of what I
need. It's also fast enough, but it's not going to cut it doing
embedded network stacks, which is what I've been using C to do.
I would also answer you questions:
Because it is easier to learn than C++. There are no pointers and hence
you tend to grasp the object oriented fundamentals more easily than if
you program in C++. If you don't care about Object oriented
fundamentals and you want to program in C++ then I would say you don't
really need C++ and hence C would suffice. This also answers your next
question.
Equally there are better languages than Java for learning "pure" OO.
They're not as readily available though, I'll admit.
Above all debugging Java is very very easy. You don't need memory
debugging tools.
Debugging C can be tricky on an embedded platform, especially as the
probe effect tends to be much more prevalent, and the task is often
inherently real-time. Debugging C++ in MSVC is at least as easy as Java
in eclipse / netbeans. If you learn RAII soon, and use auto_ptr, or
some other, possibly more suitable, smart pointer, then C++ is almost as
easy as Java in terms of resource management.
> You don't need to care too much about memory
management.
In fact, I would like to go one step further and say that learning C, or
at least having knowledge of C, possibly introduces some peoples need to
use pointers everywhere. If you told everybody that a pointer should
not be used, and instead to wrap it in a boost::shared_ptr memory
management would be as easy as Java. Like I said, learning RAII from
early on is very beneficial.
> Definitely it has again its pros and cons but for a
beginner in programming it serves the purpose.
Of course.
And as far as FAQ's go, I don't think they are the words of THE GOD and
hence there are certain things in FAQ at parashift to which someone may
or may not agree.
Of course. I didn't mention the FAQ, though.
And if still you are not happy then sorry I am not a conformist and
even I don't expect someone else to confirm to my ideas.
Don't be too concerned about my happiness, and certainly not to
apologise for your opinion! It's as valid as anybody else's, even if
it's wrong (joke!)
I'm happy to agree to disagree on this issue, of course... I just feel
it necessary to present both sides of the coin.
I think that there are LOTS of things in both C and Java which can be
misleading and/or dangerous (in terms of defined behaviour) when applied
to C++. Learn C++ the C++ way first, and then by all means see what
else is out there when the need arises. This is also more pragmatic as
you can get started with your C++ coding today, rather than in a years
time when you've half-heartedly learnt C and Java.
Ben Pope