Vamsi Emani
Vamsi Emani

Reputation: 10302

Why were block closures excluded in java?

I am a mainstream java programmer but recently, I've been taking interest in smalltalk. I must admit that I am totally blown by the immense power that the language gives to the programmer and I find dynamic typing as a big plus (personally).

I do not want to compare the two languages because I understand that java is a good fit for the enterprise reality that takes away much of the programmer's power for good (like the usage of pointers?) to lessen the scope for committing mistakes. Agreed. But I fail to understand why was the concept of blocks/closures eliminated not included in the language? Because I really find them very useful and I don't see a reason why such powerful a feature cannot be married into java, albeit the fact that it is static typed. Is there any specific reason for this?

Upvotes: 2

Views: 195

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533530

AFAIK, it was not included because Java has based on languages which did not have this feature. Instead Java has alternatives which achieve the same thing but in relatively ugly ways.

Hopefully, it will be included in Java 8 if only to stop people complaining about it. ;)

I don't see a reason why such powerful a feature cannot be married into java

Can you think of a realistic example of something you can do with a closure, you can't do with Java already? The main difference is productivity and readability. While these are very important, its not like it can't be done.

Upvotes: 3

Related Questions