Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

C++ and Java

Thread view: 
Alan Brown - 03 May 2005 06:28 GMT
As a newbie I would like to ask what the difference in application (not
details) is between C++ and Java.   In what situations would you use C++ in
preference to Java and vice versa?  

I am not asking for personal opinions on which is the *best* language :)

Alan.
Phlip - 03 May 2005 07:28 GMT
> As a newbie I would like to ask what the difference in application (not
> details) is between C++ and Java.   In what situations would you use C++ in
> preference to Java and vice versa?

In general, prefer programming systems that make programmers faster. (And
note that VisualBasic makes them slower, for example.)

So, you might want to go with a very-high level language that rapidly
encodes what you need with minimal futzing

Java is an attempt to impersonat such a high-level language, while keeping
enough {} style syntax to advertize to C++ users.

Use C++ if you like manually managing memory, virtual dispatch, array
bounds, etc. C++ encapsulates these things very well in systems like the
STL, but it still does not allow as much programmer speed as very-high level
languages.

If you need a very large and fast program, you must indulge in manual memory
management, array bounds checking, etc. So use C++ to write things like the
engines of databases or videogames.

And, in any language, write lots of unit tests.

Signature

 Phlip
 http://www.c2.com/cgi/wiki?ZeekLand

Ioannis Vranos - 03 May 2005 08:05 GMT
> As a newbie I would like to ask what the difference in application (not
> details) is between C++ and Java.   In what situations would you use C++ in
> preference to Java and vice versa?  
>
> I am not asking for personal opinions on which is the *best* language :)

Use Java if you want to write applications for the Java Virtual Machine, use C++ if you
want to write applications for everything else, or want to do systems programming.

Signature

Ioannis Vranos

http://www23.brinkster.com/noicys

Alf P. Steinbach - 03 May 2005 08:20 GMT
* Alan Brown:

> As a newbie I would like to ask what the difference in application (not
> details) is between C++ and Java.   In what situations would you use C++ in
> preference to Java and vice versa?

As always the FAQ is a good place to start getting a handle on such questions.

In this case, FAQ items 6.5 and 6.6.

<url: http://www.parashift.com/c++-faq-lite/big-picture.html#faq-6.5>
<quote>
 In 99% of the cases, programming language selection is dominated by
 business considerations, not by technical considerations. Things that
 really end up mattering are things like availability of a programming
 environment for the development machine, availability of runtime
 environment(s) for the deployment machine(s), licensing/legal issues of
 the runtime and/or development environments, availability of trained
 developers, availability of consulting services, and corporate culture/
 politics. These business considerations generally play a much greater
 role than compile time performance, runtime performance, static vs.
 dynamic typing, static vs. dynamic binding, etc.
</quote>

The FAQ isn't perfect, though (what is?).  It should have stated _main_
programming language selection.  For example, long ago, in a galaxy far
far away, there was a Java project where we needed to maximize windows
(not possible in Java then), to deal with the Windows clipboard (not
possible in Java then except for pure text), and where we needed a decent
help system (not available in Java then); I implemented those things in
C++, used by the main Java code.  Only a couple of months later a Java
help system much like the standard Windows one became available, and half
a year or so later Java got better support for clipboard operations, I
think, it's possible I have the timeline reversed now, t'was long ago.  It
was easy to then switch from the C++ implementations to pure Java because
the interfaces were clean (a single language improves maintainability).

In an even earlier Java project, possibly even farther away, I created
interfaces to the Windows security system (access checks, impersonation)
in C++  --  impossible to do in Java then.

C++ lets you do those integration things that a canned language like Java
doesn't, and it lets you access hardware, and it can be more efficient for
some things, although the set of such things has become smaller and smaller
over the years (Java-like JIT compilation can be superior to a fixed once-
and-for-all C++-like compilation wrt. efficiency, but not always).

With C# there's less need for C++ because C# lets you access basic OS
functionality, but then, with C# it's easy to get stuck not only in the
Windows world, but in a particular version of Windows, .NET and toolset.  C#
is great as a beginner's language, though.  And so is Java, but IMO not quite
as good for that as C# (here's much room for opinion), the Turbo Pascal heir.

> I am not asking for personal opinions on which is the *best* language :)

Ah, but you are... :-)

Signature

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?

Ioannis Vranos - 03 May 2005 08:33 GMT
> With C# there's less need for C++ because C# lets you access basic OS
> functionality,

We should not confuse C# (or Java) with the underlying framework.

In particular, .NET facilities are the same for all languages.

Signature

Ioannis Vranos

http://www23.brinkster.com/noicys

Alan Brown - 04 May 2005 06:44 GMT
> * Alan Brown:
>>
[quoted text clipped - 9 lines]
>
> Ah, but you are... :-)

Thanks for your reply.  I meant I did not want to know who felt that one
language was the better, but in what circumstances would Java be better
than C++ or vice versa.

Thanks

Alan
Lionel - 06 May 2005 00:18 GMT
> As a newbie I would like to ask what the difference in application (not
> details) is between C++ and Java.   In what situations would you use C++ in
[quoted text clipped - 3 lines]
>
> Alan.

If you want to write an app that you compile once and it will run the
same on any machine, then use Java (though it does occasionaly have
slightly diffent behaviour between machines). If you want to get lower
level for speed, direct hardware access etc. such as games programming,
use C++.

Lionel.
Dave - 23 Jun 2005 14:15 GMT
> > As a newbie I would like to ask what the difference in application (not
> > details) is between C++ and Java.   In what situations would you use C++ in
[quoted text clipped - 11 lines]
>
> Lionel.

Or if you want to create an applet which any user can run via a web
site, in any web browser, on most any machine, create a Java applet.  
This could also be done via Javascript (a completely different language,
which has nothing to do with Java), but the Javascript version would be
more challenging if you wanted it to run on all machines and all
computers and Operating Systems, since their Javascript and DOMs
(Document Object Models) are not identical.  The JVMs are much closer to
identical.

There are many commercial software packages written in C++ (over 95%).  
There are very few written in Java.

--Dave

Java__Dave@NOSPAM_Hotmail.com

Remove NOSPAM_ to reply...
The 2 underscores in Java__Dave are required...


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.