Thread: C++ vs Java

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    66

    C++ vs Java

    Which one is 'better'?What are their advantages/disadvantages? It seems that C++ is more powerful, however Java can be used online.
    An Unofficial Cristiano Ronaldo Website : Ronaldo 7

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Java is barely used online as applets nowadays. People use Flash. Java is easier to learn and is more "programmer-friendly." However, I recommend C++ because of its power, features and what not.

    I learn Java first then C++, 2 years later. C++ all the way.

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    I personally use both. For quick multi-platform GUI development I prefer Java, whereas for anything else, I like C/C++.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  4. #4
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Another important difference is that Java is interpreted whereas C++ is compiled. That means that running a Java program is much slower than a C++ one.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  5. #5
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    Originally posted by joshdick
    Another important difference is that Java is interpreted whereas C++ is compiled. That means that running a Java program is much slower than a C++ one.
    Yeah. But one bad thing about C++ being compiled is it can produce more serious errors whereas Java's errors usually just stop the program.

  6. #6
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    No, most errors in C++ are caught at compile-time whereas Java's errors wait for run-time.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  7. #7
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Java runs about 10% slower than C++ last time I did a test. Its pretty acceptable.

  8. #8
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Originally posted by joshdick
    No, most errors in C++ are caught at compile-time whereas Java's errors wait for run-time.
    I can't think of any situations like that. You got some examples?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  9. #9
    Registered User
    Join Date
    Jan 2003
    Posts
    311
    Java is a platform as much as a language. although the syntax is related much of the design and philosopy is radically different. Java has much more power, as the word is originally used than c++. c++ is more low level than Java and thus, by definition less powerfull. This is not a bad thing, less power puts more decisions in the hands of the programmer and thus more control. An automatic transmission is more powerful than a manual transmission as your car is making more decisions. If you look at a class with virtual methods and non-trivial constructors it does more, is more powerful, but you can't make a copy with memcpy, can't save it to disk with write, can't read it from disk with read, can't include it in a union and so forth. A Java reference can do things that a c++ pointer cannot, like relocate or garbage collection. The JVM can even (under the right conditions) make that reference a simple imedeate location in the JIT code (like an automatic in c/c++) this comes at the cost of sometimes having that reference be a pointer to a pointer (possibly with some additional management beyond that). Different tools for different problems. Java is the best tool for creating programms for the Java platform. c++ is my prefered tool for creating computer programs.

  10. #10
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    Which one is 'better'?What are their advantages/disadvantages?
    It seems that C++ is more powerful, however Java can be used online.
    I just go mad when someone says that something is more powerful than the other, and most of the time, it turns out that they have no idea what they are talking about (no offense Cris987, you are actually asking), did anybody else notice this powerful thingy?
    now back to topic:
    Both have uses, you should always Pick The Right Tool For The Job™, Win32 client programs in Java just suck, while network programming, servlets, multi platform programming rock, those just are examples btw.
    Anyway, I highly recommend you to learn both, so you can pick up the one that suits the job better.

    EDIT: fixed formatting and a typo, you can see the old version below
    Last edited by glUser3f; 01-04-2004 at 04:18 PM.

  11. #11
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    gluser3f is right, learn both , it gives you alot more options for how to solve a problem, i.e. you need to make a GUI for a database program, you dont need alot of speed as it isnt a very mathematical intense program, so you would use JAVA for its easiness of making something like that. on the other hand, if you are making a 3d FPS , you would go with C++ or ASM because they give you more choices and are less bloated and provide the speed the game needs.

  12. #12
    Registered User
    Join Date
    Nov 2003
    Posts
    66
    Originally posted by glUser3f
    I just go mad when someone says that something is more powerful than the
    other, and most of the time, it turns out that they have no idea what
    they are talking about (no offense Cris987, you are actually asking),
    did anybody else notice this powerful thingy?
    now back to topic:
    Both have uses, you should always Pick The Right Tool For The
    Job? Win32 client programs in Java just sucks, while network
    programming, servlets, multi platform programming rock, those just are
    examples btw.
    Anyway, I highly recommend you to learn both, so you can pick up the
    one that suits the job better.
    Thx guys...
    An Unofficial Cristiano Ronaldo Website : Ronaldo 7

  13. #13
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I just go mad when someone says that something is more powerful than the other
    I feel the same way when somebody tries to compare two programming languages. The scope of such a comparison is way beyond a little thread like this one. Basically, the best answer you can get is an opinion (usually not well thought out either).
    My best code is written with the delete key.

  14. #14
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    I like Java because it has so many features built into the language standard: concurrency, GUI classes, networking and much, much more.
    C++ on itself cannot do much useful. You'll need additional libraries that aren't part of the standard.
    The performance difference is often not important. I belive that future computer languages will be more like Java and Haskell and less like C and C++, with more layers of abstraction. Not many are programming in assembly these days.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  15. #15
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    as for the performace, it's not an issue any more for Java IMO, modern computers run Java apps quite well, and if Swing's theme is set to the OS native's, you hardly notice the difference.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 02:06 PM
  2. First Java Class at college
    By GanglyLamb in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 09-29-2004, 10:38 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. C or Java as a first language
    By CorJava in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 10-23-2002, 05:12 PM