Closures for Java and other thoughts on language evolution
The document discusses goals for language changes including simplifying programs, reducing bugs, and adapting to changing requirements like multicore processors and concurrency. It proposes adding closures to Java to help meet these goals by allowing for more concise code, avoiding repetition, and making programming with concurrency easier. Specific examples are given of how closures could help implement common patterns like try-with-resources and iteration in a more readable way while also enabling flexibility for programmers to extend the language.
Closures for Java and other thoughts on language evolution
1. Closures for Java
…and other thoughts on language evolution
Neal Gafter
Google
1680
2. 2
Goals for Language Change
> Simplify programs
– More concise
– Don’t Repeat Yourself (DRY)
– Make reading, writing easier
> Fewer bugs
> Adapt to changing requirements
– Multicore and concurrency
– Enable programmer flexibility (expressiveness)
3. 3
What is a Closure
> A closure is an anonymous function expression
> Like
– Block in Smalltalk, Ruby, Scala
– Lambda in Lisp
– Anonymous function in Javascript
12. 12
Multicore and Concurrency
> Need concurrency to exploit Moore’s Law
> Thread- based concurrency is hard
> Fork- Join concurrency is easier
– Concurrent Loops
13. 13
Multicore and Concurrency
> Need concurrency to exploit Moore’s Law
> Thread- based concurrency is hard
> Fork- Join concurrency is easier
– Concurrent Loops
> But more will be needed in the future
– Actors
– Functional Programming
– Software Transactional Memory
14. 14
Enable Programmer Flexibility
(expressiveness)
> Programmers “grow” a language by adding APIs
> See Guy Steele’s “Growing a Language”
If you give a person a fish, he can eat for a day.
If you teach a person to fish, he can eat his whole life long.
15. 15
Enable Programmer Flexibility
(expressiveness)
> Programmers “grow” a language by adding APIs
> See Guy Steele’s “Growing a Language”
> Support more flexible “language extension” by API
> Reduce the need for future language change
16. 16
There is more to Java (SE) than Java (PL)
> The VM
> Deployment
> Other languages
>…
17. Neal Gafter http:/ / www.javac.info/
Google neal@gafter.com