Does Java Make You Less Productive Than Dynamic Languages?
Join the DZone community and get the full member experience.
Join For FreeI still hear from many people that dynamic languages make them more
productive, but my experience is exactly the opposite: I used to prefer
Python to Java. But then along came Eclipse with its refactoring and
code browsing and afterwards, I could not go back to simpler editors.
Many of the advanced Eclipse features are possible precisely because
Java is not dynamic. But in many ways, Python feels more polished than
Java. The irony is that this has nothing to do with Python being
dynamic. All of the following things could be easily added to Java.
Standard library.
The good news is that Java has libraries for
almost anything you can imagine. The bad news is that dynamic languages
tend to come with much more useful stuff built in:
- URL-decoding
- JSON encoding/decoding
- UU-encoding
- Joining strings
- Command line argument parsing
- CSV file parsing
- Complete HTTP client implementation (multipart POST, cookies, ...)
- Iterators: for loops over iterators, combinations (filter, append, etc.), conversion to collections
- Collection literals: Java 8 will have collection literals, so we will have to wait a while. In the meantime, Arrays.asList() is good enough for lists and a chainable put() (return type = Map) would be good enough for maps.
- Triple-quoted strings: If a string is triple-quoted in Python, it can contain multiple lines of text and single quotes.
- Raw strings: In Python, prefixing a string quote with an 'r' means it is raw and slashes are interpreted as is, and not used for escaping. This is very useful for text that contains backslashes (regular expressions, LaTeX).
- List comprehension: great in Python, easily added to Java, once it has closures.
- Accessing the n-th last element (arrays, strings, lists, ...): In Python, the index -n can be used for this purpose. In Java, you have to resort to mylist.get(mylist.size()-n).
- str() and ref(): Python has two kinds of toString() methods. str() returns a human readable representation, while ref() returns something that can be parsed (i.e. this method serializes to Python source code).
- Keyword arguments, optional arguments: useful, but might be too cumbersome to add to Java.
Most of the other Java warts, I can live with. That Java will have closures sometimes in the future is great, because currently it is difficult to encapsulate a way of iteration, where the operation that is applied to each element can be configured.
From http://2ality.blogspot.com/2010/10/does-java-make-you-less-productive-than.html
Opinions expressed by DZone contributors are their own.
Comments