I'm a Java guy doing mostly Android stuff.
I want to get into game programming for Android and was wondering if there is any point learning C (not for android obviously as there you can only write in C++). What do people still use C for? Isn't it a bit old and overrun by Java and Objective-C?
I will definitely learn C++ as everybody says you need it for game programming. Would you learn it simultaneous to Java (I'm still learning) or should I learn Java first?
Despite being quite an old language, C is in fact still one of the most frequently used languages. According to the well known Tiobe language index, it only trails behind Java: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
C is still being used a lot in many environments, among which embedded systems but also regular desktop applications. Especially on Linux, C has a strong following even for work outside systems/kernel development.
The Java / C++ connection is legendary though. It's clear the Java syntax heavily leans on the C++ one, but in concepts the language is actually much closer to Objective-C. Patrick Naughton (one of the early Java language designers) has recently posted about this: Java Was Strongly Influenced by Objective-C
So to better understand Java it definitely pays off to learn C++ and Objective-C at some time, but it absolutely isn't a requirement. If you've learned any of those two, you have automatically learned (large) parts of C.
In general, better learn one language reasonably well before hopping on to the next one.
I learned C as my first language. The focus was on memory allocation and deallocation, and simple datatypes such as dynamicly allocated arrays, variable sized dynamic allocated arrays, pointers et cetera.
This was enough to do a fully fledged application of course, but looking back at it now, it was much harder to do things in; I was limited to arrays, dynamic or static, so the complexity of it was horrible.
Anyway, it meant that later on I could focus on object oriented programming and efficient data structures, algorithms et cetera in C++ and Java without worrying at all about programming.
All methods work, but I'm very glad that I understand how memory works. Most of the people I meet at my University that learned programming through Java, do not understand this. And I think it's quite important :)
C is one of the most powerful languages available. And as they say with great power comes great responsibility. Due to its immense flexibility it is very easy to make mistakes and drive programmers crazy while programming/debugging in C. Anyhow I feel that to be a 'great' programmer, you need to learn the nuts and bolts of how memory and pointers are allocated/deallocated, garbage collection.. from C which is never exposed to programmers in Java. And for your game programming ambitions it will definitely help too as you use it to optimize performance.
I'd recommend you learn C along with Java, so that you better appreciate their differences and similarities or you would become too dependent on Java and the transition to C becomes more hard.
To learn any language, the best way is to program. Here http://cslibrary.stanford.edu/, you would get the best exercises to get you started.Have fun!
If you learn C++, learning C is only a small step. As a first approximation, C is more or less a subset of C++.
I'd thoroughly learn Java together O-O design skills and design patterns, before taking on C / C++. Once you start with C / C++ you have to deal with issues like pointers and explicit memory management ... and language specifications that say "the behavior of X is undefined" a lot more.
It is easy for the complexity of languages like C and C++ to get in the way of learning design skills.
Firstly Objective-C is basically only for development on Apple technologies so it is definitely not as powerful in its compatibility/portability aspect as opposed to C. C++ was actually only created as a library to add classes to C. When developing in C++ you are really developing in a massively updated C. Java has not overrun C rather provided another approach to programming. Java does not have the low level power of C(editing memory...).
C is used for system programming in particular in Linux kernel.
But in fact, learning programming languages != learning programming.
So, its best for you to learn Java first as your primary programming language AND read some books listed here: What is the single most influential book every programmer should read?
After that expanding your knowledge would be easier.
C is used for many things. Most of (PC) applications you use are still written in C or C++. You can read about the details here for example ;-)
Java is different, and it is not really that evolutionary step that many advocates try to suggest.
Related
Here's my situation: I taught myself C++ (albeit rather badly), and was later taught how to use Java in college. Returning to C++, I find myself confused by several things that differ from C++ to Java, for example memory management and avoiding memory leaks.
What would be the best mode of returning to programming in C++? Should I read a beginner's guide again, or are there some good references for my kind of situation?
All help is appreciated and thanks!
If you never properly learned C++ (you say you learned it "badly"), start over. Forget everything about Java, because trying to use Java idioms and techniques in C++ is just a recipe for bugs and memory leaks and very inefficient code. The differences between the languages are fairly big.
So get a good book teaching C++ from scratch.
There are books especially for your desire, check out:
C++ for Java programmers by Mark Allen Weiss, or by Timothy Budd.
Here are some links:
Moving from Java to C++
C++ for Java Programmers
I would recommend C++ Primer Plus by Stephen Prata. A bit dry, but very focused.
You might also want to consider The C++ Standard Library by Nicolai M. Josuttis
If you already know the basics of C++ then I would recommend reading Effective C++ by Scott Meyers. It contains a wealth of tips and guidelines for writing better C++ code. Unlike previous editions, the third edition of the book was revised to take into account that readers were coming from backgrounds other than C coding (Java being one of those).
Chapter 3 of the book deals with Resource Management, including how to avoid memory leaks.
I recommend you to start from the scratch. There are already lot of answers holding good books with it. Follow any one of those, though I myself liked C++ Primer.
And for your question
What would be the best mode of
returning to programming in C++?
IMO there is only one mode. It is Practice, practice, practice.
This is one of the best I've used. Explains how its not C, or "C with Classes".
Effective C++
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Presently, i am learning Java from the book The Art and Science of Java and following Standford's Programming Methodology Course.
I would like to do game programming, but only as a hobby.
I was thinking, would Java be a good choice or is C++ the defacto in game programming.
Since you are learning Java i would recommend that you stick to it.
If you are only developing games for fun, it won't really matter what language you use.
That depends, do you want to learn more about C++? Do you need to know? There's still OpenGL libraries in Java that are available, and the concepts would essentially be the same regardless of what language you work in. If it's just for a hobby then I can't see anything wrong with working in Java. In terms of speed however, lower-level languages are prefered.
Either would be fine. For a hobby, they both have pretty good low-level support for graphics etc, and both also have pretty good higher-level libraries for games (jMonkey engine, SDL, SFML, Ogre and many more).
You could also consider other languages too. Python has SDL bindings called PyGame. C# has the XNA framework which has several books published for it now to help learning the framework. SFML has bindings for C++, C, D, Ruby and I think Python. All of these are then suitable for creating games in. Just pick a language and off you go.
If you ask me, neither Java or C++ are fun languages. Both of them have a number of advantages but if you're doing it for fun and don't have deadlines, I would seek out a language that's more fun. Like Python, or something similar.
If you want to make games you really need a game platform as well as a language, otherwise you will spend all your time solving basic problems like how to draw a sprite to the screen, rather than concentrating on building a fun game.
Great choices for hobby games development are:
Microft's XNA platform with C# language
Adobe's Flash with ActionScript language
Sun's JavaFX platform with JavaFX script language
Unity3D with C# language
Ogre with C++ language
You can write games using both languages but I think you should really try C++. There are far more high-level libraries and game engines written in C++ than Java so it would be easier to find one that suits your needs. Not to mention that a lot of older games have been open sourced and you can freely download them and study the code. You can guess what language they're using ;)
Also you'll find a lot more tutorials and books that teach game programming using C/C++.
No matter what you choose in the end, have fun writing your games :)
If you go with Java, I recommend Computer Graphics for Java Programmers, by Leen Ammeraal.
If you were developing commercial games you would be using libraries rather than implementing these algorithms yourself, but it's easier once you know the fundamentals, which you can learn from a book like this one.
I once wrote a software renderer for a DOOM clone in Java, and having this book for reference helped a lot.
C++ is THE defacto language not only for game development but for pretty much everything else, including the browser you are using along with the OS it runs on.
So if you are considering ever getting serious with programming C/C++ should be top at your list.
As for speed C++ IS generally fast than Java.
Why generally?Well, the truth is that C++ is faster than Java, is faster than pretty much everything else actually, but sometimes C++ code can be poorly written and Java may prevent beginners to make some mistakes resulting in many of the claims that Java is as fast as C++, there are even claims that Python/Psyco are as fast as C++ and faster than Java.
Keep in mind that no program written for a framework (Java, .NET, VB, etc) will ever run faster than a program that runs on a lower level (direct on the OS or even the hardware) like C/C++, ASM, Pascal and so on.
Take a look at this:
Poorly written C++ half the speed of Java, properly written is much faster
At the end of the day you should go with the language that you feel more comfortable with, remember that python is enterprise ready, commercial, stable, great for beginners, awesome to use on "Web 2.0" projects not to mention that is a lot of fun too.
Java - I'd recommend sticking to one and getting good at it. The ideas remain the same, and as you learn more about a single language, you'll begin to learn about the drawbacks and advantages that are prevalent in many of the programming methodologies and languages today.
Even if you never intend to get into professional game development there is one big advantage to C++, which is that you have a lot more resources available. There are more books, more tutorials online, more open source examples to look at and more people who will be able to answer your questions on sites like gamedev.net.
I have developed a couple of small games in both C++ and Java and I would select C++ everytime. It gives you the low level control which you just dont get with java. But games development is a whole different beast. So if you are looking to learn games developement start in something you are comofrtable with
If you think you may one day want to work in the industry, you should learn C++. C++ is used to make pretty much all commercial games that run on PC/xbox/ps3. I assume wii is the same but don't know 100%, I never worked on wii.
The games studio I used to work at (before it got shut down) used C++ for the game (small parts used C and assembler) and was starting to use C# for tools.
If it will only ever be a hobby, then it doesn't really matter what language you use.
I would suggest to try Haaf's Game Engine for C. It is very very simple 2D engine with good documentation, tutorials and examples, runs on Windows 98 and above and it is ABSOLUTELY free even for commercial usage!
If you're completely new to game development, it's right for you IMHO.
Only a hobby? If you're using Java then Java. But first, what are you programming, 2-D or 3-D games? Java does both, and it's my game programing language, but I'm doing only 2-D programs. C++ is the defacto standard for serious game programming, especially commercial games.
Java has a great IDE called Eclipse, which, to me, is worth doing Java all by itself...Eclipse rocks! And it's free.
C# - no. Way too Microsoft dependent.
Btw, Java will work as an applet and as an application if you plan it well, the application runnable on all three platforms...
So, think about it. Low investment, high quality tools, cross-platform. If you decide to get into C++, then that's okay too. At least you will have wet your toes for free...
;-)
Language defines target platform and public. Both Java and C++ have advantages and disadvantages. You will use same architectures and algorithms on any platform. If you know how to write a game in C++ it takes a little to write game in java (2 weeks for me http://madeinsoviets.net/).
Start learning game programming with C++ and some easy game engine (Ogre3D, irrlight) - much more information and tutorials.
Old topic but since people still read this i want to add my 2c since its unique
to this post.
Stick with java, its a great way to make games over c++ if your going to do it as a hobby
and by yourself for these 2 reasons.
10x less coding for the same results (albeit it runs about 5x
slower)
Android games, even mediocre ones will sell (a buck each) on the
marketplace. if you sell even one your going to feel huge pride!
(also java doesnt slow down over C++ on android because its JVM is
unique and runs against the API directly accessing hardware, which
is fantastic!)
If you are just doing it as a hobby, it probably doesn't matter. Just use whatever you are most comfortable so you can get into the swing of game programming. Once you get better, you might like to figure out what is the "best" language.
I would definitely suggest C++ if your intention is general game programming. Of course, if you want to develop for a mobile platform such as Nokia and Ericsson then Java might be a good idea.
But if it is for general desktop gaming then definitely C++. If you want to deploy games over the net then flash might also be a good idea.
If you're planning to enter the industry (or maybe a day start to sell your game yourself), then you have to learn C++.
Java or C# are good choice to get to the point of creating game without worrying much about the machine (memory and speed). That's recommended for beginner, but I would personally start directly with C++.
If you're looking into game programming then C++ is the way to go. Sure Java will be good for certain games, but C++ is so much faster.
I've coded in Java before, and then started coding in C++. The time I've spent coding in C++ made me understand certain things that were heavily simplified in Java.
Depending on how much experience you have programming, I'd suggest to learn the basics of Java and then move on to C++.
If you start with Java, I recommend this book Physics for Game Programmers
In general, C++ is for real games.
Java has always been slow for me, whatever platform or program I use.
C# is better than Java, but not as good as C++.
Yes, there are exceptions, but the fact that they are so notable rather proves that C++ is just the way to go unless you really know what you're doing.
I am ActionScript 3/Flex programmer, it is the first language I learned.
I want to learn either Java or C++.
Would one of these be easier to learn based on my current knowledge?
It really depends what you want to do. C++ is more powerful and fast. But Java has a smaller learning curve.
I'd say learn C++, only because it will require you to gain a better understanding of how computers work under the hood. It will also help position you to learn Java, C#, or any other language down the road.
Java seems more likely to be directly relatable to your work in AS3; C++ is better for giving you a grounding in a different technology (pointer-style OO rather than object-style. C++ may feel eerily similar yet different).
If you are doing C-ish C++, the pointer language learning process can be very informative as to how OS-level calls are written...
The places where you will reach for one tool or the other are very different, and the use you have for the tool may be more important in deciding than their relative merits as languages - employability IS a use for a tool, after all.
Well, AS3 more closely resembles JavaScript - they both follow the ECMAScript specification.
But to answer your question, I would say learning Java will be more beneficial and easier for you. Java supports Interfaces, and single inheritance, like Flex, whereas C++ supports multiple inheritance and lacks a formal notion of Interfaces. Java and Flex both manage memory for you, whereas C++ forces you to manage your own memory. Both Java and Flex have large helper libraries out of the box, and both have native String types, whereas C++ forces you to find a library to use and doesn't support native String types.
This may be my own bias, but it also seems more likely that you'll find a job that is looking for a Flex/Java developer, rather than a Flex/C++ developer. Java and Flex seem to work well together, with Flex as a front end and Java as a middle and back end.
I would say Java is more similar to AS3 than C++. You will find lots of familiar metaphors and mechanisms.
C++ on the other hand, will require more effort to learn. It is closer to the machine and demands an undertanding of lower level mechanisms. For instance, there is no garbage collection so you have to manage your memory resources yourself.
Which is better to know depends on what you plan to do with the language. C++ is good at performance critical applications (games, all kinds of real time simulations etc.). Java makes it easier and safer to build things, but at the cost of performance.
hope this helps
regards
C++ is, generally, harder to learn than Java. You will find this true pretty much no matter what your previous experience. Therefore, if you want to learn the easier, learn Java.
(This is partly a matter of design philosophy. C++ was designed to be mostly upward compatible from C, at least the C at the time C++ was being designed. It was also designed
to be useful and permissive, with ease of learning being secondary. Java was designed partly as a reaction to C++, as a generally safer and easier language. C++ is more expressive than Java, but this comes at a price: it's harder to learn C++, and easier to screw up with it.)
That being said, you never said why you wanted to learn another language. You might well be better off learning C++, even though it is more difficult.
Whatever you'll finally decide to learn, do yourself a favor and read either Thinking in Java or Thinking in C++.
Both books are available - for free! - at Bruce Eckels website. They are very, very good.
C++ is more complex than Java so I'd suggest to take a look at Java, first.
However, this isn't meant as C++ bashing. Both are great language, it just depends on what you'd like to do in the end.
I would go with Java. It will be easier to learn and, given your background, I'm guessing you do more web/internet work in which case you'll probably find more ways to apply the Java knowledge then you would C++.
I think you would find Java more similar.
Learning C++ will likely require you to learn concepts that you could avoid with other high level languages (such Java and AS3) e.g. manual memory management, pointers, non forward looking compiler, multiple inheritance, etc.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I've been writing Java professionally for the last 5 years. Recently, I've had to dig into JNI a bit to call some Windows specific functions.
This experience has highlighted my poor command of the C (or C++ for that matter) language. My only introduction to C was a brief "dummies" book that I read in high school 11 years ago.
I know that both languages have advanced in that time frame, especially C++ and the standard library.
Would it be appropriate for me to learn C or C++? Which books would be best?
Do folks also have any recommendations for Windows programming as well? I can read through MSDN well enough to figure out certain API calls but I have a feeling I'm missing things in regards to the "big picture".
Thanks
Good question. On the surface, it'd be obvious to recommend C++, because "it's object oriented like Java". Only problem is, it's not really true.. C++ allows OOP, yes, but it's just one of several paradigms that C++ supports. Treating C++ like a OOP language (and especially, treating it like Java) will only lead to frustration.
The problem is that Java and C++ don't actually have much in common. Java programmers often believe that Java was inspired by C++, but that's only true if by C++ you mean the very earliest versions of C++, which might more appropriately be called "C with classes".
Since then, C++ has transformed completely into its own language with its own way of doing things. It has probably changed far more since then than Java has. A Java programmer back then would still be able to make sense of today's Java code. Not so for C++. So I'd argue that C is actually closer to Java than "modern C++" is. C is what you get if you take Java and strip away the GC and the concept of classes and a few other abstractions. To arrive at C++, you have to add a similar number of features to our hypothetical stripped-down Java as well.
Further, C++ is a remarkably complicated language, and learning it well takes ages. And if you don't learn it well, you're going to shoot yourself in the foot over and over again.
Finally, it depends on your objectives.
C++ is a much more modern language than C, and once you learn it, very expressive and powerful and, surprisingly, it can even be very elegant and concise. But the learning curve is nasty. So for native programming in the long term, I'd recommend C++ over C.
But if your goal is primarily to interface with the Win32 API (or other native API's for that matter), you won't need C++. Win32 and most other API's are written in C, not C++, and you most likely won't need very complex code to interface between that and Java in any case.
About learning Win32, you're right, all the details you need are on MSDN. If you want the big picture, Petzold is the book on the subject.
I guess it depends on your objectives.
If you want to get closer to the machine, then C.
If you want to supplement you knowledge of a OO Java-like layer above C, then C++.
Accelerated C++ (sanitised Amazon link) is an awesome book to learn C++ from the point of view of C++ and not just C with other bits tacked on,
And K'n'R C (sanitised Amazon link) is still the way to go for learning C IMHO!
BTW For C++ follow up with the wisdom of Scott Meyers in the Effective C++ books! And his Effective STL book as well.
HTH
cheers,
Rob
Learn enough C++ to use it as "a better C". You don't have to try to map all of it onto your understanding of Java. All you want is to be able to use C++ objects as abstract data types, new and delete, etc. If STL comes along for the ride, so much the better.
The real question is: Why do you think that JNI is such an absolute necessity? The Windows calls will ruin any thought of keeping your app portable. I'm sitting next to a guy who's having to dig into a Java app that uses JNI. It randomly brings down a server with a SEG FAULT. His hypothesis is that the heap fills up, a JNI call is made to a routine that calls malloc to allocate space on the heap. It's not available, the routine doesn't check the returned pointer for null, deallocates it, and down comes the server. He's still trying to reproduce the error locally, because it requires precise timing to call the JJNI method just before the GC starts up.
100% sure they're required? Just asking....
If you have a good understanding of Java, I'd recommend that start with C, if you start directly with C++ there're a lot of differences between it and Java, and you probably will dislike it.
If you are serious about learning both languages I'd recommend "The C++ Programming Language" by Bjarne Stroustrup, and "The C Programming Language" by Dennis Ritchie.
I think that C++ would be much easier for you to become proficient in than C.
If you've been using Java, you'd have a hard time doing away with conveniences like classes, exceptions, a form of references, dynamic binding, etc. and of course, decent libraries.
However, you should learn C first to make sure you really understand what's under the hood and get to experience pointers and their use and the feeling of working "with no protective gear".
Once you master that, learn about the inheritance mechanisms in C++ and how it's different from Java (e.g., multiple inheritance).
This really depends on your strengths and weaknesses. If you really like design patterns, then I'd suggest using C++, but if you just have to implement a couple simple methods in JNI, then I would recommend C. Learning C before C++ should give you a better understanding of memory management without having to worry about some of the complexities of C++ (constructor call order, destructors, and other differences between C++ and Java).
I would suggest "The C Programming Language" by Kernighan and Ritchie as the definitive manual for learning C. http://www.amazon.com/Programming-Language-Dennis-M-Richie/dp/0876925964
If you're on a *nix system, there's ample documentation in the manpages for different functions. For example,
bash$ man malloc
If you want an excellent resource for C, "The C Programming Language" by Dennis Ritchie is the book to get.
If your intent is to continue writing JNI code then I'd definitely recommend C++.
In particular, the JNI interface requires you to acquire (and subsequently release) references to Java objects. Using C++ auto variables you can get these references using 'RAII' (Resource Allocation is Initialisation) techniques which makes memory management far simpler.
100% sure they're required? Just
asking....
Unfortunately, yes.
Thanks everyone for your answers.
To answer some of the follow up questions, I'm not looking for a career change to C or C++. I'd just like to learn the fundamentals so I don't feel like I'm flying blind when I do need to write bits and pieces.
In particular, the JNI interface
requires you to acquire (and
subsequently release) references to
Java objects. Using C++ auto variables
you can get these references using
'RAII' (Resource Allocation is
Initialisation) techniques which makes
memory management far simpler.
Thanks, that is helpful. One of the areas that stoked the growing concern in my stomach was dealing with manually managing the memory associated with the JNI objects
If your "main goal" here is to do windows programming, I'd recommend C# over C or C++. However I believe every programmer on Earth, and in Lower orbit, SHOULD know C. Not knowing C++ is acceptable, although you might not get invited to a few parties :) But C is something of a rite of passage, between Applications (high-level) programmer and Library (low-level) programmer.
I've had little exp. with java and since now i've worked with c++. what makes this one more special and preferred?
Moreover I would like to know about the use of System.in classes and parseInt classes.
Java is vastly easier to work with, especially when developing large programs.
Debugging: Java generates nice Stacktraces
Stability: You can catch every exception
Development Speed: you need no linker (which can take many minutes in C++); with a modern IDE (e.g. eclipse) you can edit code in-place while the program is running
Garbage Collection and run-time type safety eliminate whole classes of errors
really good free (as in beer) IDEs
In theory (and sometimes in reality) Java programs also run on multiple platforms, "write once - debug, er, run everywhere" type of thing. That makes it very useful for a variety of projects.
In my personal experience, while learning Java shortly after being introduced to C++, Java seemed simpler and easier to learn and understand, hence more productive, as was said before. While program structure and syntax is very similar, there is no need to worry about pointers and other potentially dangerous language features.
This is really very broad and I think these are really 2 or 3 different questions. I'll address the first one very briefly. Java utilizes garbage collection, or autmatic memory management. That is, arguably, the biggest difference between it from a language like C++. There are clearly some potential for increase in productivity in that you don't have to worry as much about memory, although in reality you do need to pay attention to your references. Perhaps you could refine your question a bit.
Java works in browsers! (Milpa for example). You can say Flash too, but with Java you can leverage the numerous classes coming with it (another advantage over C++, even if both languages has a good set of free libraries on the Net) and your knowledge of the language.
As said, Java is supported on many platforms with minimal adjustments, with a fast, efficient VM, from big servers to mobile phones.
OO support is arguably better designed, avoiding mistakes done in C++. Somehow, C# is to Java what Java is to C++ ^_^ (I won't argue on this, I don't know C# enough actually, it is just an historical point).
In the same spirit, Java is slightly more abstract, avoiding pointers, manual memory management and some other low level stuff.
That doesn't mean than one is better than the other, STL helps C++ for some of the issues above, etc.
I am not sure how to answer the last sentence, these are object and method respectively, not classes.
I never used System.in yet, I suppose it is usable if you feed the Java program with < or | on the command line. And parseInt is a static method of Integer class.
The language features have already been mentioned (GC, reflection etc.). But there is another major difference: Libraries. I know there is the STL and Boost and all kinds of libraries out there, but they are not all of a piece, they all feel different. Often you are forced to use all kinds of C-APIs (e.g. threading or sockets, just to mention two things). All the C++ evangelists will now jump in and tell about some kind of cool OO-socket or OO-threading library, but they are not part of the STL. They should be. Its almost 2009 and everything is networked and multithreaded. This ought to be part of the standard library.
Why is it bad to use those C-APIs? Because it is hard to use them in an object oriented programm. Try using Win32's CreateThread() with the listener-pattern (C#-users: read "delegates").
For a "rich client application", where performance is not a big deal, I would always use Java or C#. If I need raw speed (think signal processing or embedded applications), I would rather use C instead of C++.
BTW: I have used all four languages (C, C++, Java, C#) for a long time.
If you like to program really the object oriented way, then you need to go from C++ to Java. One of the problems with C++ is that most programmers actually use it as C and don't exploit all its OO features. Java is here stricter.
With C++ you're programming "on the metal", whereas with Java you're programming towards a virtual machine. The Java software stack all the way down to the VM is constructed to give a highly abstracted programming experience. This is most clearly apparent in the use of datatypes "that just are" (i.e. the programmers need no understanding of how they translate into memory areas), garbage collection "that just works" (the programmers don't have to deal with allocation and deallocation issues) and the ubiquity of exceptions for error handling and propagation. Pointers are not part of Java, the system takes care of where and how things are allocated.
From this, you might see that the design philosophy of Java is very different from C++: Java tries to enforce that the programmer should stick to certain ways of working which are considered to be safe and to make programming easier. Some people hate this aspect of Java, other people love it.
It really depends on what you're trying to do.
For a lot of higher level functionality where optimal performance may not matter, Java is easier and more reliable to use. For example, garbage collection, array checking, etc. It's also sandboxed, of course.
For me, another major benefit of Java is the use of reflection and of run time class loading. I write a lot of plugins within pluggable architectures, and can ensure I can add more new classes to a running program on any platform. Last time I tried to do that in C++, I had to mess with DLLs and COM.