19.12.15

JDK 8: Real functional programming tooling for the enterprise?

Replacing anonymous inner classes with pure functions in Java 8.

Basically, you can return an anonymous function as a substitute to a single function anonymous inner class.  This allows us to inject behaviour into java applications without having to create stub classes for custom behaviourisms.


This is sort of similar to  Golangs interfaces, which are implicit to the compiler rather than requiring explicit declaration.

Its definitely a nice feature but I think it likely will be abused to the point of making things unreadable.

So why is this exciting? Well, because its finally a functional programming construct that has unambiguous support in all major IDEs.

Makes me wonder: Is this java now a mainstream, enterprise grade, functional programming language?

Not quite: Immutability and state management are still such staples of Java 101 programming that I dont think cramming these features into the API will make it a "real" functional language, just yet.

But I think its the closest thing we have to a functional programming language that will be adopted at massive scale.

In intelliJ or eclipse, a developer can click on the cross hairs above, and see that this interface is implementing a type, click on that type, and read about it.  Awesome language features just get in the way if the dev tooling isn't equally awesome.

I knew about the JDK updates for a while, but didn't realize that the tooling was all up to date and capable of traversing all this stuff so cleanly. 

My IDE is even telling me when I need to kill an anonymous class and replace it with a lambda.

Funny, just 3 years ago I remember feeling like I had to fight my IDE to get it to understand stateless transformations using guava and tuplesForJava and .... Now its the other way around :)

No comments:

Post a Comment