News for hackers. Stuff that matters.
Re:Yahoo Mail moving to React by kyllo on Wednesday November 26, 2014 @10:52AM (#8662840)
First-class functions and closures are nice if you're coming from Java.
Re:Yahoo Mail moving to React by empthought on Wednesday November 26, 2014 @10:55AM (#8662860)
Those are in Java now. Always have been, really, with a lot of boilerplate.
Re:Yahoo Mail moving to React by kyllo on Wednesday November 26, 2014 @01:36PM (#8663854)
No, they aren't. The only thing "first-class" in Java is classes. They added lambda expressions in Java 8 but they still must be defined inside of a class method. It is still illegal to define a function outside of a class in Java. And Java methods are still not lexical closures; there are some tricks you can do to sort-of emulate this but closures are not a language feature.
Re:Yahoo Mail moving to React by empthought on Monday December 01, 2014 @12:08AM (#8679605)
> The only thing "first-class" in Java is classes.

And lo and behold, they have decided that an anonymous class with only one method is equivalent to an anonymous function object, and given us syntactic sugar to invoke it without the class declaration boilerplate.

You're essentially doing the same as complaining that conditionals aren't a Smalltalk language feature.

Re:Yahoo Mail moving to React by kyllo on Monday December 01, 2014 @01:25AM (#8679789)
An anonymous inner class with only one method. The "inner" is important. It still has to exist inside of an explicitly declared class. Also, a variable holding a reference to a lambda function cannot be called as a function (no function pointers).

Contrast with JavaScript, where functions are first-class, can be declared at top level, can be passed as arguments to and returned by other functions, can be called by dereferencing a variable, can be nested, can be partially applied, etc.

The minimal syntactic sugar for anonymous inner classes added in Java 8 doesn't even begin to approach the power of the function support in languages like JavaScript. Language-level support for this stuff matters.

Re:Yahoo Mail moving to React by empthought on Monday December 01, 2014 @09:22AM (#8681053)
They have exactly the same "power," they're just spelled differently. "func()" doesn't let you do anything that you can't do with "callable.call()". It's trivial to do everything that isn't syntactic sugar (for example, partial application, passing as arguments for abstraction) that you mention in Java, if a bit tedious (and often pointless, since the standard APIs generally weren't designed with that in mind.) _A Little Java, A Few Patterns_ came out in 1998; give it a read.
Re:Yahoo Mail moving to React by kyllo on Tuesday December 02, 2014 @01:17AM (#8685965)
The fact you put the word "power" in scare quotes indicates to me that you don't understand what it means in this context. Here, have a pg essay: http://www.paulgraham.com/power.html
Re:Yahoo Mail moving to React by Dewie on Wednesday November 26, 2014 @02:54PM (#8664278)
> Always have been, really, with a lot of boilerplate.

Many uses of first-class functions is for reducing boilerplate to begin with.

Re:Yahoo Mail moving to React by woah on Wednesday November 26, 2014 @12:57PM (#8663605)
But really, anything in Java requires a lot of boilerplate.