There’s a lot else to respond to, but this cuts to the heart of the issue - I don’t think Java’s current state effectively enables the removal of the unnecessary. When I look at the pure Java examples that do what Cas wants, my eyes are attracted to everything but the “live” bits of code in there, which to me means they fail at the mission. Screen space is dominated by boilerplate that doesn’t vary from use to use, and the tiny bit of logic that does vary from filtration to filtration is all but obscured. This is true in most real life Java code that I see, in amounts usually proportional to how complex the overall system being designed is.
That’s why characters typed is a useful metric even in the face of fancy IDEs that take care of the typing for you - it’s not that you actually have to type all that stuff, it’s that you have to parse it away when you glance over the code in order to figure out what the real logic is, and as projects grow, development time is dominated by code readability.
IMO, it comes down to this: a filter/map/reduce/fold should always be a one-liner, even if the criteria is only used once, and it’s just not possible to achieve that in Java. I understand that the ability to do this type of thing means some people will abuse it, but that’s what code reviews and standards are for. Reflection can be abused quite readily, but most people would be fired long before they could manage any real damage to a codebase by using it.
Hell, half the time when people abuse reflection it’s just to do things that would be trivial if they had closures anyways…who hasn’t seen the dreaded reflection-simulated-function-pointer anti-pattern showing up here and there in live code?
I’d definitely vote for some sort of reasonable compiler plugin system, particularly one that didn’t involve an external build step (I’m very aware of all the stuff you can do with annotations and bytecode manipulation now, and it’s all a real hassle to use). The nice thing there would be that we’d all have access to the power, but companies or teams that feared the mess that could be made if their worst programmers had access to it could just forbid the specific compiler plugins at the IT level, which is a lot easier than enforcing coding standards.
Scala has almost exactly what you’re talking about, Cas, and it’s not perfect or anything (difficult to write plugins), but it’s a lot easier to use a plugin than it is to integrate a bytecode processor into a Java build (once it’s set up once, it can be used by default whenever necessary): http://www.scala-lang.org/node/140 (…I offer that link with the full acknowledgment that the syntax in that compiler plugin highlights one of the most troublesome aspects of Scala, namely the prevalent operator abuse; luckily that is supported in most IDEs, so you can command+click on <:< to figure out wtf it does…)
Re: IDE integration, the ideal solution there would have been to give the IDE the hooks it needs into the language syntax as part of the plug-in interface. Generally speaking I’d love if languages started to treat IDE integration as a core concern of the language itself rather than a cosmetic step on top, it would very seriously increase the usability of most languages - my language design thoughts have lately centered on this issue almost above all else, as I think it’s quite the failure of most newer languages. IDE issues are the biggest problem with Scala at the moment, otherwise I’d be pushing it a hell of a lot harder than I am already!