C++ and Java

A

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?

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

Alan.
 
P

Phlip

Alan said:
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.
 
I

Ioannis Vranos

Alan said:
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.
 
A

Alf P. Steinbach

* 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... :)
 
I

Ioannis Vranos

Alf said:
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.
 
A

Alan Brown

(e-mail address removed) (Alf P. Steinbach) wrote in
* Alan Brown:

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




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
 
L

Lionel

Alan said:
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.
 
D

Dave

Lionel said:
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.


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...
 
R

Remon van Vliet

Not sure where you got that wisdom from but it is factually untrue. I
sincerely doubt that 95% of the application being written today are C++.
That this may have been the case in the past (i doubt that as well, but
still) is irrelevant. At one point 95% of the programs were written in
assembler, that doesnt mean C++ wouldnt have been the better alternative if
it were available.

Note that i'm not claiming Java is better than C++ or anything else, each
has it's uses. But plenty of commercial apps have been written in Java, and
it's a fair bet a large portion of the websites you visit are powered by it
as well.

-Remon
 
J

John Carson

Remon van Vliet said:
Not sure where you got that wisdom from but it is factually untrue. I
sincerely doubt that 95% of the application being written today are
C++. That this may have been the case in the past (i doubt that as
well, but still) is irrelevant. At one point 95% of the programs were
written in assembler, that doesnt mean C++ wouldnt have been the
better alternative if it were available.

Note that i'm not claiming Java is better than C++ or anything else,
each has it's uses. But plenty of commercial apps have been written
in Java

Care to name some?

C++ applications include Microsoft Office, Internet Explorer, Adobe
Photoshop, Illustrator and Acrobat. I understand that Macromedia's Web
Development apps are also written in C++.

See here for a long list:

http://www.research.att.com/~bs/applications.html
 
R

Remon van Vliet

John Carson said:
Care to name some?

C++ applications include Microsoft Office, Internet Explorer, Adobe
Photoshop, Illustrator and Acrobat. I understand that Macromedia's Web
Development apps are also written in C++.
You're naming desktop apps only, that's a relatively small percentage of
application being developed.
 
T

Thomas Fritsch

alex said:
Dave wrote:




Huh?

If you mean "commercial software packages currently in the process of
being written":
I think it is very likely, that 95% of them are in Java.

If you mean "commercial software packages used now and written at some
time in the past":
I think it is very likely, that 95% of them are in C++.
 
L

Lucy

Care to name some?

C++ applications include Microsoft Office, Internet Explorer, Adobe
Photoshop, Illustrator and Acrobat. I understand that Macromedia's Web
Development apps are also written in C++.

See here for a long list:

http://www.research.att.com/~bs/applications.html
What does that guy know. Windows XP is using ".net" stuff now.
For example Visual Basic is in this directory.

C:\WINDOWS\assembly\GAC\Microsoft.VisualBasic\7.0.5000.0__b03f5f7f11d50a3a
 
T

Thomas Fritsch

Thomas said:
If you mean "commercial software packages currently in the process of
being written":
I think it is very likely, that 95% of them are in Java.
Well, I was kidding. 30% Java is probably closer to reality.
 
R

Raymond DeCampo

Remon said:
You're naming desktop apps only, that's a relatively small percentage of
application being developed.

Note that he said commercial applications. That would preclude a lot of
custom web applications you may be banking on on the Java side of the
ledger.

That said, this kind of statistic is very difficult to ascertain. Most
commercial applications do not advertise what language they are written in.

Ray
 
S

Steven T. Hatton

Thomas said:
Well, I was kidding. 30% Java is probably closer to reality.

But that 30% is a very significant 30%. Java's application servers really
did catch the C++ community off guard. C++ programmers look(ed) at all the
features that Java lacks and conclude(d) that C++ is(was) a superior
language. What they fail(ed) to look is what Java does provide over C++.
I've seen a good many experienced C++ programmers switch from scoffing at
Java to using Java. Few have moved in the opposite direction.

There aren't a whole lot who have looked at Java carefully and tried to
address the deficiencies of C++ as a result of their observations. I really
don't know what is happening with regard to C#, but I suspect there is a
growing challenge from that direction as well. C++ designers would do well
to examine the features that make these languages attractive. It really
isn't as simple as disallowing assignment in an if condition. To me the
three key aspects that make Java attractive are introspection, organization
and portability. I'll leave my dislike of the CPP off the list for now.
 
J

John Carson

Remon van Vliet said:
You're naming desktop apps only, that's a relatively small percentage
of application being developed.

The original statement referred to "commercial software packages" which I
take to mean something that you can buy off the shelf. I understand that the
most popular language for in-house development is Visual Basic.
 
J

John Carson

Lucy said:
What does that guy know. Windows XP is using ".net" stuff now.
For example Visual Basic is in this directory.

C:\WINDOWS\assembly\GAC\Microsoft.VisualBasic\7.0.5000.0__b03f5f7f11d50a3a

The significance of this directory entry is not as clear to me as it
apparently is to you.

It is certainly true that Microsoft is moving some of its development to the
..Net framework. Stroustrup acknowledges this when he comments "Some parts of
Visual Studio like the Base Class Libraries that ship with the .NET
Framework were written using C# but the C# compiler itself is written in
C++."

Bits and pieces of a variety of Microsoft apps are now written using C# (and
presumably one of the versions of managed C++). It remains to be seen how
far this change will go, but my understanding is that it has not yet gone
very far.
 

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

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top