4 ms·
Conveniently ignoring the fact that Java, by default, includes lots and lots of unnecessarily verbose APIs, and in many cases you're stuck using them - then yes
by kevingadd 17y ago
Conveniently ignoring the fact that Java, by default, includes lots and lots of unnecessarily verbose APIs, and in many cases you're stuck using them - then yes, verbosity is not Java's fault.
- _delirium 17y agoYeah, a more accurate title could have been: Java's verbosity is due to its API, not the underlying language. It's still somewhat interesting to me to decouple the two, though. There are some things that are verbose and cumbersome in Java due to the way the language fundamentally works: for example, no anonymous functions means that if you want to pass a simple one-time-use function to sort, you have to create a whole new file with your sort functor. But the examples in this blog post could've been fixed by just having designed the API differently, or even had the same underlying API but added a set of convenience wrappers for the common cases.
- pvg 17y agoyou have to create a whole new file with your sort functor. You don't. You can use an inner class. An anonymous one, if you like. It's more verbose than your typical lambda expression but it's not 'a whole new file' by any stretch.
- _delirium 17y agoAh right, I'm not sure why that skipped my mind; I've even done that before. I suppose that adds to the general view of the linked post that Java-the-language isn't actually inherently that verbose, but the JVM APIs are.
- wolfgke 17y ago> for example, no anonymous functions means that if you want to pass a simple one-time-use function to sort, you have to create a whole new file with your sort functor. No you don't have to. Simply create an anonymous class deriving from your sort functor interface. With anonymous functions it would still be shorter, I have to admit. But it is less cumbersome than the way you suggest.
- derefr 17y agoThose aren't specifically Java APIs, though, they're JVM APIs—Scala and Clojure expose them as well. Are Scala and Clojure verbose? If not, why not? And whatever your response to that, can that same response be retroactively applied to Java, now that we know how to do it?
- pvg 17y agoIn many cases, they are the Java APIs, there really aren't 'JVM APIs'. Java the language comes with a standard set of APIs, if they're not there you can't call it 'Java'. If you were writing a nontrivial UI in Swing in Clojure or Scala, it will likely be fairly verbose.