Are c++ features a subset of java features?

B

BillJosephson

Want to do OOP. Does c++ have all the abilities of java, or is it some
subset?

Thanks...
 
K

kwikius

BillJosephson said:
Want to do OOP. Does c++ have all the abilities of java, or is it some
subset?

Yes C++ is basically just a clone of some of the simpler to understand
Java features.
That really limits its usefulness but makes C++ very easy to learn.
Most people can pick it up in a couple of days.

regards
Andy Little
 
P

Peter Liu

BillJosephson $B$N%a%C%;!<%8(B:
Want to do OOP. Does c++ have all the abilities of java, or is it some
subset?

Thanks...

Real world apps need more features and functionalies than just
class-class relations and coders'handles on them. C++ is an OOP
language but C++ can't create a GUI itself without third party libs.
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

Want to do OOP. Does c++ have all the abilities of java, or is it some
subset?

Well, I don't know of any comparison but personally I'd say that C++ is
a superset of Java, way more powerful. Truth is that I don't think that
there is much that, from an application level programmers point of
view, you can do in C++ that you can't do in Java or the other way
around (if we are just looking at the language and not bringing
libraries in). They are different languages with different abilities
which leads to different solutions, but I think you can solve all
(most) problems with any of them. The question is just how.

Personally I feel a bit confined when using Java, I often come across
situations where I know I could have solved a problem really easy and
elegantly with C++ but Java does not support that kind of programming,
maybe it's just because my way of thinking is closer to the C++ way
that the Java way, but I've always felt more in control with C++. Just
look at a parameter to a function, in Java an object is passed by
reference and a built-in type (int, double etc.) are passed by value.
In C++ I can choose if I want to pass any parameter by value, reference
or pointer.

If you want to learn OOP by all means try C++. It might be a bit harder
than Java at first, there are lots of rules and things to keep in mind
but the basics are quite easy and the rest comes with experience, and
if there is anything you are wondering about you can always ask your
question here or in comp.lang.learn.c-c++.

And you might want to read the excellent FAQ:
www.parashift.com/c++-faq-lite/
 
R

Rolf Magnus

BillJosephson said:
Want to do OOP. Does c++ have all the abilities of java, or is it some
subset?

Java has features that C++ doesn't have, and C++ has features that Java
doesn't have. If any, I'd call Java the subset, because quite some features
have been removed to make the language simpler.
 
S

Sylvester Hesp

kwikius said:
Yes C++ is basically just a clone of some of the simpler to understand
Java features.
That really limits its usefulness but makes C++ very easy to learn.
Most people can pick it up in a couple of days.

regards
Andy Little

Was this pure sarcasm or have you mistakenly swapped the words "C++" and
"Java"?

- Sylvester
 
B

BillJosephson

Rolf said:
Java has features that C++ doesn't have, and C++ has features that Java
doesn't have. If any, I'd call Java the subset, because quite some features
have been removed to make the language simpler.


Thanks much for the responses.

Hm, I'm surprised by this, given what other people have told me.

Aside from the differences in parameter passing Erik mentioned, what
can C++ do that java is lacking?
 
K

kwikius

Sylvester said:
Was this pure sarcasm or have you mistakenly swapped the words "C++" and
"Java"?

If the O.P wasnt a troll then I wasnt being sarcastic.

To be honest I would in fact prefer to use Java to C++, if it had the
features, because it has comprehensive libraries which actually work
with each other. Java has libraries and no features. C++ has features
and no libraries.

Maybe I'll move to C++/CLI ...

regards
Andy Little
 
B

bjeremy

Erik said:
Well, I don't know of any comparison but personally I'd say that C++ is
a superset of Java, way more powerful. Truth is that I don't think that
there is much that, from an application level programmers point of
view, you can do in C++ that you can't do in Java or the other way
around (if we are just looking at the language and not bringing
libraries in). They are different languages with different abilities
which leads to different solutions, but I think you can solve all
(most) problems with any of them. The question is just how.

Personally I feel a bit confined when using Java, I often come across
situations where I know I could have solved a problem really easy and
elegantly with C++ but Java does not support that kind of programming,
maybe it's just because my way of thinking is closer to the C++ way
that the Java way, but I've always felt more in control with C++. Just
look at a parameter to a function, in Java an object is passed by
reference and a built-in type (int, double etc.) are passed by value.
In C++ I can choose if I want to pass any parameter by value, reference
or pointer.

If you want to learn OOP by all means try C++. It might be a bit harder
than Java at first, there are lots of rules and things to keep in mind
but the basics are quite easy and the rest comes with experience, and
if there is anything you are wondering about you can always ask your
question here or in comp.lang.learn.c-c++.

And you might want to read the excellent FAQ:
www.parashift.com/c++-faq-lite/

In Java everything is passed by value. Objects may seem like they are
passed by reference, but in fact the Object References themselves are
passed by value. This may seem like semantics, but it actually isn't.
If you pass an object reference into a function, and inside the
function you reassign the reference to a new heap object. Once you
return from the function, your reference will "point to" the original
heap object. For an example, try writing the iconic sawp(a, b) function
in Java... it won't work. And I wouln't say that Java is simpler than
C++ per se or vice verse. Both languages have features in common and
their own special abilities. C++ seems to give you more low-level
control and seemingly more of an ability to "roll your own"
implementations, however you can usually get that control in Java, its
just more round about. While Java's framework seems to make for faster
implementation (yeah... lets not get into a discussion on how fast you
can code something in each respective langauage)... I will have to say
that my biggest beef with Java is no freakin' unsigned values... that
pisses me off (I believe the char is unsigned, but that really doesn't
help you out)... but everyone has pet peeves with C++ and/or Java...
 
B

Bruintje Beer

BillJosephson said:
Want to do OOP. Does c++ have all the abilities of java, or is it some
subset?

Thanks...

Java is is a copy of c++. C++ has more features is faster. There is nothing
new in java you cannot do in C++.

Java sucks

John
 
B

bjeremy

Sascha said:
multiple inheritance for example

Yes, but you can implement multiple interfaces. So multiple
implementation inheritance can not be done, but multiple interface
inheritance can be accomplished in Java.
 
R

r

BillJosephson said:
Thanks much for the responses.

Hm, I'm surprised by this, given what other people have told me.

I'm not surprised that you are surprised. Some people have this
impression that Java is a super-language that has taken over the
software world.

I've been told that the Microsoft Office, OpenOffice, and Firefox are
written in Java.
 
B

bjeremy

Bruintje said:
Java is is a copy of c++. C++ has more features is faster. There is nothing
new in java you cannot do in C++.

Java sucks

John

C++ "had" more feature, Java 1.5 added a lot... i.e. Gereics which are
their version of templates... But Java has features that C++ doesn't
have... not saying that you can't do it in C++, but its convienient in
Java... i.e. Serializable, Type Safe Enumerated class, garbage
collection is convienient... But I will admit it is slower, and I would
probably not implement a Server in Java (though this is being done with
success). But I wouldn't dismiss it off hand and say "java sucks".
 
J

Josh McFarlane

jeremy said:
C++ "had" more feature, Java 1.5 added a lot... i.e. Gereics which are
their version of templates...

I hope you're not seriously trying to claim that generics are
templates. All generics are is a wrapper around down-casts and up-casts
from generic Object types.
 
B

bjeremy

Josh said:
I hope you're not seriously trying to claim that generics are
templates. All generics are is a wrapper around down-casts and up-casts
from generic Object types.

No, I'm seriously trying to imply that they try and give you the same
functionaity of generic programming, not on how differently the two
language features are implemented.
 
J

Josh McFarlane

bjeremy said:
No, I'm seriously trying to imply that they try and give you the same
functionaity of generic programming, not on how differently the two
language features are implemented.

Except that you can't actually use generics. You can use Objects, and
cast them to and fro as generic parameters, but god forbid you actually
try to store a generic.
 
B

bjeremy

Josh said:
Except that you can't actually use generics. You can use Objects, and
cast them to and fro as generic parameters, but god forbid you actually
try to store a generic.

Fine noone likes Java Generics.. I get it... but you have to admit
Java's anonymous inner classes are way cool...
 
J

Jon Harrop

BillJosephson said:
Aside from the differences in parameter passing Erik mentioned, what
can C++ do that java is lacking?

1. Execute code at compile time thanks to C++'s Turing-complete type system.

2. Low-level access to data structure internals, so you have more control
over memory usage.

3. Write unsafe code that accesses raw memory locations.

4. Operator overloading.

Both C++ and Java lack lots of features found in other languages, of course.
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top