How long to learn C++ if fluent in Java?

R

Rhino

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 get help with Java 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". 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 have at
least some knowledge of C. Then again, I understand that Java and C++ use
classes a bit differently; for instance C++ allows multiple inheritance
while Java allows only single inheritance but allows for multiple interfaces
as compensation. I'm not sure how long it would take to get fluent with
multiple inheritance after several years with Java.

I'd be very curious to know how long it took people here who were fluent in
Java to get fairly fluent in C++ if they started with approximately the same
skills I have today.

--
Rhino
---
rhino1 AT sympatico DOT ca
"There are two ways of constructing a software design. One way is to make it
so simple that there are obviously no deficiencies. And the other way is to
make it so complicated that there are no obvious deficiencies." - C.A.R.
Hoare
 
I

Ioannis Vranos

Rhino said:
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 get help with Java 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". 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 have at
least some knowledge of C. Then again, I understand that Java and C++ use
classes a bit differently; for instance C++ allows multiple inheritance
while Java allows only single inheritance but allows for multiple interfaces
as compensation. I'm not sure how long it would take to get fluent with
multiple inheritance after several years with Java.

I'd be very curious to know how long it took people here who were fluent in
Java to get fairly fluent in C++ if they started with approximately the same
skills I have today.


C++ supports 4 paradigms. The Object Oriented paradigm, the procedural
paradigm, the modular paradigm (namespaces) and the generic programming
paradigm (templates). Each paradigm is supported *well*, with optimal
space and time efficiencies.


The "well" part means that in OO for example, single and multiple
inheritance are supported (including that of interfaces), virtual
inheritance, virtual bases etc.


This means that it is a large language (I guess something like 4
languages in one), and will take time to learn.


However you do not need to know the entire language to begin writing
applications (myself have not finished it yet).


Since you have some programming background the best way to start is the
book "Accelerated C++" by Andrew Koenig, Barbara Moo.


You may also check http://www.accu.org for book reviews.
 
V

Victor Bazarov

Rhino said:
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 get help with Java 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". 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 have at
least some knowledge of C. Then again, I understand that Java and C++ use
classes a bit differently; for instance C++ allows multiple inheritance
while Java allows only single inheritance but allows for multiple interfaces
as compensation. I'm not sure how long it would take to get fluent with
multiple inheritance after several years with Java.

I'd be very curious to know how long it took people here who were fluent in
Java to get fairly fluent in C++ if they started with approximately the same
skills I have today.

There was that philosopher, Diogenes, who lived in a huge barrel somewhere
not too far from Athens. And he was known as a very smart guy. And once
upon a time a man was passing Diogenes' barrel and asked him, "Tell me, o
wise man, how long a walk to Athens?" Diogenes answered, "Go!". The man
thought he heard it wrong and asked again, "I want to know how long I will
need to reach Athens" Diogenes again said, "Start walking, go!". Then the
man shrugged, and started walking away in the general direction of Athens.
After the man has made several dozen paces, Diogenes shouted, "Two and
an half days!". The man stopped, turned around and asked very
irritatedly, "Couldn't you just tell me that earlier?" "No", answered
Diogenes, "I didn't know how fast you were going to walk".

How can anybody can answer the question how long it will take _you_ to
learn C++? It's basically an attempt to predict the future without any
relevant information.

And, here is another point: don't ask how long it would take as if you're
deciding whether to take that route or not. If you feel that knowing C++
is essential for your career, start learning it NOW! I made my decision
more than 12 years ago and I am still learning. On the way I picked up
Java, Python, and several other languages I didn't know twelve years ago.
What does it tell you WRT how long it will take you to get there? Nothing
if you think about it.

Just my $0.02

V
 
R

Rhino

Victor Bazarov said:
There was that philosopher, Diogenes, who lived in a huge barrel somewhere
not too far from Athens. And he was known as a very smart guy. And once
upon a time a man was passing Diogenes' barrel and asked him, "Tell me, o
wise man, how long a walk to Athens?" Diogenes answered, "Go!". The man
thought he heard it wrong and asked again, "I want to know how long I will
need to reach Athens" Diogenes again said, "Start walking, go!". Then the
man shrugged, and started walking away in the general direction of Athens.
After the man has made several dozen paces, Diogenes shouted, "Two and
an half days!". The man stopped, turned around and asked very
irritatedly, "Couldn't you just tell me that earlier?" "No", answered
Diogenes, "I didn't know how fast you were going to walk".

How can anybody can answer the question how long it will take _you_ to
learn C++? It's basically an attempt to predict the future without any
relevant information.

And, here is another point: don't ask how long it would take as if you're
deciding whether to take that route or not. If you feel that knowing C++
is essential for your career, start learning it NOW! I made my decision
more than 12 years ago and I am still learning. On the way I picked up
Java, Python, and several other languages I didn't know twelve years ago.
What does it tell you WRT how long it will take you to get there? Nothing
if you think about it.

Just my $0.02
Your point is well taken, even if it isn't very helpful. Yes, you are right,
you know nothing about me so you can't estimate accurately how long it would
take _me_ to learn C++.

I was really just looking for a generalization to get an idea of whether
this would be a difficult task or something that was relatively easy given
what I already know. I wasn't looking for an estimate that was accurate to
within 10 minutes. I suppose I should have made that clearer, although I
think most people would understand the sense of my question without having
to spell that out.

Rhino
 
I

Ioannis Vranos

Rhino said:
I was really just looking for a generalization to get an idea of whether
this would be a difficult task or something that was relatively easy given
what I already know. I wasn't looking for an estimate that was accurate to
within 10 minutes. I suppose I should have made that clearer, although I
think most people would understand the sense of my question without having
to spell that out.


It is not difficult, however it will take you enough time, since it is
more powerful language and provides more features.

An example is being able to read an object of whatever type as a
sequence of characters (unsigned chars = bytes) and print it character
by character.


After all, JVM is written in C++. :)


However as I said in another message, you do not need to know the whole
language to begin writing applications.
 
I

Ioannis Vranos

Ioannis said:
It is not difficult, however it will take you enough time, since it is
more powerful language and provides more features.

An example is being able to read an object of whatever type as a
sequence of characters (unsigned chars = bytes) and print it character
by character.


After all, JVM is written in C++. :)


However as I said in another message, you do not need to know the whole
language to begin writing applications.


Also check this:

http://www23.brinkster.com/noicys/learningcpp.htm
 
E

E. Robert Tisdale

Rhino said:
Your point is well taken, even if it isn't very helpful.
Yes, you are right, you know nothing about me
so you can't estimate accurately how long it would take _me_ to learn C++.

A week.
It shouldn't take you more than a week to learn C++.
It takes about as much time to learn C++
as it takes to read a textbook on C++ cover-to-cover.
Most computer science students taking a course on programming languages
get about a week to learn each new language if they are lucky.
Java is smalltalk disguised as C++.
C++ is *not* Java.
You will need to *unlearn* some of Java
before you can progress in C++.
But both Java and C++ are imperative computer programming languages
so much of what you learned to do with Java
will transfer to C++.
I was really just looking for a generalization
to get an idea of whether this would be a difficult task
or something that was relatively easy given what I already know.
I wasn't looking for an estimate that was accurate to within 10 minutes.
I suppose I should have made that clearer,
although I think most people would understand
the sense of my question without having to spell that out.

It might also help if you can learn to be patient
with people who are trying to help you.
 
G

Gary Labowitz

Rhino said:
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 get help with Java 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". 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 have at
least some knowledge of C. Then again, I understand that Java and C++ use
classes a bit differently; for instance C++ allows multiple inheritance
while Java allows only single inheritance but allows for multiple interfaces
as compensation. I'm not sure how long it would take to get fluent with
multiple inheritance after several years with Java.

I'd be very curious to know how long it took people here who were fluent in
Java to get fairly fluent in C++ if they started with approximately the same
skills I have today.

No really good answer is possible without knowing what skills you have
today.
However, I have found students who knew C++ fairly well learned Java fairly
well in about a year. It was on the order of six months to learn Java and
how to cobble together a program that actually did something, and another
six months to refine their understanding and eliminating the C++ knowledge
they had from the Java knowledge. I suspect it will work similarly the other
direction. There is just enough difference between the two languages to
cause problems for someone who wishes to learn both.

To become proficient in either probably takes years unless all you spend
your time on is exploring classes, libraries, etc.
 
A

adbarnet

I don't know what everyone else thinks, but I think the areas you'd have the
most fun with will be resource management (say goodbye GC - hello memory
leaks!) since you will have to know the implications of pointers to objects,
references to objects and value objects - there's no automatic reference
counting of your resources in C++.

Oh - and introductions to the 'const' keyword are in order - a close
personal friend of mine for the last ten years - sorely missed in my Java
experience - he'll be delighted to meet you!

And Templates! - Once you start looking into Templates - well! You'll wonder
how you ever lived without them!

Not that I'm biased, but I reckon you'll have more fun learning C++ than
most C++ developers have learning Java!

In short - 21 days.

(that's what it'll say on the cover of the book anyway :)
 
M

matt.fordj

The interesting difference between Java and C++ is that in Java, you
spend about 3 days learning the "Language", and then the rest of your
life learning the "Library". C++ has a lot of history behind it, and is
very complicated. It will probably take you longer to get used to the
language then it did for Java. In C++ you will spend a lot of time
learning small things like implementation-less declarations, memory
leaks, and syntax, and a little longer getting used to things like
multiple inheritence. I don't suppose you have any C background, do
you? If you did, it would be a snap.

By the way, the Java Virtual Machine is no longer there to baby-sit
you...no offense implied (Java was my first language too)
~(but then what do I know?)
 
I

Ioannis Vranos

adbarnet said:
I don't know what everyone else thinks, but I think the areas you'd have the
most fun with will be resource management (say goodbye GC - hello memory
leaks!) since you will have to know the implications of pointers to objects,
references to objects and value objects - there's no automatic reference
counting of your resources in C++.


He can use RAII which works everywhere. And also memory is not the only
resource than can leak, and RAII manages all kinds of resources.


Also it depends on the platform. For example I am programming in .NET
which is a VM environment.

He could also plug in a third party GC engine if he had the need to.



However RAII is important even in VM environments, in .NET (and in the
advent of C++/CLI), it is called "deterministic destruction".
 
G

Geo

E. Robert Tisdale said:
learn C++.

A week.
It shouldn't take you more than a week to learn C++.
It takes about as much time to learn C++
as it takes to read a textbook on C++ cover-to-cover.
Most computer science students taking a course on programming languages
get about a week to learn each new language if they are lucky.
Java is smalltalk disguised as C++.
C++ is *not* Java.
You will need to *unlearn* some of Java
before you can progress in C++.
But both Java and C++ are imperative computer programming languages
so much of what you learned to do with Java
will transfer to C++.


It might also help if you can learn to be patient
with people who are trying to help you.

A WEEK!!!!! why delude him.... a decade maybe.... or do you consider a
vague notion of the syntax to be enough to be fluent in a language,
perhaps you are deluded yourself, but I'll give you the benefit of the
doubt and assume you were just taking the piss.
 
M

Martin Rennix

I would recommend "Accelerated C++". It assumes a fairly astute reader
but it will guide you through the major pitfalls, of which there are
many. You also should get a good library reference like Josuttis "The
C++ Standard Library". The C++ standard library is very different to
the Java class library. But learning it will help you to write good
"modern style" C++. Oh, and get all the Meyers books. Armed with that
lot you should be able to make intermediate level in about a year :)

The main issues you will have are:

1. C++ does not have a huge standard class library like Java. You need
3rd party libs for networking, thread, GUI etc.
2. Objects can be created on the stack as well as the heap. In Java
they are only on the heap.
3. Memory management. Probably the single biggest hurdle for Java
programmers. You will be amazed at the reams of advice available on how
to manage memory, and then you will realize how spoiled you were with
Java :)
4. Generic programming with templates. The C++ library uses templates
heavily. There is no direct comparison in Java (not even in JSE 5.0)
5. Getting used to the syntax. C++ can look virtually unreadable to a
Java programmer. Check out the source to the C++ library to see what I
mean.
6. Unfriendly compile errors, especially with templates
7. The preprocessor. No equivalent in Java.
8. There is no C++ IDE as good as Eclipse :-(
 
M

Matthias =?ISO-8859-1?Q?K=E4ppler?=

I suppose the term "easy to learn, hard to master" sums it up really well.
It won't take you too long to write your first program if you work through
a book about the language basics.
However, to really *know* the language, to write efficient, large scaled and
stable code, well, I don't think that will happen anytime soon. I can only
speak for myself here, but the more I read about C++, the more I have the
impression I know very little about it. And I have learned for roughly 5
years now.

By the way, since at university the primary language is Java, I had the same
problem the other way round. However I would imagine that already knowing
C++ and learning Java afterwards is easier than knowing Java and learning
C++. C++ is the far bigger and complete language (well, it's way older than
Java), is more flexible and has far more possibilities to realize a
specific problem, each with its own advantages and disadvantages, whereas
in Java you mostly have one language structure to fullfill a specific task
and you have to stick with it (which is less error prone, but also less
flexible).

Overall I'd say, C++ is well worth the time you'll need to learn it. In my
eyes it's the most powerful and flexible language available, and on top of
that, it's extremely well known and nearly a standard in the industry.

That's just my 2 ?-Cent :)
 
D

Dietmar Kuehl

Rhino said:
I am giving some thought to applying for some jobs that want people with
Java and C++ experience.

If you don't know C++ now, it is probably to late to learn it for a job
where you need to know it which is already advertised: even if you are
fluent in another programming language, it will take some time to get
fluent in *reasonable* C++, too. The thing is that in C++ you are doing
things quite differently than in Java. Actually, I'd say that the only
relation between Java and C++ is that they share a similar syntax. This
is actually rather unhelpful: the relevant foundation (the underlying
object model) of C++ does not share anything with Java's counterpart.
Essentially, C++ is value-based while Java is pointer-based (call the
Java pointers "references" if you want to but they are actually just
pointers; from a C++ perspective Java's pointers add garbage collection
but lack pointer arithmetic). The consequences are actually quite
dramatic. In particular, approaches which work reasonable in Java (I
don't think there is anything which works "well" in Java at all due to
limitations inherent in Java's design), will probably not work in C++
(... and what works well in C++ will almost certainly not be workable
at all in Java). The consequence is that you will have to unlearn many
habits of Java programming when you have your C++ hat on. It is also
very important that C++ is not an object-oriented language: it support
object-orientation but it also supports other paradigms e.g.
procedural and generic programming.

As a recommondation how to learn C++ with knowledge in another
language,
I would recommend to read and understand the following books for a
headstart in the given order:

- "Accelerated C++" by Andrew Koenig and Barbara Moo
- "Effective C++" by Scott Meyers
- "The C++ Object Model" by Stan Lippmann

These three books are, IMO, essential to learning C++. These mostly
address the core language but it is also important to understand the
standard library, in particular the portion refered to as "STL"
(which is actually about "concepts": these concepts are used to realize
highly efficient algorithms in terms of iterators accessing containers;
many people, errorneously take exactly the opposite perspective putting
containers at the heart and consequently don't understand what STL is
all about). There is no book I'm aware of which is the single most
appropriate and complete book covering the language but these are a
good choice to learn about it:

- "The Standard C++ Library" by Nicolai Josuttis
- "Generic Programming" by Matt Austern
- "IOStreams and Locales" by Angelika Langer and Klaus Kreft

Nico's book covers the whole standard library while the others cover
only a selected portion (STL and IOStreams/locales, respectively) but
go into much more depth.

The books mentioned so far will give you a solid *foundation* to start
from. To become an efficient professional working with C++ you will
probably also want to read:

- "More Effective C++" by Scott Meyers
- "Exceptional C++" by Herb Sutter
- "More Exceptional C++" by Herb Sutter
- "Exceptional C++ Style" by Herb Sutter
- "Large Scale C++" by John Lakos
- "C++ Templates" by Nicolai Josuttis and David Vandevoorde
- "Modern C++" by Andrei Alexandrescu

Somebody in this thread mentioned that about a week would do to learn
C++. Well, after that time you will be able to create programs which
do what you want but probably only for relatively minor tasks. To be
ready for real production development I'd rather estimate at least
half a year of relatively instensive working with C++. Of course, I'd
expect something like this to become comfortable and accustomed to
the language specific idioms for other languages, too.
 
G

Gary Labowitz

Dietmar Kuehl said:
Rhino wrote:
If you don't know C++ now, it is probably to late to learn it for a job
where you need to know it which is already advertised: even if you are
fluent in another programming language, it will take some time to get
fluent in *reasonable* C++, too. The thing is that in C++ you are doing
things quite differently than in Java. Actually, I'd say that the only
relation between Java and C++ is that they share a similar syntax. This
is actually rather unhelpful: the relevant foundation (the underlying
object model) of C++ does not share anything with Java's counterpart.
Essentially, C++ is value-based while Java is pointer-based (call the
Java pointers "references" if you want to but they are actually just
pointers; from a C++ perspective Java's pointers add garbage collection
but lack pointer arithmetic). The consequences are actually quite
dramatic.<<giant snip>>

What you say in the rest is quite reasonable, but this "call the Java
pointers "references" if you want to but they are actually just pointers;
from a C++ perspective" is wrong and misleading. Java just doesn't have
pointers. Period.
The two biggest differences I find students have the problems with are the
many "types" C++ has versus the nine that Java has, and the difference in
exception handling. Java may simplify too much (and is remedying that by
adding boxing and making everything an object), but C++ gets confusing with
all the portability built into the implementation instead of an
language/interpreter. Of course, C++ is more useful and produces tighter
code if you strip it down.
 
T

Tom Widmer

What you say in the rest is quite reasonable, but this "call the Java
pointers "references" if you want to but they are actually just pointers;
from a C++ perspective" is wrong and misleading. Java just doesn't have
pointers. Period.

In C++ terminology, Java references behave like pointers - they can be
null, you can assign new values to them, etc. A procedure with a
reference parameter in Java behaves like a procedure with a pointer
parameter in C++ in that you can modify the value of the pointed to
object, but changes to the "pointer" itself don't propogate back to
the calling procedure.

Finally, the Java NullPointerException rather gives the game away!

Certainly all the Java developers I know who have some C or C++
background think of Java references as pointers...

Tom
 
J

jarrodhroberson

then you miss the point entirely his answer is the MOST HELPFUL one can
could possibly get. GO!!! Start learning NOW! if you think it is
important, if not don't.
 
G

Gary Labowitz

Tom Widmer said:
In C++ terminology, Java references behave like pointers - they can be
null, you can assign new values to them, etc. A procedure with a
reference parameter in Java behaves like a procedure with a pointer
parameter in C++ in that you can modify the value of the pointed to
object, but changes to the "pointer" itself don't propogate back to
the calling procedure.

Finally, the Java NullPointerException rather gives the game away!
Ah, but that's just what it's called. The real question is: What is it? (See
Alice Through the Looking Glass chapter with the White Knight for details on
the difference put in a nice way.)
Certainly all the Java developers I know who have some C or C++
background think of Java references as pointers...

Yes, I know. And some C++ programmers think of passing by reference as a
"pointer" under the hood. Still, there is no requirement that implementation
use pointers to support references in either language. They could just as
easily be handles used to look up resources that control the variables.
Anyway, it's one of those areas where the term has lost precise meaning and
causes a lot of head scratching ... and bar brawls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top