Thread: Java vs. C++

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    66

    Java vs. C++

    There is always that question of which is better. So I'm asking you guys, why did you choose C++? If you have tried both Java and C++ say so and let me know which you like better and why.

  2. #2
    Registered User
    Join Date
    Jul 2007
    Posts
    17
    I chose c++ because its more flexible than java, you can do more with c++, though it may be more confusing i still prefer it, plus i love dealing with confusing stuff lol. I still program in java sometimes though, just so i dont go rusty

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I didn't choose C++ over Java. I was taught C++ in school and my job primarily uses C++. We are working on other stuff in Java, and when I move to that other stuff I'll use Java.

    You're probably more interested in why some stuff uses C++ and other stuff uses Java, but I didn't really make that decision so I can't give an actual answer for my specific situation.

    As far as which I like better, I'd say C++ mostly because I'm more comfortable and familiar with it. If and when I get more comfortable with Java I don't know whether I'd have a preference.

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    17
    Did you learn c++ in highschool or college? I learned java in highschool, well actually a tradeschool but it was while i was in highschool lol

  5. #5
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    ditto Daved's answer. It's fairly narrow of a person to limit themselves to one language. I routinely switch between Java/C/C++/Ada for work. A programmer is a programmer and should be able to handle whatever language you throw at them.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    It might be new to you, but it's the same old question over and over again for some of us.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Language comparison questions do come up from time to time, and they tend to end up like this one: C++ compared to Java.

    I would say that one should use the best tool for the job. I happen to like the fact that C++ allows for "multi-paradigm programming", with the use of both OOP and template (meta-)programming, and I find the concepts in its standard library interesting. These will not deter me from working on a project in Java.

    Oh, and I note that it was moved to the Tech Board even before I could finish my post
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Massively Single Player AverageSoftware's Avatar
    Join Date
    May 2007
    Location
    Buffalo, NY
    Posts
    141
    A friend of mine once said, "Java is like C++'s retarded younger brother."

    I love C++ because it trusts me. Java infuriates me because it doesn't. Still, I do use Java for certain projects because it's the most suitable choice.

    Lately, Objective-C (the other object-oriented C) has been getting a lot of my attention. Can't recommend it enough.

    Learn as many languages as you can, they all come in handy.
    There is no greater sign that a computing technology is worthless than the association of the word "solution" with it.

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> Did you learn c++ in highschool or college?
    College... sort of. We had a Pascal class and a C class, and we spent a couple weeks in our data structures class learning C++. Then we had to use it for all the rest of the classes. The classes were more for theory and stuff anyway, which is generally more important than language specifics. That's why we didn't spend a lot of time on the language itself.

  10. #10
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    Horses for courses. There's no way I'd use C++ to build a web-based commerce server. Equally there's no way I'd use java to build a cutting edge 3d engine or a large high performance system.

    Anyway the point is moot as python is better than both
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  11. #11
    Registered User Dave++'s Avatar
    Join Date
    Jun 2007
    Location
    Where the Buffalo Roam
    Posts
    40
    I'm doing C++ in Unix on a hardware effort, but I'll be using Java in Eclipse to develop cross platform apps from my MAC.

    The cost in time and overhead to learn multiple IDE's and multiple environments can be taxing.
    Last edited by Dave++; 07-06-2007 at 01:59 PM. Reason: "MAC" in caps for emphasis !

  12. #12
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    I wrote a rather small program that was required in a university course in C++. It was considerably easier than it would have been in Java, due to some strange requirements of the application that were easily met by the Boost libraries.
    I'm writing a large web platform in Java. I don't want to think what this would take in C++ right now. (But I expect this situation to change over the next 5-10 years.)
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  13. #13
    Massively Single Player AverageSoftware's Avatar
    Join Date
    May 2007
    Location
    Buffalo, NY
    Posts
    141
    Quote Originally Posted by Dave++ View Post
    I'm doing C++ in Unix on a hardware effort, but I'll be using Java in Eclipse to develop cross platform apps from my MAC.

    Pet peeve, Mac is not an acronym, and should not be written "MAC" unless you're referring to network card's hardware address.

    The cost in time and overhead to learn multiple IDE's and multiple environments can be taxing.
    Yes, but it's extremely worthwhile. I'm a C++ programmer by trade, and I'm amazed at the number of "C++ Developers" that only know how to use one IDE, and just start floundering if you put them in front of something they don't know. At home, I use Xcode, Dev-C++, KDevelop, and sometimes just plain vim to do coding. When I started my job, I had to learn how to use Borland C++ 6 and Visual Studio 2005. My exposure to so many different IDEs allowed to pick both of them up with no problem.

    In short, learn as many IDEs, languages, and especially operating systems as possible. There are hundreds of "I only know Visual Studio and Windows" people out there. Differentiating yourself by knowing your way around Macs and Linux machines, and how to develop for them, can go a long way toward getting a decent job.
    There is no greater sign that a computing technology is worthless than the association of the word "solution" with it.

  14. #14
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I agree that IDEs server their purpose, and they probably are worth learning but becoming less dependent upon them in general is also a good thing. If you need an IDE to compile a "hello world" program, then something just ain't right with where you're at. There are loads of people that can't navigate in a shell of any kind (probably loads of those VS + Windows people ), and that's bad to be in that category.

    I would argue that properly learning different shells, compilers, languages, O/S system calls.... at least to some extend to be able to move around in a shell and figure out what compiler switches to use and such should be primary. I think IDEs are secondary, but I admit, I just hate IDEs since they seem to hide a lot of options that a compiler switch can take care of. Perhaps I'm wrong in that regard.

    To comment on the original topic....

    C++ allows you to write software in many different ways, with paradigms not very well suited for Java. Java is meant to always be used as an OOP language. I think it's a clean language in that regard, and the API is quite rich and provides a lot of classes for various usages.

    C++ gives you more power to communicate with the O/S, and as such, with the hardware of a machine, but such communication is not standard (with regard to C++ I mean... ie. different hardware, different O/S.... means different code). Java is stuck with communicating with the VM and any other extra JNI stuff you tack on, which suffers from the same thing that C++ does, but the Java API is pretty standard and you can guarentee a lot of what will happen on most platforms.

    C++ is more efficient than Java in terms of the speed of the execution of the language at this point. Due to Java being interpretted, it's obviously slower, although I read there are optimizations available that make some Java programs run faster than hardcoded compiled programs by having the code recompiled on the fly to be more efficient depending on branches that the program takes as it is executing (Note: This isn't a full reality yet for practical usage afaik).

    Depends what you want from the language really. Personally, when I want to deal with the O/S or I want a "real program", I typically use C instead of C++ out of habit, having learned C. When I want an OOP approach to a problem, or something involving threads and sockets, I generally will choose Java over C and C++, since Java's sockets and threads are pretty portable. In addition, I think the OOP approach is better in Java than in C++, but I haven't done much work with C++ really, so I'm biased in that regard.

    Overall, this is a long debate, and it's been going on for years, and will probably continue for awhile longer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Java for real-time applications
    By zacs7 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 08-26-2008, 06:34 AM
  2. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 02:06 PM
  3. The Java language is being expanded
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 06-11-2004, 09:07 PM
  4. Java woes
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-06-2003, 12:37 AM
  5. How to use Java with C++
    By Arrow Mk 84 in forum C++ Programming
    Replies: 2
    Last Post: 02-27-2003, 04:12 PM