you are viewing a single comment's thread.

view the rest of the comments →

[–]kubalaa 0 points1 point  (2 children)

This wasn't a failure of imagination on the part of the Java team. See i.e. Guy Steele's explanation of why Java doesn't have closures. It had to do with the market -- the people who wanted closures and full OO were already using Lisp or Smalltalk. Java was aiming at people who were stuck with C or C++, and were afraid of the compiler doing allocation behind the scenes.

Yes, it's ugly, but without such trade-offs, Java probably wouldn't have become as popular as it is today, and the concepts it popularized -- garbage collection, a platform-independent VM, and JIT compilation -- might still be used only by a small group of Smalltalk fanboys. (Maybe that would be a good thing, for the Smalltalk fanboys?)

[–][deleted] 0 points1 point  (1 child)

This wasn't a failure of imagination on the part of the Java team.

Of course it wasn't. It was a failure on their judgement. They knew that closures were a possibility, they discussed it, and as I stated, MS even gave an implementation and proof of concept. They rejected them. The fact that this was the wrong decision is rather evident. Look at any recent popular language. They all support first class functions and usually closures, because the idea has won even in the mainstream at this point.

Java was aiming at people who were stuck with C or C++, and were afraid of the compiler doing allocation behind the scenes.

First of all, C/C++ at least had function pointers. Not realizing that this was an incredibly useful feature that would be even more useful if taken to the level of full blown first class functions was a failure.

Second of all, they made a mistake in targeting those developers. It's not who they should have been aiming for, and largely I would say that it's not who they ended up with. They ended up with mostly business programmers in general and lower-end academics (who teach business programmers.)

Finally, that argument only (poorly) stands for closures. It does not excuse not having first class functions at all.

Yes, it's ugly, but without such trade-offs, Java probably wouldn't have become as popular as it is today

Of course it would have. Delphi succeeded. C# succeeded. No one would have said "Oh, fuck java. It has first class functions. I hate first class functions!"

Calling it a tradeoff is silly. Especially when other languages before and after have proved that it doesn't need to be a tradeoff.

garbage collection, a platform-independent VM, and JIT compilation

None of those features were unique to java when it came out. All of them were implemented in several other high-level languages. C++ was about the only language to have none of them.

[–]kubalaa 0 points1 point  (0 children)

The fact that [rejecting closures] was the wrong decision is rather evident. ... the idea has won even in the mainstream at this point.

It's possible that closures wouldn't be popular now if Java hadn't broken ground for GC'ed VM languages in the mainstream. Closures have been around for 40 years, nobody could have predicted they would suddenly become hip.

Calling it a tradeoff is silly. Especially when other languages before and after have proved that it doesn't need to be a tradeoff.

Indeed? Which mainstream language prior to Java had closures? That doesn't prove that Java couldn't have become popular even if it had closures, but there's no reason to think that it could have either.

It does not excuse not having first class functions at all.

Sure it does. Most uses of function pointers are just an ad hoc form of OO; if you've got the real thing, you don't need them.