Friday, 29 November 2013

Unknown

Adavantages And Disadvantages of Java

Advantages(Pros):
  • Easier to learn than c++
  • Easier to read code than c++
  • More rapid and potentially less error-prone development (due to less memory management) than c++.
  • Most cross-platform since it was designed for it and Sun makes JREs and JDKs for most platforms
  • All things are passed by reference except for value types, by default
  • Garbage collector cleaning up objects once they're no longer used, so you don't have to manually track everything yourself
  • Apparently java 6 runs (some?) stuff slightly faster than c++ (test code ported from c++ ran faster despite having to do seemingly wasteful things!)
  • Program is compiled and optimized for the platform it's on, if necessary?
  • Easy to make multiple threads, and you can declare functions synchronized so only one thread can be in them at a time (IIRC)
  • You can use wait() and notifyAll() and notify() to suspend threads to wait for signals and wake them up again.
  • Various free IDEs available on all platforms, such as Eclipse
  • If the program crashes, it should either tell the user where in the code and why, showing a stack trace including line numbers (if debug symbols are enabled or something like that), or it can be dumped to an error log file.
  • Programs can be packaged into jar files with various data files in different jar files and accessed by users using Java WebStart, which will auto-update the program and any other needed jar files to the latest version, only downloading what jar files have changed.
  • Easier/more cross-platform networking than c++.
  • Files are read and written as big-endian on all platforms (which is network byte order) ensuring that communications between java programs and file loading never require byte-order swapping (unless talking to a non-java program or using a file written by one).
Disadvantages(cons):
  • Uses more memory than c++ or c#
  • JNI is terrifying, but if we're being cross-platform we probably won't use it, (except that the 3d engine will?)
  • Garbage collector using CPU cycles and memory - (but barely any, at least CPU time)
  • No unsigned integers
  • No pointers, no ref or out parameters (which replace pointers in c#). To return multiple things from a java function you tend to have to return an object[] holding each thing, or make a class which holds each thing and return an object of that class.
  • Some things were renamed - const is final in java, for example
  • Java does not allow indexers or operators on objects, e.g. if you use resizable lists etc, you have to do list.get(index) instead of list[index], and you can't do someVector + someOtherVector.
  • Java does not let you decide whether a type should be a value or a reference type (determining if it should be pass by value or pass by reference), unlike c#.
  • Jar files used by java webstart have to be signed with a certificate. Code signing certificates cost hundreds of dollars per year, or you can make a self-signed one and use that, which will make Java Webstart pop up a "This certificante can't be verified" dialog when the user tries to run the program. (Alternately, don't use Java Webstart and just distribute jar files directly - which requires users to check for updates themselves.)
  • Requires a JRE to be installed to run the program, which is a several hour download on dialup.
  • Have to use java 5 for generics, 1.4 doesn't have them. Java 6 is newest and a couple years old, but - Apple releases their own java versions for Mac users, and still hasn't released a "stable" java 6 version for its users.

Unknown

About Blog No Baap -

Since 2016 BlogNoBaap has been bringing you the very best in all types of web resources. Posted daily, and delivered straight to your inbox each morning.

Subscribe to this Blog via Email :