C++ vs. Java

EvilManagedCare

Senior member
Nov 6, 2004
324
0
0
Which would be better to learn first? Would there even be a benefit from learning one before he other?

Thanks in advance
 

Spydermag68

Platinum Member
Apr 5, 2002
2,614
98
91
Either language is fine to learn first. Deitel & Deitel books have a good introduction to both languages, but they are $80+ for 1000+ pages.
 

sigs3gv

Senior member
Oct 14, 2005
513
0
0
Theres no significant benefit by learning one before the other. However, Java is fully object oriented. If you really want to learn OOP, you should try Java.
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
If you have no programming experience, Python is a better learning language than both.
 

Red and black

Member
Apr 14, 2005
152
0
0
Originally posted by: tfinch2
If you have no programming experience, Python is a better learning language than both.

For sure.

C++ is very complicated, and would make a very poor choice for a first language.

Java is not as complicated, but is pretty brain-dead.

Python would be fine. After getting comfortable with Python, when you're ready to start learning more about what the computer is actually doing, learn C.

The only reason to learn C++ or Java would be for a programming job.
 

Spydermag68

Platinum Member
Apr 5, 2002
2,614
98
91
In degrees of complexity I think both C++ and Java are equal for someone just starting to learn a programming language.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
In degrees of complexity I think both C++ and Java are equal for someone just starting to learn a programming language.

I wouldn't agree with that. Java is a fully managed application environment. C++ requires you to be familiar with a lot of lower level concepts and structures. Memory management is probably the number one thing that is different, and that adds significant additional complexity to C++ programs as compared with Java. Pointers alone can consume you for a couple of decades ;).

Now C# and Java I would say are pretty much identical in terms of complexity.
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
Memory management is all handled for you in Java as Markbnj said.. I'm still having pointer nightmares in C++ after 5+ years of experience (mostly school) :eek: One of the major reasons I hate programming in C++.

If you want to learn OOP first, learn Java. If you want to learn memory management, learn C++. Of course it's not all that black and white so at the end of the day just take a pick if you just want to learn the concept of programming :p

Edit: And oh.. you'll understand pointers a lot more clearly after doing assembly
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I have done over 7 years of professional assembly programming.

I didn't think the question was whether you understand pointers :).

And by the way, even if you can write assembly language in your sleep, you could still have trouble with C pointers. I think addressing memory in assembler is a lot easier, frankly, unless all you're doing in C is arrays. As soon as you get into a couple of levels of indirection and dereferencing it gets pretty damn cryptic. One of the weak points of the language, imo.

Edit:

I absolutely agree that having done assembler is a huge boost in learning C or C++. A little less so, maybe, for C++. But in general both languages are most accessible to people who already know how the system works at a low level.

 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
C++ is a lot harder than Java. They aren't even in the same league in the first place. C++ is unmanaged and Java is managed.

I don't think assembly is going to help you with C a whole ton (maybe in terms of the fastest way of doing things). The most important thing in C IMO is to know precisely how data is stored (just one part of assembly).

Chances are someone who has only used Java would have no idea what this code did.

Just guessing though. :)

Good article on it: http://www.codeproject.com/dotnet/pointers.asp
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I don't think assembly is going to help you with C a whole ton (maybe in terms of the fastest way of doing things). The most important thing in C IMO is to know precisely how data is stored (just one part of assembly).

Right, that's exactly it. It's primarily the understanding of how memory is layed out that makes it challenging, imo.
 

caivoma

Senior member
Sep 3, 2004
957
0
0
I am taking java course right now and i have a lot of problem with it. Does anyone know any website that have sample codes with lots of explanation ? It would be awesome, thanks.
On the topic, i dont like either C++ or Java, i guessed i choose the wrong major :(.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I haven't heard anything about VB.NET- anyone here prefer it to java/c#?

Different animal. Sort of halfway between java and javascript. Great for whipping out quick windows apps, or writing frameworks to run controls written in C++/C#.
 

Xyo II

Platinum Member
Oct 12, 2005
2,177
1
0
Originally posted by: Markbnj
I haven't heard anything about VB.NET- anyone here prefer it to java/c#?

Different animal. Sort of halfway between java and javascript. Great for whipping out quick windows apps, or writing frameworks to run controls written in C++/C#.


Oh I see. thanks.
 

BFG10K

Lifer
Aug 14, 2000
22,709
2,996
126
I'd start with C++ - it's harder but it's a walk in the park to pick up Java later on. Java may be easier but it's missing a lot that C++ offers so you have to learn again if you were to move to C++.

As for pointers and memory management, use STL in C++ and it largely takes care of it for you.
 

replicator

Senior member
Oct 7, 2003
431
0
0
Depends on what kind of work you do.

If your interest is in developing business applications, including web apps, Java is the way to go. Java is really king in the business enterprise space. You won't see much C++ unless you are a lower level application programmer working for a software shop.

C++ has its place, but it really depends on what type of work you are involved in, or you hope to work with.
 

itachi

Senior member
Aug 17, 2004
390
0
0
Originally posted by: xtknight
C++ is a lot harder than Java. They aren't even in the same league in the first place. C++ is unmanaged and Java is managed.
not everyone deals with pointers.

i think people who've dealt with C and C++ would have a difficult time figuring that one out too.. especially considering that C has no public modifier and C++ casts aren't done in that manner.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
If your interest is in developing business applications, including web apps, Java is the way to go.

I still find Java apps pokey on Windows. If I were writing client-server business apps I would use VB, maybe C#. For server stuff, C++ or ASP. Web-based client stuff, javascript.
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Originally posted by: itachi
Originally posted by: xtknight
C++ is a lot harder than Java. They aren't even in the same league in the first place. C++ is unmanaged and Java is managed.
not everyone deals with pointers.

i think people who've dealt with C and C++ would have a difficult time figuring that one out too.. especially considering that C has no public modifier and C++ casts aren't done in that manner.

If you scrapped the public modifier it should be valid C...I just copied it off of C# code for an example. I guess it's more C than C++, but bleh... I have to admit I don't know the difference between p-- and --p, but I'm no C master. :p Wouldn't it be reinterpret_cast<byte*> for C++? What is the difference anyway?
 

itachi

Senior member
Aug 17, 2004
390
0
0
Originally posted by: xtknight
Originally posted by: itachi
Originally posted by: xtknight
C++ is a lot harder than Java. They aren't even in the same league in the first place. C++ is unmanaged and Java is managed.
not everyone deals with pointers.

i think people who've dealt with C and C++ would have a difficult time figuring that one out too.. especially considering that C has no public modifier and C++ casts aren't done in that manner.

If you scrapped the public modifier it should be valid C...I just copied it off of C# code for an example. I guess it's more C than C++, but bleh... I have to admit I don't know the difference between p-- and --p, but I'm no C master. :p Wouldn't it be reinterpret_cast<byte*> for C++? What is the difference anyway?
p-- is the post decrement operator and --p is pre.. it basically states whether the decrement/increment will be done before or after the assignment. if it's the only statement in a line, there is no difference.. int x = p--; after this statement, x = p and p = p - 1.. int x = --p; after this statement, x = p - 1 and p = p - 1.

one of the main problems that people seem to have with C is it's poor typing. typically, a system's memory reference will have the same bit width as the standard integer for that system.. in C, since all variables are essentially integers, it allows you to perform arithmetic on them relatively freely.. reinterpret_cast is C++'s way of offering the same functionality.
but then again.. C's poor typing is also part of why in a lot of situations C is a more pratical solution than assembly for systems programming.