Originally posted by me262
View Post
Java runs in a Java VM which includes useful features like garbage collection. So, in theory, Java doesn't memory leak.
Java is popular for several reasons:
1) No memory management. This makes it "easier" to teach.
2) No pointers. See the corollary of 1)
3) "Platform Independant" so long as the target platform has a compliant (and compatable!) JVM.
4) As a corollary of 1) and 2) everywhere teaches it.
5) As a corollary of 4) every new CS grad knows it.
C++ can be anything to anybody. With operator overloading, templates, and some of the other advanced features of the language, it can get very very powerful (and very very very complex!).
Java is designed to prevent you shooting yourself in the foot, C++ allows for the possibility that shooting yourself in the foot serves some purpose. As a simple demo of this principle, try implementing the classic swap() function in both languages. (Having done that, work out how to do the same in Python, it's hilariously funny.)
Leave a comment: