Self-documenting interfaces and having nice tools.
I used to prefer dynamic languages (specifically Python, Common Lisp, and Ruby) over Java for my spare-time coding projects. That's changed recently and I've come to realize it's because of generics and the smart for-loop in Java 5.
Since Generics arrived in Java, my code has a much cleaner feel to it. Imagine a class for generating Atom feeds. Instead of the Python code:
class Feed: [...] def get_entries(): return entriesIn Java, the method signature would tell me everything
interface Feed { Iterable<Entry> getEntries(); }
Now I know immediately that what I will be getting can be shoved through a smart for-loop and the entries worked over like so:
for (Entry e: getEntries()) { doSomething(e); }
I had a good idea that the Python code would return a List (because I can see the return statement) but I'd have to run my tests to be sure it worked. With Java 5, I have a better chance at build self-documenting interfaces. I really like that.
I should probably also admit that IntelliJ IDEA has completely changed how I program in Java. I used to code with the following steps:
- make changes
- compile and wait forever.
- read compiler errors
- fix
- make changes
- look at the sidebar for red
- see red, go directly to the error
- fix
Same amount of steps but because of incremental compilation it's a small fraction of the former time and I never leave my editor.
I'm sure I'll write some gushing blog posts about IDEA and Java 5 in a few weeks. Papa's got a new bag.
(Sorry, that's the last time I'll call myself "Papa")