Whats wrong with arrays in Java?
An array is a low-level idea exposed in a high-level language. In a low-level language such as C, an array is just a blob of memory. Accessing elements is very fast, because you’re just multiplying the size of an element (typically a power of two) by the index and adding the result to the start. By contrast, the memory model in Java is intended to prevent unsafe accesses, so no pointer arithmetic is used. Activities that do pointer arithmetic in the background are subjected to additional tests. Any lookup of an array value requires a range check. A naïve Java compiler inserts a test around each array access to check whether the index is in the permitted range. A modern compiler or VM does a lot of static analysis to try to remove these checks. How is this problem caused by choosing the wrong abstraction? A few years ago, a group at IBM tried modifying Java to require arrays to be accessed via index sets. The only operations you could perform on index sets were those from set theory; th
- I tried running a Java program (or another program that uses a just-in-time compiler) under Valgrind but something went wrong. Does Valgrind handle such programs?
- Ive tried to convert my Java application but the translator reports "Cannot find class: java.lang.Object". Whats wrong?
- Can I use Java data types such as Strings to represent file names instead of character arrays?