Java vs C++

I’m quite sure that java interprets it then it compiles it…

It’s true that the risk of memory leaks in C/C++ is greater than Javas because you have do allocate the memory and deallocate it, but it really depends on the programmers skill. He/She can deallocate the memory as soon as it is not needed, making the memory have more room to do stuff while java does not, not as soon as you might want it to be. Making C/C++ have more efficient memory handling. But as I said earlier, it really depends on the programmer.

But reading all of this, I am half-convinced that it is better to learn Java. Maybe I’ll stay with java, Ill just make a game and see if i like it, otherwise ill go back trying to learn the complexities of C++.

Nice theory, but it doesn’t really fly. I don’t care how many years someone programs with C/C++ they are still going to have memory leaks because of the fact that they have to allocate memory manually. And this has nothing to do with garbage collection, which you seem to infer.

I recently wrote a C library of generic collections for a short course I was giving at a local institute. I have written countless linked lists and dynamic queues in the past, but even so I still found through testing that there was a leak in my circular linked list. This is one of the many reasons that I prefer Java in most cases.

[quote]It’s true that the risk of memory leaks in C/C++ is greater than Javas because you have do allocate the memory and deallocate it, but it really depends on the programmers skill. He/She can deallocate the memory as soon as it is not needed, making the memory have more room to do stuff while java does not, not as soon as you might want it to be. Making C/C++ have more efficient memory handling. But as I said earlier, it really depends on the programmer.
[/quote]

[quote]I’m quite sure that java interprets it then it compiles it…
[/quote]
A C/C++ compiler also interprets and then compiles it. :wink:

aldacron is absolutely right. Look at those commercial PC games, software. They do always release new patches to fix memory leaks, do you think those software developers high school students? or lack of experience? No matter how good you are, even the C inventor Dennis Ritchie, memory leak is just unavoidable. The way you can say is that experiencers know how to find and fix the memory leaks FASTER than non-experiencers.

For Java, I don’t care if it’s interpretted first then compiles or what, as long as the program runs well and is stable, with 2 to 5 times shorter development time than C/C++, what do you expect more?

Actually, Java is compiled first, then interpretted. Code is compiled into bytecode, and bytecode is interpretted into machine language.

:wink:

These days we just have object leaks instead which are every bit as irritating as memory leaks but fortunately a lot easier to find thanks to the debugging interface in the JVM.

Cas :slight_smile:

If by interpretted you mean compiled, then yes.

I find it interesting that in the year 2003 the whole Java vs C/C++, particulary in regards to memory, debate is still going on. Two different approaches. Each with their own advantages and disadvantages. Different situations lend themselves to different approaches. Move on people :slight_smile:

Agreed! click

-SG