::scr usability, languages and apis

Simon Kinahan scr@thegestalt.org
Mon, 19 Nov 2001 22:42:17 -0000


> On Thu, Nov 15, 2001 at 05:57:18PM -0000, Simon Kinahan wrote:
> > However, I quite like Java. More than Perl, in fact. Is it possible to
have
> > a useful conversation on whether Java is a good language or not ? The
main
> > reason I like it is that it was the first language to bring things lots
of
> > people think are of academic interest - closures, for instance - to a
"blue
> > collar" audience.
>
> This puzzles me slightly. I work in Java every day, and I like the
> language. I think that it often (not always) chooses a good trade-off
> between usefulness and purity.

My only problem with Java - albeit a big one - is the gaping gulf between
the built in types and user defined classes. This is a consequence of
welding a smalltalk like superstructure onto a C-like foundation. You get
problems neither language has on its own. Don't get me wrong - I work in
Java  every day too. I write tools for "Enterprise" Java systems. I think
its the best current general purpose language, and a vast improvement on its
immediate predecessor, but it definitely has problems.

> But it's the bit about closures that I don't understand. The only Java
> feature that I can think of which could be described as closures is
> the way that inner classes can refer to final variables of the outer
> class. That is a closure of sorts, but it's *very* limited. You can't
> close over variables which are actually *variable*.

Well, they are closures, in the way they work internally, albeit closures
with multiple entry points. They can actually modify the state of the
enclosing instance, but not temporary variables or parameters of the
enclosing method. They're real closures because local variables in Java can
be "blank final": that is they are assigned only once, like values in
functional languages. I don't miss the ability to close over mutable local
variables. It allows many truly vile things, and few good ones, at the
expense of the VM writer's sanity. I did some of them back when I used
Smalltalk. Functional languages use closures more than any others, and they
(naturally) don't have any mutable references.

As to Perl: actually Perl (and Python) have done a lot to raise the general
level of programming. However, since Perl is a "do it your way" language,
people who don't understand closures (for instance) are not forced to learn
about them.

Simon