Jump to content
xisto Community
silverkirfsco

What Are The Advantages Of Java Vs C++?

Recommended Posts

Java is designed to be simple, object oriented and similar to C++ while removing the unnecessary complexities of C++. It is also said to be a robust, architecturally neutral, portable, interpreted, threaded, dynamic and high performance language. Java enables the development of robust applications on multiple platforms in heterogeneous, distributed networks. C++ is not truly portable nor is it suited to heterogeneous, distributed networks. While C++ excels in high performance, its powerful features and complexities are often the source of many errors.

Share this post


Link to post
Share on other sites

C++ can be a very fast language when compiled hence its use in device drivers and other core applications (alongside C). Java is moer userfriendly for writing applications for that will contain a GUI as it is mostly self contained and will run completley indipendantly of system or operating system. C++ does not have this advantage and external compile files or systems may be required to run software you design, this is especially true on linux and unix.

Share this post


Link to post
Share on other sites

It depends on what you mean by graphics. For a simple GUI, Java's Swing API is easy to use, and usually built in or included as an add-on package to install. There's another GUI API, but it slipped my mind. I always just used Swing.Java, as stated before, can be complied to run on the JVM. This creates a multi-platform application that you can easily distribute. The only negative part about this is performance, where the JVM is often sluggish and not fully robust enough for me to trust. I'm using a Yearbook creation software for a school, and it's the most poorly designed (and hideous) program I've seen in years, and I suspect that the problems lie mostly in the Java architecture rather than program design (could be wrong, but honestly, would anyone purposefully write a program that requires you to quit the application to open a new file?) I hated the JVM, and probably always will.C++ has its downfalls as well. It's harder to learn (generally), but more importantly, it's a ***** to actually port to other processors. Since most APIs are processor specific, you'd have to find a comparable API to fill in the gaps that can't be used again. The OOP concept is essentially the same, so that's a moot point here.If I had to classify Java and C++, I'd say Java is for learning, and C++ is for coding. C++ has significant advantages when it comes to performance, and can smoke Java in equal settings.

Share this post


Link to post
Share on other sites

C++ has its downfalls as well. It's harder to learn (generally), but more importantly, it's a ***** to actually port to other processors. Since most APIs are processor specific, you'd have to find a comparable API to fill in the gaps that can't be used again. The OOP concept is essentially the same, so that's a moot point here.

You mean each Operating system has its own API's.
C++ if coded with portability in mind, is very very very easy to port.
Just re-compile.

aslong as you stick to C++ standards ( for example using fstream for file access instead of microsofts FILE class, < which does exactly the same thiing as fstream, except its not portable>)

Infact, The only parts that are difficult to port between windows, and the rest of the OS's is the GUI. and this can be nullified by using the GTK, QT or SDK libraries in c++ for GUI control.

In other words... IF a c++ project is designed with portability in mind, porting is as simple as a re-compile.

ANYWAYS... advantages of Java which nobody has pointed out jet...

1) Garbage collection. in java you dont have to delete memory when you have finished with it, it is virtualy impossable to wrte a program in java which suffers from memory leaks.

2) No Raw memory access. Although c++ raw memory access is lightning fast, Java takes away memory manage,ment from the porogrammer, making it virtually impossable to make a mistake which could result in a buffer overflow vunerability.

Some aspects or very confusing though.
for example in c++ you can simply declair an array of user defined object, and begin using them..

example
myObject  objectArray[ 100 ];

BUT in java, to do the same thing you need to
myObject[ ] objectArray = new myObject[100];for(int n=0; n<100; n++) {    objectArray[ n ] = new myObject;}

this is because, in the java virtual machine, line one one creates an array of 100 pointers to myObject, you then need the loop to create 100 objects and assign them to pointers

This part of the java language only makes sence if you understand memory management and pointers (which you will only get from learning c or c++)

Share this post


Link to post
Share on other sites

It depends on what you mean by graphics.  For a simple GUI, Java's Swing API is easy to use, and usually built in or included as an add-on package to install.  There's another GUI API, but it slipped my mind.  I always just used Swing.

 

Java, as stated before, can be complied to run on the JVM.  This creates a multi-platform application that you can easily distribute.  The only negative part about this is performance, where the JVM is often sluggish and not fully robust enough for me to trust.  I'm using a Yearbook creation software for a school, and it's the most poorly designed (and hideous) program I've seen in years, and I suspect that the problems lie mostly in the Java architecture rather than program design (could be wrong, but honestly, would anyone purposefully write a program that requires you to quit the application to open a new file?)  I hated the JVM, and probably always will.

 

C++ has its downfalls as well.  It's harder to learn (generally), but more importantly, it's a ***** to actually port to other processors.  Since most APIs are processor specific, you'd have to find a comparable API to fill in the gaps that can't be used again.  The OOP concept is essentially the same, so that's a moot point here.

 

If I had to classify Java and C++, I'd say Java is for learning, and C++ is for coding.  C++ has significant advantages when it comes to performance, and can smoke Java in equal settings.

<{POST_SNAPBACK}>

I don't think that's the JVM's fault, it sounds more like a creation of a dumb programmer. After all, Oracle SQL was written in Java....

Share this post


Link to post
Share on other sites

Let me share my knowledge about Java and C++.C++ was here before Java came and its obvious for C/C++ to grab large portion of the market. but it does not make C/C++ the only programming language. Everyone Prefers C and C++ because it works as a middle tier of highlevel language and lowlever language. you get both power of programming at root as well as at the top. due to this popularity there are more C/C++ compiler than other languages. like GNU C++ or G++, Turbo C++, Borland C++, Devshed C++, MS C++ and many more they come in many flavour. some are specifically for windows. like VC++. I have not heard any one coding application in VC++ for Linux. Due to this popularity C and C++ has become powerful more and more day by day and today it stands as a ruler in languages. And Microsoft had added a new flavour to C and C++ called C#. Though C# is made from the scratch. It is based on the same norm of C and C++.C++ is handy as it supports both the structured programming and OOP. It is easy if you do not get overdriven by Pointers and end up crashing your software with an error reading "Illegal Referenc to this and that" or "Null Pointer Assignment". Memory management in C/C++ is totally on hands of a programmer. Though there are software to check the memory leaks and garbage collection. But memory management is tedious in C/C++. If you are well with Pointers and memory management then C++ should be your choice. And talking about Graphics and others there are plugin API specially for Graphics, I think much of the graphics software or games are made in C/C++ and their other flavours.Java is great Programming language. And I like to code in Java than in C/C++ because of its ease of use. I have heard that the codes in java are 4 times smaller than the codes written in C/C++ for the same job. Java manages memory itself by its garbage collector. and it eliminates the pointers and itself is based on references. I mean any variable you create are references. Java is easy to use for the programmers from the C/C++ background coz it has the same look and feel of coding.[The curly braces I love Curly braces{}]Graphics in Java is good. The new JDK2 comes with more powerful Graphics API and I think you will hardly need 3rd Party API. Moreover Java is platform independent and secure. You can port your program to any platform without any hassle. I code Java program in windows and use it in Linux and viceversa. Its fun. you need not bother about portability as long as you have JVM running....And there are many to follow...Now you make choice which one is better..

Share this post


Link to post
Share on other sites

In short...stick with C++ unless you need cross-platform usability and don't need anything complex.

Share this post


Link to post
Share on other sites

i know people have already posted alot on this, but here'e my 2 cents. java is easy. there are a HUGE number of libraries that sun and other people have provided. No matter what you are trying to accomplish, if you look hard enough, you'll find that someone has already written a function to do it for you. In C++, there are quite a few default libraries, but you deal with alot more in depth coding using system calls and whatnot. THis is even more true if you use C (which I do). Besides this, the syntax for the languages are pretty similar, and each could be written to look like the other. The real difference, as I see it, is the performance. C/C++ has very little abstraction between the program and the operating system, making it very fast. Java, on the other hand, has a virtual machine between it and the OS, which increases portability, but decreases speed immensly. Also, java is an entirely interpreted language, which (very basically) means is compiles each line as it reads it, slowing it down further. In the end, unless you're writing an applet for use on a website, theres no reason to use java if you've got a decent amount of programming skill.-afrothunder

Share this post


Link to post
Share on other sites

The whole reason java and C++ are so similar is because java is based on C++. It was acctually made to be used more in web development anyway, something which C++ was lacking. Java cut down on all the memory management and such in order to make web programming easier (try programming the memory managment when you have to think about IE or some other random browser in the mix too....).

Share this post


Link to post
Share on other sites

I'm primarily java programmer, but some years ago I used c++ as my primary programming language.I can list some(not all) features which are big adventages in java:1. garbage collector (you don't think about empty pointers)2. numerous libraries (especially open-source libraries)3. almost full object programming4. cross-platform programming and running5. you can write programs and pay nothing for licences(free IDE, free frameworks etc.)6. very big community

Share this post


Link to post
Share on other sites
Replying to qwijibowI don't think that is correct. In Java you declare a user defined object array as (for example Student class objects) ArrayList<Student> list = new ArrayList<Student>( );You don't bother with pointers, you don't have to use a for-loop. That's it!-reply by Jose

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.