View Full Version : what are the facts on java vs C# vs C++?
TobiasTheViking
30th January 2006, 10:16 AM
K, so far i have learned, at home Qbasic, Pascal and php.
From studying i have learned Mosml and C++.
The next half year, i'll be learning Java and C#.
Now, i run linux(gentoo) exclusively, but that doesn't mean i'm zealous against .net. I can see certain good things in it.
As for java.. I've had bad experiences (slow guis.. and abuse of resources on the few non gui apps i've tried).
So, i usually steer clear of java.
But, what are the facts on these three different languages? Google gives me mostly flame wars and unsubstantiated opinions.
Personally, i can't see how either C# or java can be faster than C++(considering both of them are virtual machines). On the other hand both of them may( i don't know) have other virtues.
I'm not just talking speed, also security and everything else interesting.
Sincerely
Tobias.
JamesM
30th January 2006, 10:29 AM
Java has garbage collection. And it's easier to learn than C++. You can stray further from the OO paradigm with C++, though.
You also have to take into account what other APIs and frameworks there are for each language. Most of the ones I want to use are in Java, so I use that. Personally, I find programming in Java a more pleasant experience than C++.
Wudang
30th January 2006, 10:50 AM
There are more better paid java jobs.
bigred
30th January 2006, 01:33 PM
Java has garbage collection. And it's easier to learn than C++. You can stray further from the OO paradigm with C++, though.
You also have to take into account what other APIs and frameworks there are for each language. Most of the ones I want to use are in Java, so I use that. Personally, I find programming in Java a more pleasant experience than C++.
Interesting. So basically you'd say C++ is "better" (faster, more powerful etc) but Java is often preferable due to being easier to use and having other "things" (APIs etc) that support it, making it generally the better choice? (geez sounds sorta like UNIX vs Windows don't it ;) ) Do you think hardware, net apps etc are at a point where more often than not the pros to C++ as stated tend to be moot?
As a mere BA/PM mortal, I can't confirm any of this first-hand, but this is generally what I'm hearing from other developers.
In any event, I find this very interesting. Look forward to add'l responses.
PS what about C#? In fact what in the flip IS C#? Man I'm out of it on programming stuff...
TobiasTheViking
30th January 2006, 01:40 PM
PS what about C#? In fact what in the flip IS C#? Man I'm out of it on programming stuff...
.net
C# is .net
Well, not really, but if you know what .net is, you are most likely mistaken, and you really know what C# is. :D
Atleast that is how it was for me till today.
But yes, i have heard from one of my friends that C# should be superior to java.
Jorghnassen
30th January 2006, 01:57 PM
I find JAVA more cumbersome than C++. In fact, I'm much happier with plain old C. Yeah, I don't program that much (except to speed up some R functions).
JamesM
30th January 2006, 02:15 PM
Interesting. So basically you'd say C++ is "better" (faster, more powerful etc) but Java is often preferable due to being easier to use and having other "things" (APIs etc) that support it, making it generally the better choice? Let me, as ever, preface my comments by stating that I have no formal computer science education, so grain of salt and all that.
C++ is definitely more flexible, and faster. You can do more with C++, like functional programming (using pointers) and template programming, which isn't possible in Java, due to the latter's implementation of generics.
But for object oriented programming, given the choice, I would always choose to program in Java over C++. The only thing I miss from C++ is the ability to overload operators - as a result, implementing mathematical and statistical concepts can be very cumbersome.
Do you think hardware, net apps etc are at a point where more often than not the pros to C++ as stated tend to be moot?
I think that, if you had no legacy code to support, equal access to a team of hardened C++ and Java veterans, and if you were going to do some standard enterprise application, involving a big database with web pages on top, there's no question that Java would be the first choice. I doubt that reality is ever that simple, however.
what about C#? In fact what in the flip IS C#? Man I'm out of it on programming stuff...
C# is a .NET thing - it's very similar to Java, although it's perceived that it's being doing more of the innovating than Sun lately, and the last update to Java was Sun playing catch-up.
a_unique_person
30th January 2006, 02:50 PM
C# was Microsofts response to Java, when Sun rebuffed it's attempt to hijack Java.
C# is actually a very well thought out programming language, designed by the man behind Delphi. (Microsoft stole him).
It is trying to be 'one step ahead' of Java, although there is nothing you can do in C# that can't be done in Java.
Java is more universal in terms of platforms it runs on, C# is really just for windows despite the open implementations such as Mono. Java does not integrate as well with Windows, while C#, via .Net, does.
C# is very nice to use, very efficient for a language that uses a VM, but not as widely used as Java.
kevin
30th January 2006, 02:52 PM
Java has garbage collection.
so does C#.
You can get C# on Linux with Mono.
http://www.mono-project.com/Main_Page
a_unique_person
30th January 2006, 02:55 PM
I have tried to run C# code on Mono that works fine on Windows. Mono just does not run applications as well.
PixyMisa
30th January 2006, 04:02 PM
They suck.
Use Python. :snake:
russell_morris
30th January 2006, 04:09 PM
C# was Microsofts response to Java, when Sun rebuffed it's attempt to hijack Java.
C# is actually a very well thought out programming language, designed by the man behind Delphi. (Microsoft stole him).
It is trying to be 'one step ahead' of Java, although there is nothing you can do in C# that can't be done in Java.
Java is more universal in terms of platforms it runs on, C# is really just for windows despite the open implementations such as Mono. Java does not integrate as well with Windows, while C#, via .Net, does.
C# is very nice to use, very efficient for a language that uses a VM, but not as widely used as Java.
I agree on most counts - I've been doing 95% .NET work for a little over four years now, and I don't have nearly as many gripes with the system as a whole as I have with others I've been equally involved with (e.g. I'll run amok if I ever even see COM via MFC again).
There is one thing that the .NET runtime has always had over Java - member-specific, user-supplied metadata inspectable by the built-in reflection engine. They're typically referred to as 'Attributes', and they have made writing plugin frameworks a complete snap :) I'm not aware of anything similar in Java that's more sophisicated than predictable name-mangling.
The .NET 2.0 framework also has one up on the new JVM (1.5?) in that it's generics implementation makes generics first-class members in the type system, while the JVM's implementation is primarily compiler magic to maintain backwards compatibility with the boatloads of existing Java code out there.
I haven't use .NET 2.0 on anything production, so I'm not really fit to comment on how well they actually utilized the generics in the .NET base class library.
kevin
30th January 2006, 04:42 PM
Go truly object oriented with Ruby 8)
Complexity
30th January 2006, 04:49 PM
I've been programming in C++ for fifteen years. It is the object-oriented language that I know the best, so it is the one I prefer to use when I have a choice. I've written in both C# and Java and appreciate aspects of both languages, but I use C++ when I can.
I use C++ for my research in algorithm design for challenging problems. I often need to tune my code for speed as much as I can.
For example, one program for factoring that I'm working on will be expected to run full-speed for months if needed (checkpointing and resumption are being added). I expect that I'll be running it on different problems on different machines simultaneously. Speed improvements can lead to real savings in both time and money.
Most of my research programs implement solvers for NP-complete problems and speed is of great importance.
Paul C. Anagnostopoulos
30th January 2006, 05:30 PM
Use Python.
Python is a "whitespace grouping" language, and thus the Devil's work.
~~ Paul
bigred
30th January 2006, 06:15 PM
Well y'all blew by me a handful of posts ago but it's still interesting. um I think.
PixyMisa
30th January 2006, 06:47 PM
Python is a "whitespace grouping" language, and thus the Devil's work.
Yep. That's why it sells so well.
a_unique_person
30th January 2006, 08:56 PM
Python is a "whitespace grouping" language, and thus the Devil's work.
~~ Paul
C++ is the Devil's work, as far as I am concerned. It is the most complex programming language ever created.
ceptimus
31st January 2006, 11:25 AM
PHP uses C syntax (like C++ and java) but PHP has variables more like Perl. Unfortunately, as PHP is normally used to produce HTML output, it becomes difficult to maintain a proper object-oriented approach.
Plenty of jobs out there for PHP jockeys at the moment.
bigred
31st January 2006, 11:56 AM
C++ is the Devil's work, as far as I am concerned. It is the most complex programming language ever created.
Write some programs in Assembler and come back and talk to me.
: old fart :
PixyMisa
31st January 2006, 02:57 PM
PHP uses C syntax (like C++ and java) but PHP has variables more like Perl. Unfortunately, as PHP is normally used to produce HTML output, it becomes difficult to maintain a proper object-oriented approach.
Plenty of jobs out there for PHP jockeys at the moment.
Oh, I loathe PHP.
Well, I guess I mostly loathe the programs written in it, because PHP lends itself to the creation of truly awful messes.
Then again, they say that a real programmer can write COBOL in any language. :)
PixyMisa
31st January 2006, 03:11 PM
Write some programs in Assembler and come back and talk to me.
Z80 assembler is cool!
But I'd sooner take up goat farming than write an accounting package in it.
...
Okay, maybe not.
Complexity
31st January 2006, 03:27 PM
Several years ago, I heard that some programmers wrote a COBOL compiler in COBOL just for fun.
And people think I'm weird...
a_unique_person
31st January 2006, 04:06 PM
Write some programs in Assembler and come back and talk to me.
: old fart :
Nitpicking here. High level languages and assembler are two different animals. One describes the actual hardware you are working with, and makes no pretense at abstraction, (unless you want to go macro mad), high level languages are an abstraction that makes the hardware architecture irrelevant.
McFunley
1st February 2006, 08:27 PM
C++ is of course theoretically faster than Java/C#, but in practice this can sometimes require an expert to achieve. GC confers benefits in non-obvious ways (read: locality). Combine that with the fact that you can generally crank out a managed app twice as fast and the performance criticism loses steam very quickly.
I wouldn't bother learning a language just because "there are a lot of jobs in it." People who are smart can learn any language, and interviewers for good jobs know this.
Pros for each (trying to be original):
Java - Nice tools and library support. Huge community.
C# - .NET is by far the most productive platform for writing Windows applications these days.
C++ - Ability to do absolutely anything, any way you please. Power your computer using nothing but your own sense of self-satisfaction.
Cons for each:
Java - Frequently espoused by gasbags.
C# - MSDN Magazine can be extremely annoying.
C++ - Byzantine and/or tedious.
Hellbound
2nd February 2006, 01:10 PM
Don't know about C#, but I will second that C++ is faster than Java.
The big advantage of Java is that it's a hybrid between an interpreted and compiled language, and the advantage of this is platform independence (to a degree, anyway). With a C++ program, the program is written and then must be compiled seperately for each platform it is to be run on...one for a PC, one for a Mac, etc, etc. THis means that in a multi-platform environement you end up with several exe files and each system has to get the right one.
With Java, it's compiled in to a code language, not an exe. The code language is sort of like a "shorthand" Java. The clients then have their Java interpreter on, and any client can run any Java program (in theory). Java is a better choice when you plan on supporting a wide range of platforms, which is part of the reason it's gained popularity in web-based apps. C++ is better for directed programs, especially where performance is a factor.
TobiasTheViking
2nd February 2006, 01:51 PM
After trying some .net and mono stuff, i must admit, i really do fancy it.
Coming from a linux/freebsd fanboy, that is saying something.
Trying java next wednesday.. Thanks for all your replies, i'm still very much interested in opinions and facts.. GIVE ME DATA. :D
Paracelsus
2nd February 2006, 01:53 PM
Actually the facts behind why Java can on some occasions be faster than C++ is because of the GC. When a C++ program asks to allocate memory it usually must go to the operating system. Operating system calls are usually expensive. When the JVM in java asks for memory it does it the same way, but with one difference when the GC reclaims the memory not referenced by objects the JVM keeps the memory and the next time you allocate some object it checks if there is available in the reclaimed memory. This means that it can avoid some "expensive" operating system calls. Of course this process can be simulated in C/C++ with a construct called memory pooling.
Also the JVM has the possibility of optimizing running programs by collecting information on how the code is used and optimize appropriately. It works usually best with long running processes like servers and such. It is called HotSpot. There is no similar construct for C/C++ available. Closest is some stuff from Intel.
Now the problem is that these things that allow the programs run faster doesn't help some types of applications. Like most numerical applications does not benefit from the possibilities of the JVM.
JamesM
2nd February 2006, 02:46 PM
Isn't multithreading supposed to be faster with Java than C++, too?
bigred
2nd February 2006, 04:45 PM
I wouldn't bother learning a language just because "there are a lot of jobs in it." People who are smart can learn any language, and interviewers for good jobs know this. I'm sorry but that's just plain naive. Not that I don't agree with you, but by and large companies want someone who knows the particular languages/OSs/etc they have or are implementing. Plus it's hard to say from most interviews just how "smart" a given programmer really is.
Unless you're really young or have a really secure job or are rich (or some other condition I'm not thinking of offhand), it makes a GREAT deal of sense to learn a language (or database or whatever) because the job market demands it. Java and Oracle remain among the highest in demand, at least based on what I can tell/have seen and heard.
epepke
2nd February 2006, 05:56 PM
Isn't multithreading supposed to be faster with Java than C++, too?
It's isn't faster, but it's easier because it's built into the language. This is something at which Java excels.
hodgy
3rd February 2006, 11:30 AM
I'm sorry but that's just plain naive. Not that I don't agree with you, but by and large companies want someone who knows the particular languages/OSs/etc they have or are implementing. Plus it's hard to say from most interviews just how "smart" a given programmer really is.
Unless you're really young or have a really secure job or are rich (or some other condition I'm not thinking of offhand), it makes a GREAT deal of sense to learn a language (or database or whatever) because the job market demands it. Java and Oracle remain among the highest in demand, at least based on what I can tell/have seen and heard.
I agree. On the odd occasion that I have interviewed or otherwise been involved in taking people on, I have looked for people who can be useful immediately. This is largely due to the short notice nature of activities that I get involved with but that engagement model is pretty common in IT.
Its also pretty obvious that if someone is advertising for Java programmers and you only know C++, clearly they will not take you on as a Java programmer - maybe as a trainee Java programmer but that's a different job spec and will certainly attract lower wages than the full position advertised.
epepke
3rd February 2006, 05:08 PM
I agree. On the odd occasion that I have interviewed or otherwise been involved in taking people on, I have looked for people who can be useful immediately. This is largely due to the short notice nature of activities that I get involved with but that engagement model is pretty common in IT.
The problem is that if you know Java and C++, say, then managers automatically assume that you can't possibly know either well. It's some sort of zero-sum game, and it's more than a bit goofy.
hodgy
3rd February 2006, 05:52 PM
The problem is that if you know Java and C++, say, then managers automatically assume that you can't possibly know either well. It's some sort of zero-sum game, and it's more than a bit goofy.
Do they?
Generally, if I am looking for people I want them to have product (i.e. an enterprise s/w system) and / or industry (i.e. telecommunications in my case) experience - its not enough to know a programming language but Java (J2EE) is essential as a baseline. Its normally even more specific than that but I won't bore you with the details.
epepke
3rd February 2006, 11:24 PM
Do they?
That's been my experience, looking for a job.
There's a specific instance from five years ago. I applied to a consulting company. I was given a choice between taking a test in C++ or Java. I chose C++. I only missed one question, and I would have argued about it because I think I got it right but didn't use the right buzzwords, except that it was only 3% out of 100%.
Because I had taken the C++ test, after the followup interview (which didn't ask any Java questions), it was determined that ipso facto I couldn't be brought up to speed in Java. Which is rather absurd, frankly. But it happened.
hodgy
4th February 2006, 03:26 AM
That's been my experience, looking for a job.
There's a specific instance from five years ago. I applied to a consulting company. I was given a choice between taking a test in C++ or Java. I chose C++. I only missed one question, and I would have argued about it because I think I got it right but didn't use the right buzzwords, except that it was only 3% out of 100%.
Because I had taken the C++ test, after the followup interview (which didn't ask any Java questions), it was determined that ipso facto I couldn't be brought up to speed in Java. Which is rather absurd, frankly. But it happened.
Obviously the people doing the recruiting were idiots - I have also been on the recieving end of stupid recruitment processes so I take your point. It doesn't mean that your experience is a general rule though.
bigred
4th February 2006, 10:29 AM
No, but I can tell you that stupidity, recruiters, and esp. HRers quite often go hand-in-hand. Don't get me started.......
hodgy
4th February 2006, 03:48 PM
No, but I can tell you that stupidity, recruiters, and esp. HRers quite often go hand-in-hand. Don't get me started.......
Hah hah - HR is just a way for admin people to justify higher wages. In my experience they provide no value whatsoever to the business.
McFunley
4th February 2006, 05:40 PM
I'm sorry but that's just plain naive. Not that I don't agree with you, but by and large companies want someone who knows the particular languages/OSs/etc they have or are implementing. Plus it's hard to say from most interviews just how "smart" a given programmer really is.
Unless you're really young or have a really secure job or are rich (or some other condition I'm not thinking of offhand), it makes a GREAT deal of sense to learn a language (or database or whatever) because the job market demands it. Java and Oracle remain among the highest in demand, at least based on what I can tell/have seen and heard.
I suppose I don't disagree with you either, in that sense. What I should have said is that the original poster should concentrate on learning to learn new skills, since that's what ensures long-term viability in the industry. The fact of the matter is that Java is popular now, but it's far from a given that it will still be a reasonable choice for applications in the future. And, jobs in big companies mostly suck, so avoid them if you can :).
hodgy-- I would definitely hire a C++ programmer for a Java job, if I thought he were smarter than any of the Java applicants. I might be using Java on this project, but since I use the right tool for the job I might be using Visual Basic on the next one and Lisp on the project after that.
If you are a consulting company it may make sense to hire based on immediate need, but it makes no sense if you are trying to build a software company.
epepke
4th February 2006, 06:45 PM
Obviously the people doing the recruiting were idiots - I have also been on the recieving end of stupid recruitment processes so I take your point. It doesn't mean that your experience is a general rule though.
Well, it's my experience, and I've been looking for a job unsuccessfully for a couple of years now.
And if it isn't a general rule, perhaps you could give me a telephone number or an email address or something for a recruiter or manager who 1) is not an idiot, and 2) is looking for people who are way smart and way competent. I will work anywhere on the planet except Atlanta.
Angus McPresley
4th February 2006, 11:05 PM
The original poster asked for some hard data, and all he got was more unsupported opinions in reply.
So, let me add mine. :D
C and C++ give you too much rope to hang yourself. It's too easy to write bad, leaky, unmaintainable code using them. They're fine if you have people who can write them well, and are willing to stay with the company and support the code, but that's almost never the case. Yes, you can certainly write bad Java, but it's not as easy.
(This is the point where I should mention that I won the International Obfuscated C Code Contest six times. Not because it's that relevant to my argument, but just because I bring it up every chance I can, for reasons that I'm still working out with my shrink.)
I saw Bjarne Stroustrop speak at a C++ World convention, and he was asked about the C++ vs Java question. His response was basically, "If you look at everything that C++ set out to achieve, well, it pretty much achieved it. If you look at what Java set out to achieve (security, etc) and compare it to how it actually did, well, it doesn't fare too well." Everyone nodded, myself included, but afterwards I thought about it. By that argument, might not COBOL be a better language?
bigred
5th February 2006, 04:52 AM
Hah hah - HR is just a way for admin people to justify higher wages. In my experience they provide no value whatsoever to the business.
lol - exactly
jeremyp
6th February 2006, 07:45 AM
But, what are the facts on these three different languages? Google gives me mostly flame wars and unsubstantiated opinions.
And why do you think the JREF forums are immune from flame wars and unsubstantiated opinions?
My opinion (substantiated only by my experience) is:
Java has the cleanest syntax and the best class library. However, for server side (J2EE) applications things get very complicated very quickly.
C# has an exceptionally good development environment (if you use Visual Studio) which makes it very quick and easy to build and deploy client and server applications. It's class library is limited in comparison to Java and, of course, it is effectively Windows only. It has some nice language features missing from Java.
C++ is a bloated monstrosity but it is still my first choice for anything where you cannot use a managed run time.
TobiasTheViking
6th February 2006, 10:24 AM
And why do you think the JREF forums are immune from flame wars and unsubstantiated opinions?
Hope?
Desperation?
that said, thanks for your comment, looking forward to dipping my hands in java in two days time.. But i have really come to enjoy C# a lot.
Hell, i even installed mono on my workstation.
Marker
3rd March 2006, 01:58 PM
People who are smart can learn any language, and interviewers for good jobs know this.
You must live in a different world than me - most of us go through recrutiment agencies who create an ignorance barrier between the candidate and the employer. I was once asked if I "had" BASIC. I listed all the various flavours of BASIC I had had experience with (which was many at the time) only to get the response "Pity, what we are looking for is someone who has ordinary BASIC. Thanks anyway, goodbye".
I have also been asked if I "know" milestones - (as though this were a new programming language) and was once turned down for a job because I didnt have "RUP" on my CV - this depite the fact that the top line of my summary reads "7 years experience using, implementing and training others in the Rational Unified Process".
marting
5th March 2006, 12:08 AM
Well, having programmed in IBM 1620 ForGo, Interdata asm, Z80 asm (TDL), RATFOR, SQL, masm, C++ (Whitesmith's on up), VB 2.0 to VB, C#, C++ under .net I think C++ is really the best workhorse language for efficient bit level coding of some complexity. Especially if you need control over data memory layout and are interfacing with ASM or device drivers. For quick and dirty, C# is quite good though VB has some advantages when hooking COM objects with variable argument lists. Under .net they are fairly easily combined and the MS 2005 dev tools have good debugging capability.
As I'm typing this I'm loading in another 7.5GB TaQ NYSE DVD to the server. I need to write some front end access components to hook an expected multi terabyte data set to a SQL server - or perhaps go directly to the data set. I'm leaning on doing it in C# though I need access through matlab, will probably use their COM hooks, so I need to test .NET COM interop for compatibility first.
© 2001-2009, James Randi Educational Foundation. All Rights Reserved.
vBulletin® v3.7.5, Copyright ©2000-2010, Jelsoft Enterprises Ltd.