Hacker News new | ask | show | jobs
by chvid 2786 days ago
And lambdas were introduced in 8 making nearly all of the author’s issues mute.
4 comments

I'm curious, how much Common Lisp have you written yourself. Because what I'm reading between the lines is that you consider modern Java to be pretty much equal to Common Lisp in power, and that doesn't make much sense from here.

Take lambdas for example, the amount of arbitrary exceptions you have to keep in mind while using them makes it almost not worth the effort. It's still the same old crappy Java; only with shiny, barely working marketing gimmicks duct taped to the side.

*moot

You're right, but to be fair the article is almost 7 years old, and Java has evolved a lot.

That's the thing though... they aren't real lambdas. They're just syntactic sugar for an interface. If you watch the talk by the head of Java right now at the Clojure conference, he talks about how they're essentially trying to tack on low hanging fruit in hacky ways to keep the language up to date. But secretly it's a mess.
What about closures? Also, those lambdas are actually classes that try very hard to look like lambdas, but aren't actually.
What do you mean "aren't actually" ? Anything that behaves according to the rules of a lambda is one — they can certainly be implemented with classes.
There are quite a few complications of Java lambdas and their abstraction bleeds out in several edge cases. This is a result of their class implementation and would not exist if functions had first class support in the language and barcode bytecode (there are complications there too because they didn't want to change anything at the bytecode level for lambdas).

https://dzone.com/articles/java-8-lambas-limitations-closure...

Lambdas in Java aren't really that complicated. If you understand anonymous classes, you understand lambdas.

That article just compares Java's closures with Javascript's closures. The "limitation" is that Java's closures can only access the final variables of the enclosing scope. But the article agrees that this limitation "can be considered negligible" (seriously, read it-- that's the conclusion.)

Also, starting in Java 8, you don't have to explicitly declare things "final" to use them in anonymous classes or lambdas. They just have to be effectively final, meaning they are not mutated.

> But the article agrees that this limitation "can be considered negligible" (seriously, read it-- that's the conclusion.)

Working both in Java and Lisp professionally, it sure as hell isn't negligible. It changes the way you write code. Lambdas in Java are 80% solution. Java 8 really did make this language finally bearable, sometimes pleasant to work with. 80% solutions are good, but the remaining 20% is not "negligible".