|
|
|
|
|
by spacemanaki
4726 days ago
|
|
Because selling C++ programmers on Java was hard enough ;) The full discussion that quote is from is a very interesting read: http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/m... Guy Steele suggests that even though some of the people working on Java at the time might have been ok with closures, it was a hard sell when programmers used to manual memory management in C++ were worried about whether things were allocated on the stack or the heap and how much control they had over them. Thus you get the awkwardness that is anonymous inner classes in Java, which are effectively closures, but by another name and papered over with boilerplate. "Actually, the prototype implementation *did* allow non-final
variables to be referenced from within inner classes. There was
an outcry from *users*, complaining that they did not want this!
The reason was interesting: in order to support such variables,
it was necessary to heap-allocate them, and (at that time, at least)
the average Java programmer was still pretty skittish about heap
allocation and garbage collection and all that. They disapproved
of the language performing heap allocation "under the table" when
there was no occurrence of the "new" keyword in sight."
http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/m...Reading through this thread is delightful, I developed quite a lot of respect for Mr Steele. |
|