Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Are c++ features a subset of java features?

Reply
Thread Tools

Are c++ features a subset of java features?

 
 
Jon Harrop
Guest
Posts: n/a
 
      01-20-2007
BillJosephson wrote:
> Want to do OOP. Does c++ have all the abilities of java, or is it some
> subset?


This webpage compares simple ray tracers written in several different
languages including Java and C++:

http://www.ffconsultancy.com/free/ra...languages.html

Java is one of slowest and most verbose languages. C++ is the fastest
language. However, Java is safe and cross platform.

--
Dr Jon D Harrop, Flying Frog Consultancy
Objective CAML for Scientists
http://www.ffconsultancy.com/product...ex.html?usenet
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      01-20-2007
* Jon Harrop:
> BillJosephson wrote:
>> 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.


Of course Java can do a lot of things that C++ can't in a reasonable way
(but one example, safe applets), but to the above list I'd add as most
important,

0. C++ can interface to (or be used to implement!) OS or other
API functions, and in general, assembler language.

For example, the virtual platform that Java code runs on is implemented
in C and/or C++; Java's platform /independence/ is directly implemented
in terms of C and C++ platform /availability/.

C++ is a combination of systems-programming language, application/system
glue language, and application language. Java is a pure application
language. In pure Java you're restricted to the virtual Java universe
(not that that's bad, it's useful e.g. for productivity, but it's a
restriction), while in C++ you're in a mostly infinite universe,
although one with certain barred areas (such as applets, unless you're
willing to use a technology like Microsoft's ActiveX controls).

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
 
Jon Harrop
Guest
Posts: n/a
 
      01-20-2007
Alf P. Steinbach wrote:
> For example, the virtual platform that Java code runs on is implemented
> in C and/or C++; Java's platform /independence/ is directly implemented
> in terms of C and C++ platform /availability/.


In theory, you don't need C or C++ to implement Java.

> C++ is a combination of systems-programming language, application/system
> glue language, and application language. Java is a pure application
> language. In pure Java you're restricted to the virtual Java universe
> (not that that's bad, it's useful e.g. for productivity, but it's a
> restriction), while in C++ you're in a mostly infinite universe,


"mostly infinite"?

--
Dr Jon D Harrop, Flying Frog Consultancy
Objective CAML for Scientists
http://www.ffconsultancy.com/product...ex.html?usenet
 
Reply With Quote
 
Jon Harrop
Guest
Posts: n/a
 
      01-20-2007
Erik Wikström wrote:
> Well, I don't know of any comparison but personally I'd say that C++ is
> a superset of Java, way more powerful.


C++ doesn't even have garbage collection and it isn't cross platform.

--
Dr Jon D Harrop, Flying Frog Consultancy
Objective CAML for Scientists
http://www.ffconsultancy.com/product...ex.html?usenet
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      01-20-2007
Jon Harrop wrote:
> Erik Wikström wrote:
>
>>Well, I don't know of any comparison but personally I'd say that C++ is
>>a superset of Java, way more powerful.

>
>
> C++ doesn't even have garbage collection


C++ neither wants nor requires garbage collection.

> and it isn't cross platform.
>

Availability of compilers isn't a language feature.

--
Ian Collins.
 
Reply With Quote
 
Bo Persson
Guest
Posts: n/a
 
      01-20-2007
Jon Harrop wrote:
> Alf P. Steinbach wrote:
>> For example, the virtual platform that Java code runs on is
>> implemented in C and/or C++; Java's platform /independence/ is
>> directly implemented in terms of C and C++ platform /availability/.

>
> In theory, you don't need C or C++ to implement Java.


You mean we could use Fortran?

Or code the JVM in pure Java? That would assure universal portability.


Bo Persson


 
Reply With Quote
 
Bo Persson
Guest
Posts: n/a
 
      01-20-2007
Jon Harrop wrote:
> Erik Wikström wrote:
>> Well, I don't know of any comparison but personally I'd say that
>> C++ is a superset of Java, way more powerful.

>
> C++ doesn't even have garbage collection


You mean except for this one?

http://www.hpl.hp.com/personal/Hans_Boehm/gc/

> and it isn't cross platform.


Java isn't cross platform at all, it only runs on the JVM. To move Sun's
Open Source Java to a new target, you first have to port a C++ compiler.


Bo Persson


 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      01-20-2007
On 19 Jan 2007 06:31:03 -0800, BillJosephson <(E-Mail Removed)> wrote:
> Want to do OOP. Does c++ have all the abilities of java, or is it some
> subset?


Despite superficial similarities, Java and C++ are different languages.
Neither is a subset, even though Java used to be marketed as a
simplification of C++.

Solve a real-world problem well in Java, and solve it well in C++. Chances
are they solutions will both be good, but very different.

Key features are, IMHO, Java's garbage collected objects versus C++'s RAII
and almost cost-free small classes.

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.dyndns.org> R'lyeh wgah'nagl fhtagn!
 
Reply With Quote
 
peter koch
Guest
Posts: n/a
 
      01-20-2007

Jon Harrop skrev:
> Erik Wikström wrote:
> > Well, I don't know of any comparison but personally I'd say that C++ is
> > a superset of Java, way more powerful.

>
> C++ doesn't even have garbage collection and it isn't cross platform.
>

If anyone wants to have garbage collection with C++, they install a
garbage collector such as the Boehm one. Also, C++ is available on far
more platforms than Java. Apart from that I sort of agree with you.

/Peter

 
Reply With Quote
 
Jon Harrop
Guest
Posts: n/a
 
      01-20-2007
peter koch wrote:
> If anyone wants to have garbage collection with C++, they install a
> garbage collector such as the Boehm one.


Then they're still lacking safety.

> Also, C++ is available on far
> more platforms than Java. Apart from that I sort of agree with you.


IME, C++ programs require many changes to run on a different platform
whereas Java programs require none.

--
Dr Jon D Harrop, Flying Frog Consultancy
Objective CAML for Scientists
http://www.ffconsultancy.com/product...ex.html?usenet
 
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
Two favorite features of C++, and over-rated, and misued features Jonathan Mcdougall C++ 2 11-03-2005 06:22 PM
validators subset news.microsoft.com ASP .Net 1 05-27-2004 10:28 PM
Datagrid - populate with subset of an XML file Andy ASP .Net 0 05-24-2004 03:53 PM
Java Features (cont'd): web services + restrictions of JDBC = the downturn of Java? Rick Osborn Java 5 02-23-2004 09:37 AM
subset of data using dataview?? Guoqi Zheng ASP .Net 2 01-19-2004 01:54 PM



Advertisments