Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Can Java Programmer Learn C++ Quickly?

Reply
Thread Tools

Can Java Programmer Learn C++ Quickly?

 
 
Rhino
Guest
Posts: n/a
 
      12-06-2004
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". 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


 
Reply With Quote
 
 
 
 
FunkyKarma
Guest
Posts: n/a
 
      12-06-2004
I programmed in C++ 10+ years before programming in Java now for 5+ years.

While I think the transition from being a good object oriented C++
programmer to Java was relatively easy, I don't think that going the other
way will be quite as easy.

What working with Java will hopefully bring to the table is practice in
applying sound OO principles, and to some degree syntax. C++ and C provide
a much bigger opportunity to hang yourself especially with pointer / direct
memory manipulation.

Also, you need to be very familiar with your machine architecture to be
really good a debugger on a given platform.



 
Reply With Quote
 
 
 
 
Sudsy
Guest
Posts: n/a
 
      12-06-2004
Rhino wrote:
<snip>
> 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.


I taught myself the fundamentals in a weekend. Weird stuff like templates
took a bit longer. Granted, I had seen C++ many years ago but didn't like
it as it didn't FORCE you to use object orientation. I wasn't surprised
when Forester Research suggested that some 85% of "C++" was actually
procedural C.

--
Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.

 
Reply With Quote
 
Martin Demberger
Guest
Posts: n/a
 
      12-06-2004
Hi,
I think you would be able to program in C++ in a few days. But I a C++
programer sees this code you would say: Thats not C++ thats Java.
C++-Programer have another pholosophy (don't know how to write this in
english).
You will even be able to write a simple C++ program before you can read a
difficult one. An writing a good and real C++ program would take a very lot
of time if it's not impossible.
The problem of you wouldn't be the HOW, this can be read by any book, but
the WHY NOT.
Java has a lot of good (and also a little bad) contructs in the library.
And the STL (Thats the JDK of C++) is a awfull in my opinion.
The other problem is the memory concept. But if you can handle C you will
be able to learn that very fast. It's easier than in C but you can also use
more hacks.

cu Martin

P.S. I came from Pascal over C over C++ to Java. I wrote my diploma about
C++ and Java, so I think I can write a little about those two languages.
 
Reply With Quote
 
Ryan Stewart
Guest
Posts: n/a
 
      12-07-2004
"Rhino" <(E-Mail Removed)> wrote in message
news:d83td.17928$(E-Mail Removed). ..
>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'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.


I've been using Java constantly for about a year and a half. I feel that I
could pass the SCJP at any time without studying in advance (an opinion
supported by some coworkers who have taken the exam). That said, a couple
months ago I picked up a good sized C++ book and read it through in a week
(with some hands-on interspersed throughout, of course). After that I felt
comfortable reading some simple and not so simple C and C++ source code and
writing my own simple little things.

If you want an eyeful, download the Quake 2 source code (C only, I believe).
If you can even begin to untangle that I'd say you're doing fairly well.

For a quick start IDE, check out Dev-C++:
<http://www.bloodshed.net/devcpp.html>

Granted I'm biased as that's the only one I've used


 
Reply With Quote
 
Hal Rosser
Guest
Posts: n/a
 
      12-07-2004

"Rhino" <(E-Mail Removed)> wrote in message
news:d83td.17928$(E-Mail Removed). ..
> 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". 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.
>


I had a couple of years of Java behind me (and no C++), then went back to
school for a MS degree, and had to take a 'Data Structures' class to qualify
for the Masters program. The instructor chose C++ for the course. My Java
background saved me. The syntax is similar and OO concepts are the same (for
the most part). Watch out for pointer arithmetic and templates.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.799 / Virus Database: 543 - Release Date: 11/20/2004


 
Reply With Quote
 
Phil Staite
Guest
Posts: n/a
 
      12-07-2004

In a word, no... not quickly.

That is, while you may be able to pick up on what existing C++ programs
are doing fairly quickly, authoring your own OO programs from scratch in
C++ is, well, different.

Some of it is just different syntax, from minor to maddening... Like
where you put [] in array declarations. Or the notion of separate
header and source files. Or C++'s automatic (stack) based objects
without new...

Some of it is just fundamental differences in tool sets. Someone used
to a nice slick GUI based IDE in Java will struggle with command line
gcc Similarly someone coming from say a Borland or MS C++ IDE to a
raw javac command line would struggle...

You'll miss many of the things that are built in to Java such as GUI
support, network IO, threading, and synchronization. To do those in C++
you'll have to learn platform specific APIs. (posix standards help some,
where supported of course)

You'll struggle with STL, while whole books have been written on C++ the
language, whole other books are devoted just to the STL portion.

As others have noted, you'll struggle with the power and peril of C++ -
it not only makes it possible to shoot yourself in the foot, it loads
and cocks the gun for you too. Seriously though, some of the
automatic conversions and conventions in C++ will drive you nuts, little
things like integer types auto-converting to bool (oh yeah, boolean in
java!) Or C++'s rather casual attitude about catching exceptions. Or
that you get a choice in how to catch exceptions...

If you're really adventureous you'll try fun things like multiple
inheritence...and begin to appreciate Java's interface idiom...

Speaking of idioms... There's a whole different universe of C++ idioms
(at least 99% different from Java idioms)

Then there's the wonderful world of debugging...memory leaks, stray
pointers, uninitialized pointers... Oh, and the funny little thing that
in C++ base class constructors get called first, always... And the
whole virtual/non-virtual function call thing...

Wait till you first bump into trying to make a virtual function call
from a constructor or destructor...

Or when you first learn about overloaded functions, and the dreaded "xxx
hides function xxx declared in ..." warning...



So while you may be able to start reading/writing C++ fairly quickly, it
generally will take a long time to become well versed in it. By long
time I mean a year to three would not be unusual. I've been doing C++
since the dark ages, about 15 years. Thanks to the ongoing efforts of
the standardization committee and the slow pace of the tools catching up
to said standard... even us long time veterans still bump into new/odd
things. Of course, that's nothing new to Java programmers, you (we, I
do Java too) have been dealing with a much more rapidly evolving and
changing language.

I'm not trying to discourage you. In fact, I'd encourage you or anyone
else to learn at least a couple of languages. I believe it gives you a
much better perspective on the overall process of programming. I just
want you to go into this with an appreciation of what you're getting in
to. That way you're less likely to get frustrated and give up. There
is light/hope!
 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      12-07-2004
Rhino <(E-Mail Removed)> wrote:
> 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.


I don't have that particular experience (I had been working in C++ for
some time before Java existed), but I can offer a comment. Learning the
basics of any new language, for a competent developer who's already got
a few behind them, ought to take something on the order of days. What
takes a lot longer (meaning months) is becoming effective in that
language and surrounding environments. Unfortunately, the latter task
is difficult to even approach unless you've got some kind of non-trivial
project to work on, and that comes from using the language for real
work.

So yeah, I don't doubt you can learn the C++ language fairly quickly,
but how productive will you be once the Java standard API is nowhere in
sight and you're working with something called Qt or MFC instead? And
will you write good code, or code that reads like the transliteration of
Java into C++ that it is? That's the main difficulty here. You may
want to obtain more information from this perspective employer on what
level of C++ experience they are looking for.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      12-07-2004
Rhino wrote:

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


I haven't gone from Java to C++ (I went the other way) but I think I can add
something useful to this thread. The following is only personal opinion, of
course, but it is backed by quite a bit of experience of working with C++
programmers of various grades.

C++ is large, complicated, and /DIFFICULT/. There is no way that you can learn
it quickly, no matter what your background. If you are intelligent, a good
programmer, and are interested in understanding the details of programming
languages, then you can probably become a very good C++ programmer in as little
as three years. If not then it'll take a little longer...

I would say that its a rare programmer who can (or should !) write C++ code
without supervision with less than a year's (fulltime) practise.

Obviously, people don't /really/ take that long to become "productive" -- what
happens is that they learn a cut-down approximation to C++, and then use that.
If they are well-taught (or lucky) then the various misconceptions and
misunderstanding they have will not be /too/ serious, and they'll be able
(usually) to write code that works, and modify existing code without (usually)
introducing subtle bugs.

The difference from languages like, say, Java is that misunderstand C++ is
often dangerous. A "fairly fluent" C++ programmer is quite likely to be
introducing bugs without knowing it (even when using features that they think
they understand), whereas a "fairly fluent" Java programmer is quite likely to
be writing reasonable Java, even if there are things about the language that
they haven't yet learned.

But what you are /really/ asking isn't about learning to write good C++, its
more about knowing C++ well enough to claim that you know the language at
interview How long that will take will depend on how honest you want to
be, and on what you think /their/ requirements are. It's certainly possible to
learn enough in a week or so (fulltime) that you can easily pass simple
programming tests.

BTW, I know this post sounds like a criticism of C++, and indeed it /is/ a
criticism of C++, but I wouldn't want to give the impression that I dislike the
language. It's a lot of fun to program in C++, there are so /many/
intellectual challenges. I just don't think its a particularly good choice for
writing programs in...

-- chris



 
Reply With Quote
 
Ian T
Guest
Posts: n/a
 
      12-07-2004
Rhino wrote:
> 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
head around.

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

have at
> 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.

Ian
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need suggestions to learn Java to become an Freelance programmer Nikhil BS Java 14 05-10-2010 05:19 AM
Who gets higher salary a Java Programmer or a C++ Programmer? Sanny Java 391 01-06-2010 02:48 AM
Older Programmer Looking to Learn Java on his own. len Java 8 11-24-2008 03:10 AM
.NET Programmer Needs To Learn Java scorpion53061 Java 20 09-27-2004 07:59 PM
Experienced VB programmer trying to learn Java - Which IDE is best? Bill Java 7 07-23-2004 12:12 PM



Advertisments