473,473 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 3848
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
1
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
0
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
12
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it...
0
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build...
1
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in...
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.