Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: How much easier is Java compared to C++

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default How much easier is Java compared to C++

    I know that Java is easier than C++. What I'd really like to learn is C++, but I'm having a hard time in school and am thinking that it may be easier if I just took the Java path. If I take Java when I look back I don't want to say: "I should have done C++" I want to say "Good thing I did Java, I wouldn't have been able to do C++."

    So, I know that Java is easier, but how much easier? I think I would be able to grasp Java, but I don't want to take C++ and have it go way over my head and end up dropping.

    I want to make video games (C++) if that matters, but realize it's very difficult to break into the game industry and will probably do something else.

    Thanks, Brad


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: How much easier is Java compared to C++

    Learn both. I know both languages (as well as others). The thing about C++ is that you have to very explicitly understand the memory model, where in Java you can get away with almost anything short of murder (I'm exaggerating here). However, in order to write good Java programs, you need to understand the memory model regardless of the language you use.

    The syntax of C++ can be a bit cryptic, but to be honest I didn't think it was something that couldn't be overcome. I think the part about Java that makes it easier to understand is the language and terms used. It's easy to see that a function is abstract, but it's just a little more difficult to understand what it means to be a purely virtual function. C++ also encompasses many more ideas and programming paradigms than Java, though from a beginners standpoint I don't know how many of these paradigms you'll actually use until you get into the finer points.

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: How much easier is Java compared to C++

    Quote Originally Posted by helloworld922 View Post
    The thing about C++ is that you have to very explicitly understand the memory model, where in Java you can get away with almost anything short of murder
    Thanks for the reply. What exactly do you mean by this. That I would likely get less errors to my code in java?

  4. #4
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How much easier is Java compared to C++

    I think you better stay in Java, like C + + you also can develop games with it and if you stop to think, Java is the evolution of C / C + +

  5. #5
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: How much easier is Java compared to C++

    In C++ you must explicitly specify if you have a reference value, a value, or a pointer value. In Java, all objects are referenced and all primitives are values. C++ also forces you to manually clean up memory you allocate onto the heap.

    // C++ code
    #include <string>
    #include <iostream>
     
    void helloReference(std::string &name) // name is passed by reference, not by value
    {
        std::cout << "hello " << name.c_str() << std::endl;
    }
     
    int main(int argc, char* argv[])
    {
        std::string name("Psychotron");
        hello(name); // even though name is a value variable on the stack, it will still get passed by reference
        return 0;
    }

    This is equivalent to the following Java code:

    public static void hello(String name) // value types are passed in a pseudo-reference way
    {
        System.out.println("hello " + name);
    }
     
    public static void main(String[] args)
    {
        String name = "Psychotron"; // name is a reference type
        hello(name); // passed by pseudo-reference
    }

    I think you better stay in Java, like C + + you also can develop games with it and if you stop to think, Java is the evolution of C / C + +
    I personally don't prescribe to the view of sticking to one language. I think if anyone is willing to put forth the time and effort they can start with either language and be able to learn it just fine. That being said, Java does focus your thoughts a little better simply because there are less features in the language, and you don't have to manually manage your memory usage (which many people like this, I like it sometimes and hate it other times). C++ is by far the more powerful language (or more liberal in what it allows the user to do), but with this power means that the programmer has to know exactly what they're doing to use it correctly.

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,441
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 544 Posts

    Default Re: How much easier is Java compared to C++

    Quote Originally Posted by Psychotron View Post
    I know that Java is easier than C++.
    I'm going to stop you right there. For most non-esoteric languages, there is really no such thing as "easier" or "better". A person can prefer a language, or a language can be better suited for a specific context, but it's mostly a subjective matter of personal opinion. It's like saying "I know green is better than red, but how much better is it?"

    The stuff pointed out already (memory management, etc) might make Java look "easier", but others would argue that newbie programmers understand procedural programming much faster/easier than they understand object oriented programming (and their claims would be supported by the frequent abuse/misuse of the static keyword).

    You're on a Java forum, so people are typically going to prefer Java. If you went to a C++ forum, you'd get opposing answers. Same if you went to a webdev forum, pascal, lisp, etc.


    Quote Originally Posted by Psychotron View Post
    What I'd really like to learn is C++
    Can I ask why? More specifically, why that over any other language?

    Quote Originally Posted by Psychotron View Post
    So, I know that Java is easier, but how much easier?
    How should we even answer this question? It's seven easier. But seriously, like I said, it's not a matter of easier or better- it's personal opinion. I might think Java is easier and better, but your brain might fit around python better. I can't know.

    Quote Originally Posted by Psychotron View Post
    I want to make video games (C++) if that matters, but realize it's very difficult to break into the game industry and will probably do something else.
    C++ isn't the only language you can use to make games. Look at the popularity of flash games. Look at Minecraft (that's Java). There are a ton of resources on programming games in Java, actually.

    I'm not trying to turn you off of any language in particular, but I don't think the question of "which language is easier/better" is valid. It depends on the person, and it depends on the context. You might want to try a little bit of a bunch of different languages, see what fits into your head the best, and go from there. Or just dive into one and translate that knowledge to other languages later. It's really up to you.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    471
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: How much easier is Java compared to C++

    A programming language is a tool. Ideally, you should pick the most suitable tool for the task at hand. In practice, there are a lot of other factors, including usability, technical complexity, availability of tools and libraries, learning curve, educational value; then there's approval & support (e.g. in the work environment), and popularity & future (for future employment possibilities), and so-on.

    All these factors change in importance with time as your experience and goals change. Before deciding which language to concentrate on, you need to assess your current position, where you want to get to in the short term, and where you'd like to be in the longer term.

    For example, are you just starting out? is this going to be a hobby or a career? is your interest in gaming, or web apps, or low-level OS stuff, or finance, or research, or graphics or what?

    C++ is technically complex, hugely flexible, and interfaces well with most operating systems; it lets you code 'down to the metal', but with that power you need care and respect. Java is technically simpler, less linguistically flexible, higher-level (abstracted from the hardware and OS), but has a multitude of libraries and frameworks for GUI development and especially web-based development. It's a more forgiving environment, but more restricted.

    As a (very) broad-brush generalisation, operating systems, servers, and low-level tools and utilities are more likely to be written in C++, and the applications that run on them are more likely to be written in Java. Both languages are showing their age, and in the business world, the Microsoft .NET language equivalents, and other scripting languages, are serious alternatives for higher-level stuff. In general, the more languages you become familiar with, the more options you'll have.

    I think it helps to have an understanding of the low-level basis of programming and programming language design & structure, so a familiarity with C++ and other languages is very useful, but if I were starting out today, I'd be looking primarily at Java and web development (scripting languages and web frameworks) with C++, etc., as an educational adjunct.

    YMMV
    Last edited by dlorde; May 24th, 2011 at 12:18 PM.

  8. The Following User Says Thank You to dlorde For This Useful Post:

    KevinWorkman (May 24th, 2011)