Live data from Hacker News

Functional Programming with Java

functionaljava.org

1–10 of 30 posts

Re: Functional Programming with Java

#3
post #2

Taken from one of the examples : final HAppend , HCons >>, HCons >>>> one = append(zero); It's here that I miss the repurposed auto keyword of C++ to do some rudimentary type inference.

    final boolean b = a.exists(new F() {  
      public Boolean f(final String s) {  
        return fromString(s).forall(isLowerCase);  
      }  
    });
It's here that I miss lambdas to make functional code at all readable.

Re: Functional Programming with Java

#4
post #2

Taken from one of the examples : final HAppend , HCons >>, HCons >>>> one = append(zero); It's here that I miss the repurposed auto keyword of C++ to do some rudimentary type inference.

Or C#'s var keyword, for that matter. Unfortunately, both will only work for local variables. I suspect this is one of the reasons there aren't any popular persistent data structure libraries around for these languages. At least the .NET/C# type system supports covariance/contravariance for functions ("delegates"). Plus, they managed to build F# on it.

Re: Functional Programming with Java

#5
( http://www.findsoso.com / ) (( http://www.findsoso.com / )

We need your support and trust!!! Dear friends, please temporarily stop your footsteps To our website Walk around A look at Maybe you'll find happiness in your sight shopping heaven and earth You'll find our price is more suitable for you. Welcome to our website ( http://www.findsoso.com / ) Thanks to the support!

( http://www.findsoso.com / ) ( http://www.findsoso.com / ) ( http://www.findsoso.com /

Re: Functional Programming with Java

#6
post #4
post #2

Taken from one of the examples : final HAppend , HCons >>, HCons >>>> one = append(zero); It's here that I miss the repurposed auto keyword of C++ to do some rudimentary type inference.

Or C#'s var keyword, for that matter. Unfortunately, both will only work for local variables. I suspect this is one of the reasons there aren't any popular persistent data structure libraries around for these languages. At least the .NET/C# type system supports covariance/contravariance for functions ("delegates"). Plus, they managed to build F# on it.

F# doesn't in fact make use of {co|contra}variance: it only needed generics. (Although F# used to run on .NET 1.x using its own implementation of generics - Don Syme designed both .NET generics and the F# language.)

For type inference, you just need a sufficiently smart compiler, although it's much more useful if your language knows about generic types.

Re: Functional Programming with Java

#7
post #2

Taken from one of the examples : final HAppend , HCons >>, HCons >>>> one = append(zero); It's here that I miss the repurposed auto keyword of C++ to do some rudimentary type inference.

final boolean b = a.exists(new F () { public Boolean f(final String s) { return fromString(s).forall(isLowerCase); } }); It's here that I miss lambdas to make functional code at all readable.

exactly the example I was going to cite. In Scala this would be

val b = a.exists(str=>str.forall(_.isLowerCase))

or

val b = a.exists(x=>x.toLowerCase() == x)

There's no way I'd start using functional programming in Java if it's this clunky. Just stick with Scala.

Re: Functional Programming with Java

#10
post #4

Earlier quoted context omitted.

Or C#'s var keyword, for that matter. Unfortunately, both will only work for local variables. I suspect this is one of the reasons there aren't any popular persistent data structure libraries around for these languages. At least the .NET/C# type system supports covariance/contravariance for functions ("delegates"). Plus, they managed to build F# on it.

F# doesn't in fact make use of {co|contra}variance: it only needed generics. (Although F# used to run on .NET 1.x using its own implementation of generics - Don Syme designed both .NET generics and the F# language.) For type inference, you just need a sufficiently smart compiler, although it's much more useful if your language knows about generic types.

Thanks for clearing that up (I've yet to try F# in anger). I suppose pre-generics F# did similar type wrangling to Scala's?
Post reply on HN