470,836 Members | 1,882 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,836 developers. It's quick & easy.

C++ and Java

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.
Jul 18 '05 #1
6 3699
Alan Brown wrote:
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.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 18 '05 #2
Alan Brown wrote:
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.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 18 '05 #3
* 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... :-)

--
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?
Jul 18 '05 #4
Alf P. Steinbach wrote:
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.
--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 18 '05 #5
al***@start.no (Alf P. Steinbach) wrote in
news:42****************@news.individual.net:
* 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.
I am not asking for personal opinions on which is the *best* language
:)


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

Jul 18 '05 #6
Alan Brown wrote:
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.


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.
Jul 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ravi Tallury | last post: by
1 post views Thread by ptaz | last post: by
12 posts views Thread by Mark Fink | last post: by
1 post views Thread by jaimemartin | last post: by
oll3i
reply views Thread by oll3i | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.