final int[] nums = new int[4];
in OS++
final nums = allocate_memory(4*1);
x = nums[3];
numds[3] = 4;
OS++
x = Mem[nums + 3];
Mem[nums + 3] = 4;
- Java
- memory allocation is automatic
- freeing memory is automatic (by the garbage collector)
- bounds of arrays are checked
- In C or C++
- allocations is explicit (similar to OS++ and Mem[-])
- freeing memory is explicit (similar to OS++ and Mem[-])
- bounds are not checked
Java is slower and safe, C (or C++) is fast and dangerous.