I started this thread as a discussion of the two languages, good points, bad points, maybe some ideas for the less experienced programmer to think about. Try not to insult each other.
I started this thread as a discussion of the two languages, good points, bad points, maybe some ideas for the less experienced programmer to think about. Try not to insult each other.
To err is human. To really foul things up ... you need a computer.
C++ can have automatic GC, java forces you to - C++ is better in that you have the choice, rather than having the language ram it down your throat.Originally Posted by DaBeeeenster
Java is not totally portable, nor is C++. Java is only as portable as the unlying JVM implementation, which is usually written in C(++). This makes Java in fact LESS portable than C++. the number of platforms without a C/C++ compiler is very small, much smaller than the number without a JVM.
Java is not higher level than C++, they are both the same level (3GLs). An example of a higher level language would be Lisp or functional languages. Java is just somewhat more specialised into a particular domain than C++, that doesn't make it higher level though.Java is simply a higher level language with a richer set of high quality API's.
As for the APIs, that's open to debate. I'd argue there are a richer set of APIs for C++, they may not be bundled with the language, but they are available.
In terms of flexibiliy, C++ wins hands down. It's all about choice - to use OOP or not, to have GC or not, to have buffer security checks or not, etc. In Java it's all about shoehorning your app into Sun's vision of the one true programming style. If you app happens to fit that style already, then great, use Java it'll be quicker and easier, but it's a less general purpose language than C++ because of it.
As for speed, outside of trite example code, usually written in such a way as to validate the tester's preconceptions, C++ tends to win. If java compilers existed to a large extent, and you could remove part or all of the JVM if required then it might be different. That would remove some key features of Java though, so it's unlikely to happen.
NB: The above is all from my point of view (3d games programmer) of course, though I've tried to be reasonably objective.
FWIW I don't consider Java, even with the 1.5 enhancements to 3d to be of acceptable quality for use in a realtime 3d environment.
Come on! The products my company produces in Java run (without a SINGLE line of code change) on Win32, Linux, Solaris, OSX and BSD. You cannot say the same of C++.Originally Posted by Butcher
"All our beliefs are being challenged now, and rightfully so, they're stupid." - Bill Hicks
Yes you can, as long as you write the C++ to be portable. It's not uncommon to use the same codebase for multiple platforms in C++.
Aplogises, I didn't mean to sound snobbish. I'm pretty language-agnostic and I wasn't trying to say that one was better than the other. What I meant was that programmers working on long-term, large-scale projects such as large software applications will typically choose C++. That's not to say that you can't do it in Java though. Eclipse is written in Java and it's fine in terms of speed and features, IMO.Actually I find this statement both snobbish, elitist and utterly wrong.
Any programmer choosing their programming language based on nothing other than whether it is "serious" or not is being desperately unprofessional. Choose the right tool for the right job. Simple as that.
I've worked on large (£3M+) C++ projects that never made it into production on account of poor memory management.
"All our beliefs are being challenged now, and rightfully so, they're stupid." - Bill Hicks
They may well have the same codebase, but I very much doubt that they would have been as portable as my java application.Originally Posted by Butcher
"All our beliefs are being challenged now, and rightfully so, they're stupid." - Bill Hicks
Depends what you call portable really. The C++ is as portable as the code is written to be, much of the system specific code is hidden in libraries, or specific files. Standard compliant C++ is portable to any platform with a compiler, without modification. By contrast the Java is as portable as the JVM, all of the system specific code is hidden in libraries in the JVM. There's really not that much of a porting advantage to Java over C++ as long as you're a bit careful.
Java is better for portability if you just want to leap in and throw down the first code you think of (which can be useful at times). If you're planning to design the code first and think about it, then there's little to recommend one over the other (from a portability standpoint).
Incidentally, I've written plenty of C++ code that runs on platforms your Java wouldn't - can you say the same.
How many (useful) applications have you written that use nothing other than the standard C libraries?
"All our beliefs are being challenged now, and rightfully so, they're stupid." - Bill Hicks
In my line of work none (I generally require 3d support), but then I can't use Java either.
On the other hand, if you're doing something less user-oriented, like data processing, compression or such then writing an app in standard C++ is more than possible - after all you have access to files, keyboard + screen (text only), full computation abilities. What more do you need really? I've used many image processing and other processing apps which are pure C/C++.
It has improved a lot, especially now the JVM's can read into the cpu in use and attempt to improve the decoding before execution, but this is only recently.Originally Posted by DaBeeeenster
In my company, the balance has actually shifted to Java being the choice for all projects (incl. large scale and long-term) unless there is a specific reason to use C++ e.g. specific client requirement, resource availability, or performance.Originally Posted by Aaron
I think it's also true that the choice of language depends on who you have available to do the job. In other words if you only have 3 C++ developers available at the time then you'd do it in C++. If the programmers coming out of Uni and College have more Java experience than C++ then the balance in the industry will shift towards Java.
I don't see how you have to 'Shoehorn your app' into Sun's programming style. Your only constraint is the capability of the language, and this is true for all languages. If you want to do something outwith the language's capability then choose a more appropriate language - simple as that. No one is forcing you to use Java.Originally Posted by Butcher
I also don't see how Java is less general purpose than C++?
cheers,
dave
Very true, and probably the largest factor in language choise (at least it should be!)Originally Posted by wilkied
Because you're tied in with the JVM and automatic GC it means you have less flexibility for certain types of app. In terms of desktop apps and server apps, you can use one or the other. But for more specialised fields like embedded, system level drivers, etc. java becomes difficult if not impossible to use due to having to have a JVM available for it.Originally Posted by wilkied
Maybe general purpose was the wrong wording - multi-purpose is perhaps closer to what I meant.
I run Java on my company web servers, serving sites with up to 500,000 page views per day, I run Java on my desktop to run my IDE (Intellij IDEA) and I have Java on my phone running J2ME. How is that not multi-purpose?Originally Posted by Butcher
"All our beliefs are being challenged now, and rightfully so, they're stupid." - Bill Hicks
I don't think automatic GC is a big issue to be honest, and in fact in many ways it's actually an advantage.Originally Posted by Butcher
I think it is true, however, that specialised fields such as embedded or system level drivers may be more suited to the likes of C++, but you can equally say that Java is more suited to the likes of Web development and mobile apps than C++ and so it's swings and roundabouts really.
C++ and Java both have their merits and both are better in some areas than the other. I don't think it's as clear cut as one is better than the other.
Choose the best language for the job.
Say what? what a load of garbage, what do you think your JVM was written in? C/C++ thats what, to say that Java performs faster than C/C++ in any way is just utterly wrong and thoughtless, OS code is written in C and Assembly. And the majority of deamons also use C, some with Assembily optimisationsOriginally Posted by DaBeeeenster
If your looping acctually DOES perform better in Java than C++, then the problem isn't with the language, its with your sloppy and ineffient loop.
Last edited by aidanjt; 01-02-2005 at 03:03 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)