3 ms·
Part of the reason Java's documentation is so "good" is that it needs to be. If you want to know the length of an array, it's .length (carefully avoiding parent
by DanielStraight 17y ago
Part of the reason Java's documentation is so "good" is that it needs to be. If you want to know the length of an array, it's .length (carefully avoiding parenthesis), for a Vector, it's .size(). For Vector's, there's also .capacity() which is different from size. Then there's setSize() and trimToSize(), one of which affects size (and capacity) and one of which just affects capacity. Then you have ensureCapacity() and isEmpty() which do things you could easily check on your own.
In Python, the way to tell how long anything is is the len() function. There is no concept of capacity because there's no reason to care. If you want to check if a list is empty, you just say "if list_variable". Once you learn those two basic concepts, which apply to the entire Python library, you never need to look at documentation for sizes and capacities of anything again.
Python's slice notation replaces an overloaded add(), elementAt(), firstElement(), get(), insertElementAt(), lastElement(), remove(), removeAllElements(), removeElement(), removeRange(), set(), setElementAt(), and subList(). And it works the same for all list-like objects in Python. Java's copious documentation on those functions (some of which are exact duplicates) is not a good thing. It's a sign of a serious design problem.
- cmars232 17y agoI wish Java would adopt len() and the like. Or perhaps a more general concept like Haskell's type classes.