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

D

Dave O'Hearn

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++.

I cannot tell whether this is a joke or not. Whether or not most
computer science students "get about a week to learn each new
language", they do not actually end up learning the languages. I doubt,
for example, that the average student learns how to leak memory in
Java, and how to avoid it, or how to release resources properly in the
presense of exceptions in C++.

In any case, the original poster has already had a job. For him, when
he says he knows a language, it is expected that he has written a real
application in it, not that he solved the 8 Queens problem in it. 8
Queens will be the same in any imperative language, but string
operations, I/O, error handling, standard containers, memory
management...
 
E

E. Robert Tisdale

Dave said:
learn C++.


I cannot tell whether this is a joke or not.

It is *not* a joke.
Whether or not most computer science students
"get about a week to learn each new language",
they do not actually end up learning the languages.

They do. I did.
I doubt, for example, that the average student learns
how to leak memory in Java, and how to avoid it,
or how to release resources properly in the presense of exceptions in C++.

In any case, the original poster has already had a job.
For him, when he says he knows a language,
it is expected that he has written a real application in it,
not that he solved the 8 Queens problem in it.
8 Queens will be the same in any imperative language,
but string operations, I/O, error handling, standard containers,
memory management...

Evidently, you were never a computer science student.
Abilities differ from one person to another.
Some people will never learn C++ well enough
to sell their skills as a professional programmer.
But, if you can't pick up a new language within a week,
I would *strongly* suggest that you look into a different career path.
 
D

Dietmar Kuehl

Gary said:
"Dietmar Kuehl" <[email protected]> wrote in message
What you say in the rest is quite reasonable,

Thank you.
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.

I know this "Java has no pointers" mantra. The reasons for calling Java
pointers "references" are quite simple: pointers are a hard concept to
grasp and enough people turned away from C or C++ because the had
problems with pointers in some form or the other.

The point is, however, that Java reference behave much more like C++
pointers than C++ references! For example, a C++ reference can never
be null: if you have correct program, you can always just use a
reference (in C++ you can have stale reference, however, referring to
destroyed objects but this is a programming error according to the
standard; it is just not required to be detected by C++ implementation).
There is no such thing like a "null reference" in C++.

On the other hand, Java reference can be null - like C++ pointers. In
C++ you cannot change what a reference refers to. In Java you can
change the object a reference refers to - like C++ pointers. As I
mentioned, there are two essential difference between Java references
and C++ pointers:

- Java reference are garbage collected.
- C++ pointers allow pointer arithmetic.

Other than this, Java reference behave exactly like pointers. That is,
I would call them pointers. Of course, how these pointers are realized
is an entirely different issue! Actually, even in C++ it would be
legal if a pointer were some handle to some object. In fact, this is
what normally is: the handle just happens to be number of the memory
location where the object starts.
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.

You are saying, students fluent in Java have no trouble abandoning
dynamic polymorphism and using templates instead where appropriate? I'm
rather surprised that this is true. The people I have seen who learned
Java first try to program Java in C++ - and fail big time, of course.
That is, they typically get something to work but it is essentially
unmaintainable and does not scale.
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.

There are advantages of both languages and I wouldn't call C++ to be
optimal. Rather I would describe C++ similar to the way Winston Churchill
described democracy: "C++ is the worst programming language, except for
all those others that have been tried from time to time" :) Of course,
unlike with democracy, for some purposes there is indeed a better tool to
solve the problem at hand.
 
D

Dave O'Hearn

E. Robert Tisdale said:
It is *not* a joke.

It's still funny. It's probably just a semantic disagreement, over the
definition of "knowing" a language, but then, must humor is due to
semantic ambiguity.
They do. I did.

I can fake knowing a language after 1 week too, but I will make
beginners mistakes that cause maintainence problems. This isn't a
problem for homeworks and projects, since they get thrown out after the
due date, but most software gets shipped to users on the due date, and
the users do more interesting things with the software than grade it
and throwing it out.
Evidently, you were never a computer science student.

I was, but I have limited experience with this supposed phenomenon of
learning entire programming languages in a week. The only language I
was ever forced to learn for a course was Scheme, and Scheme does not
really count. Besides, you were talking about modern imperative
languages with significant standard libraries.

I had other courses that required a language, either C, C++, or Java,
but I knew the languages before I took the courses. I also, invariably,
wrote much better code, much more easily, than anyone else. I doubt
this is because I am a phenomenal genius. I am smart, but not orders of
magnatude smarter than an entire undergraduate program. Actually
knowing the language lets you write more, better code, much faster.
Imagine that.
Abilities differ from one person to another.
Some people will never learn C++ well enough
to sell their skills as a professional programmer.
But, if you can't pick up a new language within a week,
I would *strongly* suggest that you look into a different career
path.

I have merely recommended not lying to a potential employer. I take my
business relationships seriously. I do not lie to my employer. If you
have 1 week of C++ experience, put on your resume "C++ - 1 week total
of experience" or "C++ - I read a book about it once." That would be
honest.

It very well may be that the employer is willing to hire someone with 1
week of C++ experience, provided he or she is a fast learner, and has
other experience, and a good academic record, or is somebody's friend
or cousin. That is the employer's decision, and it may or may not be
wise, but it should not be manipulated by dishonesty.
 
M

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

I think I have to agree with Dave O'Hearn here.

I'm a computer science student too, and I already had 3 to 4 years C++
experience before I started studying. But frankly, I still don't have the
impression when reading through new articles or this newsgroups that I'm
anywhere near to knowing C++ like most professionals here.

I know, university often demands that the student has to "learn" a language
for a *specific task* in maybe a week, but this will only gain him the
opportunity to solve the given problem, but not much more actually.

For example, in the second half of this semester, we have to implement a
solver for linear optimization problems using the revised simplex in C++
(it's a project from the math faculty, not the computer science faculty),
although we have used Java as the primary language almost everywhere
(except for functional programming in Standard ML).

I really can't tell how *glad* I am that I already know C++ (quite well,
compared to most of my fellow students!). This will ease this project
assignment a LOT for me compared to someone who has merely one week of C++
experience ^^.

Regards,
Matthias
 
T

Tom Widmer

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.)

Sadly I've not yet got around to reading the second book of Alice's
adventures, but literary references are always appreciated, even if
the author referenced was a mathematician!
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.

Still, if we're talking about semantics, and certainly that's the most
important facet for most programmers, then a Java reference *behaves*
much like a C++ pointer (bar the two points Dietmar mentions). A C++
reference *behaves* like an object alias rather than a pointer.

How the two are implemented varies - I imagine that Java references
usually are handles of some kind, since this allows the GC to
seamlessly move objects around in memory. C++ references are generally
either replaced with the original object or implemented as pointers,
depending on optimization, inlining, etc.

Tom
 
E

E. Robert Tisdale

Matthias said:
I think I have to agree with Dave O'Hearn here.

I'm a computer science student too, and I already had 3 to 4 years C++
experience before I started studying. But frankly, I still don't have the
impression when reading through new articles or this newsgroups that
I'm anywhere near to knowing C++ like most professionals here.

I think that you are seriously overestimating
the knowledge of most "professionals"
who contribute to the C++ newsgroup.
Knowing the subtle implications of a computer programming language
like C++ doesn't really make you a much better programmer.
Probably, most of the people that you consider to be professionals
really aren't.
Most of the contributers to comp.lang.c++ are amateurs
who are expert in some aspect such as the ANSI/ISO standard.
They really aren't much better (more productive for example)
than C++ programmers with one week of experience.
Being a really good programmer (amateur or professional)
is really something quite apart
from knowing a computer programming language like C++ really well.
And, once you have become a really good programmer,
stepping over to a new computer programming language
is really quite simple.
 
D

Dietmar Kuehl

E. Robert Tisdale said:
Knowing the subtle implications of a computer programming language
like C++ doesn't really make you a much better programmer.

I don't agree exactly with this statement. It may not be the subtle
implications you have to be aware of but the techniques which work
- and avoid being bitten be the subtle implications. That is, you
need to know language specific idioms and when to use them.
Most of the contributers to comp.lang.c++ are amateurs
who are expert in some aspect such as the ANSI/ISO standard.
They really aren't much better (more productive for example)
than C++ programmers with one week of experience.

I'd claim that I'm more productive than C++ programmers with one
week of experience, even if the C++ programmer had loads of
expertise in other languages. Of course, productivity also depends
on the application domain, the development environment and tools,
etc.
Being a really good programmer (amateur or professional)
is really something quite apart
from knowing a computer programming language like C++ really well.

This is definitely true. It is even quite hard to grasp what really
makes a good programmer.
And, once you have become a really good programmer,
stepping over to a new computer programming language
is really quite simple.

.... but I disagree with the above statement! Sure enough, I have
no big trouble creating programs in new languages and I'm starting
to use typically one or two additional languages per year. However,
for each of them it takes a while before I become effective! I can
create working programs all the way but I'm typically relatively
slow and create a mess which matches design principles of a language
I already new rather than the new language. Picking up the idioms
for a new language takes some time, definitely much more than just
a week.
 
A

Arijit

Dave said:
I can fake knowing a language after 1 week too, but I will make
beginners mistakes that cause maintainence problems. This isn't a
problem for homeworks and projects, since they get thrown out after the
due date, but most software gets shipped to users on the due date, and
the users do more interesting things with the software than grade it
and throwing it out.

It depends on what you call "learning a language". If you call being
able to write compilable, error-free code in a language "learning", 1
week is all it takes. I saw it in my first year in college. We had C for
our programming course. I had C++ in school for 2 years, and before that
I had done a lot of programming in BASIC (my first language). So the C
course was pretty easy for me. However, I saw my batch mates struggle.
Most had never done any sort of programming before. But they did write
workable code in the first week itself, if only after a lot of
compilation errors and segmentation fault:core dumped s. By the end of
the semester, they were producing working solutions of the standard
problems. And OP here says he has a lot of experience in Java. Shouldn't
take him more than a week to start programming in C++.

This is a general guideline I consider: If given an algorithm, you can
convert it into code in a particular language, you know that language.
If you can devise the algorithm also, such that it suits that particular
language, you know that language well. Programming ultimately boils down
to algorithms, and at its core, it is nothing but implementing and
interconnecting algorithms into a working program.

I was, but I have limited experience with this supposed phenomenon of
learning entire programming languages in a week. The only language I
was ever forced to learn for a course was Scheme, and Scheme does not
really count. Besides, you were talking about modern imperative
languages with significant standard libraries.

I had other courses that required a language, either C, C++, or Java,
but I knew the languages before I took the courses. I also, invariably,
wrote much better code, much more easily, than anyone else. I doubt
this is because I am a phenomenal genius. I am smart, but not orders of
magnatude smarter than an entire undergraduate program. Actually
knowing the language lets you write more, better code, much faster.
Imagine that.

Knowing the language will help you write more code. Yes, definitely. You
will spend less time spotting compiler errors and warnings. And in C++,
where the errors the compiler gives usually have no relation to the
actual error, this is a big help. Better code ? Doubtful, but probable.
Depends on what you call better code. If two programmers implement the
same algorithm in a language, and one knows the language better than the
other, the former will write faster, smaller code. But as with almost
everything, it too follows the law of diminishing returns. A person with
4 months experience will write a lot better code than one with 1 month.
However, the difference will be much less marked in a person with 4
years experience, and another with 1 year.

However, if the person with less experience is more experienced in
programming theory, he may choose a better algorithm, giving much more
efficient results than the person with more experience. So it depends.

-Arijit
 
D

David Harmon

On Mon, 06 Dec 2004 14:33:45 -0800 in comp.lang.c++,
E. Robert Tisdale said:
It shouldn't take you more than a week to learn C++.

No, you are the only person who stops learning after a week with
C++. The smartest people are still learning after years.
 
R

Rhino

Thank you all for your thoughtful and thought-provoking replies to my
original question. You've given me a lot to think about!

For what it's worth, I know someone at the company that wants people with
both C++ and Java skills; I'm going to see if I can get him to ask the
appropriate people what level of C++ proficiency they need. That will give
me a lot better idea of whether I would be wasting their time in applying
for a job there.

Thanks again!

Rhino
 

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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top