Monday, October 09, 2006

Like watching a puss-filled boil explode in slow motion

Reading this (which is only the latest in a long saga of closure debates on Java sites) makes me glad I don't program in Java anymore. I personally think it is too late to add closures to Java, simply because the existing libraries are not designed for it, but the responses posted in discussions such as these are so comical that I want to see closures added just so that these guys get pissed off.

Come on now enterprise monkeys, make up your mind: are closures simply for newbie "script kiddies" who are not man enough to use a 400$ keyboard macro IDE? Or are they so complex that newbies cannot learn them (nevermind the extremely convoluted anon inner class syntax). Or are they easy to learn but simply unsuitable for serious Enterprise(tm) team development?

This is sort of like watching assembly freaks debate if parameters should be passed in registers or on the stack... or if subroutine calls are any good at all. Those of us in the know have moved on long ago.


Anonymous said...

Are you kidding me... The title speaks of noob "Closures without Complexity"? Wtf! It doesn't get any less complex than closures...

Or maybe I'm as screwed up as you.


Anonymous said...

I'd like to continue spamming your blog. Waiting for some tests to finish.

I've actually been using closures in C++, if you can believe it. Using boost lambda and also creating function objects for simple interfaces.

I've actually had people say, wow, that is a really useful and obvious thing to do.

But these are guys with PhDs so take that with a grain of salt. I'm trying very hard to never introduce anyone to Java, ever.

PS: You're the man.

Reinier Zwitserloot said...

Interesting, isn't it?

It really bugs me. Java is so far still the language I prefer to use, but the community sucks. There are lots of java programmers. There must (ought to?) be a community someplace that groups the saner java afficionados together. The type that realizes that adding the CICE stuff is a good idea, or will at least argue against it using believable reasoning - like, say, that you need to redesign large swaths of the API.

On that topic: I think you can extend the API to cover most bases. For example, take WindowListener. Not currently suited to CICE, because it has multiple method declarations in them, not the required 1 declaration. But, you can of course add a WindowIconifiedListener - an abstract class implementing empty bodies for all of WindowListener's methods, except for the windowIconified method, which is declared, but abstract. This is a legal SAM type you can define using the CICE notation, and it's still also a WindowListener, so you can pass it into the addWindowListener() method.

Of course, sun should consider this. Generics have not been implemented very well outside of java.util. For example, Properties, the language-side variant of an file, also implements Map, so that you can just see it as a mapping between keys and values (that's what a properties file really is, so that works out). Unfortunately, it's a Map<Object, Object> while it should have been a Map<String, String>. D'oh.

Anonymous said...

Pus, the slimy white stuff that oozes from infected areas, is spelled with only one 's'.

Puss is something totally different.

Anonymous said...

Hmmmmm, puss...

Ray Cromwell said...

I love how people dismiss closures without even knowing what they are...

"wha, I assume they're like C++ destructors. Java doesn't need them!"

And still more people dismiss them because they can type an extra 5 lines of boilerplate and achieve pseudo-closures.

The Java community has an inbuilt resistance to anything that reduces verbosity based on the idea that verbosity = readability. I think it started with the whole "operator overloading allows for confusing programs, see C++ abuse" and now anything that allows reduction in syntax tends to find resistance. Java philosophy was pitched against C++'s complex implicit promotion rules, and overloading. Thus, anything that seemed to be be a relaxation of philosophy is seen as a "slippery slope" to turn Java into C++, C++ fulfilling the role of Nazis ala Godwin's Law, since as soon as you can show something is similar to C++, it must be evil and bad.

* "Static imports? sqrt(15) is way less readable than java.util.Math.sqrt(15). How would you possibly know where the sqrt() function is defined!!"

* "Enum? I have typesafe enum pattern. Just saves typing thats all."

* "Varargs? Why do you need them, when with method overloading, you simulate them, and worse case, use use an inline array initializer"

* "Closures? I have anonymous inner classes. I don't see the point of saving a few lines of typing...Besides, I have macros to generate my 10 lines of boilerplate"