Since we have a Java class at our school, Java is what we use.
Between Java and C++, most of the differences are noted by the always awesome WPILib people: Brad Miller, Ken Streeter, Beth Finn, Jerry Morrison, Dan Jones, Ryan O’Meara, Derek White, Stephanie Hoag, and Alex Henning.
Here are their words verbatim from page 10 of the PDF:
Quote:
Java- Objects must be allocated manually, but they are freed automatically when no references remain. (Garbage Collection)
- References to objects instead of pointers. All objects must be allocated with the new operator and are referenced using the dot (.) operator. (e.g. gyro.getAngle() )
- Header files are not necessary and references are automatically resolved as the program is built.
- Only single inheritance is supported, but interfaces are added to Java to get most of the benefits that multiple inheritance provides.
- Checks for array subscripts out of bounds, uninitialized references to objects and other runtime errors that might occur in program development.
- Complies to byte code for a virtual machine, and must be interpreted. (Slightly less performance, but mostly unnoticeable)
C++- Memory allocated and freed manually. (Subject to memory leaks)
- Pointers, references, and local instances of objects.
- Header files and preprocessor used for including declarations in necessary parts of the program.
- Implements multiple inheritance where a class can be derived from several other classes, combining the behavior of all the base classes.
- Does not natively check for many common runtime errors.
- Highest performance on the platform, because it compiles directly to machine code for the PowerPC processor in the cRIO.
|