Java vs C++ research paper

Started by
8 comments, last by mihaimoldovan 11 years, 11 months ago
Hello everyone, I'm just going to start by explaining that this isn't like your average "What is better, C++ or Java?" post. I need to write an argumentative research paper for my grade 12 English class, which has two valid sides, but choose one side to support in the end. I decided to pick something related to programming and opted for this since there would be a lot of information on it. Since I've only ever programmed with Java and not gone very deep with C++, I would like some other, more qualified opinions. So, my questions are as follows:

1) As a Java developer, why do you believe Java is better for your needs than C++?
2) As a C++ developer, why do you believe C++ is better for your needs than Java?
3) If you've used both, which do you prefer and why?
4) What are the actual technical differences between the languages?
5) Can you point me in the direction of some good resources to look at?


Thanks guys
Advertisement
I'd say its a "wrong question" problem... but anyway:

1. I tend to use java for quick ui based stuff mostly because of its expansive framework and wide support without explicit porting
2. I use C++ for most of my "research" stuff since most of the scientific libraries that i develop for and with are more at home there and because I think its the right tool for hpc/cluster computing.
3. I feel more at home when doing C++ because I feel I can create more expressive interfaces with it. But its really a question of what is the problem at hand (that is like asking "do you prefer planes or cars?"... "well, i can't drive overseas, and flying to the supermarket would be nuts.")
4. Compile time "stuff" (templates, inlining, static optimization etc.) plays a huge role in how I use C++ but is barely even there in java, which makes me think about code differently.
5. no
The question is broken.


Java is not better than C++, nor is C++ better than Java. You have to provide some context. A Geo Metro is not better than a Formula One car if your goal is to win races; conversely, an F1 car is not better than a Metro if you're trying to drive to work without getting arrested. Context is everything.


Provide some context for this debate, and you might have a reasonable paper on your hands. Otherwise, you're basically going to end up writing a lot of arbitrary quibbling for one side or the other, and virtually all of your points are going to be questionable at best and trivially countered at worst.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

I'll agree what Japro's first sentence and what ApachPiQ said, bug I'll also answer the questions:

  1. As a Java developer, why do you believe Java is better for your needs than C++?

    1. I'm more of a C++ developer, but I've done work in Java before. When I've used Java at work, it's typically been on a server system, and since Java has some nice libraries for server development, it fit the bill.
  2. As a C++ developer, why do you believe Java is better for your needs than Java?

    1. At work, I primarily use it because that's what the projects I'm working on have been written in. Another reason is that we need a way to get access to the native libraries offered by the operating systems we work on, and for us that's most easily done in C and C++ (sure, we could make a JNI wrapper, but then you're mixing languages and we might as well just pick one and stick with it... plus it'd be a nightmare maintaining JNI wrappers for dozens of 3rd party external C/C++ libraries).
  3. If you've used both, which do you prefer and why?

    1. Depends. Typically, I'll usually lean towards C++ because I've used it more than Java, though I can work comfortably in both. I'll pick whichever one has better tools for doing what I want to do, typically.
  4. What are the actual technical differences between the languages?

    1. Oh boy. That's a huge list... I'm not even going to begin listing things... Here's a link
  5. Can you point me in the direction of some good resources to look at?

    1. Just did wink.png



In short, I wouldn't say X is better than Y, or X stops you from using Y either. I might say X might have more tools than Y to do a specific job Z, but this varies from job to job so I don't think X vs Y can be extrapolated past a specific job. Languages are tools. Pick the tool that fits the problem. Hammers aren't inherently better than wrenches; hammers are just better at some things than wrenches are, but wrenches are better than hammers at other things too. Using a hammer doesn't mean you can't use a wrench either.

You did get "is better for your needs" in your question, which I think is very good. The thing is though, a good programmer will be able to work in multiple languages, and usually there are multiple needs a developer faces (whether all at the same time or spanned throughout his career). I've used Java and C++ at work, because they're both better for my work's needs. Using one doesn't preclude using the other.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
1) As a Java developer, why do you believe Java is better for your needs than C++?
1. I like that it's possible to define variables outside constructor, just at variable declaration. I think this is planned in C++ later on, but this feature feels quite obvious. Not sure why C++ doesn't have it.
2. No separate header/code file. I find it redundant to have header and code files like in C++. Most people say it's to prevent multiple definition, but if I define class' methods only inside class' file, there will be no multiple definitions.

2) As a C++ developer, why do you believe Java is better for your needs than Java? (Java better than Java? I think mistake here; assuming C++ better than Java)
1. Overloaded operators. Simplifies a lot things. Java has a few but you cannot add own ones. That's kinda stupid. You have to block them completely, or allow them completely.
2. Templates. They seem to be more advanced in C++ than in Java.

3) If you've used both, which do you prefer and why?
Definitely C++. I feel it's faster and gives me more freedom. Many people claim Java is faster, But even simple for() loop with little maths inside is slower in Java. C++ compiler tends to destroy loop as everything is constant (volatile fixes that), but even with volatile's disadvantages it remains faster.

4) What are the actual technical differences between the languages?
I believe Java adds simplicity for rapid development, especially with all the packages, great for basic/simple stuff. Plus Java is cross-platform, so you don't have to worry about anything but your program. On other hand, C++ takes time to create things, but it ends up very fast in execution, however it's not likely to run more than on one machine without recompiling and code edits.

5) Can you point me in the direction of some good resources to look at?
Google of course. You're likely to find to syntax or other differences, which have own advantages and disadvantages.

C++ compiler tends to destroy loop as everything is constant (volatile fixes that)


I'm sorry, but what do you mean by that?

I'm sorry, but what do you mean by that?


If you do a completely predictable loop like you would do in "naive" benchmarking.

int a = 42, b = 23, c;
for(int i = 0;i<10000000;++i)
c = a*b;

C++ compilers will often realize that the result is always the same no matter how many iterations and will just remove the loop.
As above, one can't be better without defining first objectively defining "better". If you first pick a purpose or task to carry out, you could then define some meaningful metric to measure them both with.

For example, I mostly write systems code, which tends to be very explicit about resources, is performance critical (i.e. it's used a lot by the game/app per frame) and cares a lot about small details, such as which RAM byte addresses correspond to which variables. C/C++ are pretty friendly towards this kind of detail.
In Java, a lot of these small details are already implemented by the JVM -- in fact, if you were building the JVM itself, then C/C++ would be a good language to use.
Instead, Java is good for application programming, where the all the low-level systems that you need already exist, and you can get on with using them to build a game/app.

Often games are built with two (or more) languages; one for the engine runtime (systems), one for the gameplay code (scripting/application) and even another for the development tools. For example, I make my engine in C++ (because it's a powerful blank slate), which is used by my game in Lua (because it's easier to write than C++) and my data files are created from tools written in C# (because it's quick to make apps with thanks to many "systems" already existing in the standard library). ...but you could swap any/all of those for Java depending on your situation.

I need to write an argumentative research paper for my grade 12 English class, which has two valid sides, but choose one side to support in the end. I decided to pick something related to programming and opted for this since there would be a lot of information on it.
[/quote]
A more interesting topic might be arguing about the merits of general language comparisons, as opposed to domain/implementation specific comparisons.


Definitely C++. I feel it's faster and gives me more freedom. Many people claim Java is faster, But even simple for() loop with little maths inside is slower in Java. C++ compiler tends to destroy loop as everything is constant (volatile fixes that), but even with volatile's disadvantages it remains faster.
[/quote]
Artificial benchmarks yield artificial results.
As everyone said here, it's really not about the language but about the contents of what you are doing and the quality of implementation.

Most universities nowadays prefer to teach Java over C++ simply because it's cheaper and easier to find people capable of teaching it, and ultimately even the creator of Java admitted that one of the main design goals of the language was not programmer productivity, but ease of learning.

C++ on the other hand is often described as a dog with 9 extra legs bolted on, it doesn't particularly lend itself to novices but it does give you full control of the underlying machine which can be quite beneficial if you happen to be knowledgable about computer architecture in general.

This topic is closed to new replies.

Advertisement