Re: Can Java Programmer Learn C++ Quickly?
From: Ian T (nospam_at_spamdie.com)
Date: Tue, 07 Dec 2004 20:36:04 +1100
> I realize that this is not entirely a Java question but I am hoping that
> some of the people reading this newsgroup are Java programmers who went on
> to learn C++.
> I am giving some thought to applying for some jobs that want people with
> Java and C++ experience. I have been writing Java for several years and am
> fluent enough that I don't have to post questions here very often. I have no
> real C++ experience and not much C experience for that matter.
> However, the core Java statements are "borrowed" from C and C++ has often
> been called "C with classes".
Having programmed C++ for ~3years and now learning Java, I can say that
C++ (and C ) has some nasties that takes years to completely get your
First of all: memory management. You've got to follow that object
reference (and mallocs) everywhere it goes and anticipate every
situation where it might be stranded. A good bounds checker will help,
but still, it's something that you never think about with Java (garbage
collector), but you should always be thinking about in C++.
Second: Pointers. References (&), de-references(->), points(*().),
pointer(*), pointer arithmetic, char arrarys, memory buffers, and so on.
Learning pointers is the hardest part of C++, and once you have a good
handle on that, some of the other things come easier too.
Third: Null terminated character arrays. Useful, but often dangerous as
you can kill the null terminator and have string functions wander off
into other parts of the stack or the heap. Also, C style string
functions are the source of many buffer overflow exploits. For most
string handling <basic string> is your friend, but null terminated
character arrays have enormous flexibility.
Fourth: Learn the containers in STL as soon as practically possible,
especially <map> and <list>.
>It seems to me that it shouldn't take very
> long to get up to speed on C++ if I am already fluent with Java and
> least some knowledge of C.
Good luck with that ;). Probably *the* best book (IMNSHO) for starting
out with C++ is Dietel & Deitel C++ How to Program. It's as dense as a
chocolate pudding, but it has all the bits.