News for hackers. Stuff that matters.
Re:Why isn't Java used for modern web application development? by joshAg on Sunday June 10, 2012 @05:49AM (#4090649)
why does a language designed around an OOP perspective need a lambda (which comes from a functional programming perspective)?
Re:Why isn't Java used for modern web application development? by masklinn on Sunday June 10, 2012 @06:00AM (#4090668)
> why does a language designed around an OOP perspective need a lambda

Because only through lambdas can you actually do OOP: a core of OOP is to tell objects to do things. That you can do with lambdas, through customizing "the thing". Without lambdas, you are left with the requirement to painfully and painstakingly get bits and pieces in or out of objects in order to do the thing yourself, ending up with a horrendously procedural language with a smattering of objects added on top.

It's no secret — or mistake — that blocks are first-class components (and literals[0]) in the ur-OO language: http://en.wikipedia.org/wiki/Smalltalk#Code_blocks (as well as http://en.wikipedia.org/wiki/Self_(programming_language) )

[0] and really one of the few pieces of syntax

Re:Why isn't Java used for modern web application development? by fleitz on Sunday June 10, 2012 @06:04AM (#4090679)
Because lambdas offload programmer work to compilers.

Think of a piece of code like:

  array = [1..10]
  evenNumbers = array.where(x => !(x % 2))
Now think of how to write that code not using lambdas.

In Java where people seem to like typing unnecessary stuff it would make sense to not have lambdas as then you can type extra stuff. Also lambdas would reduce KLOCs thus making teams using java with lambdas less productive.

This is similar to the reduced productivity seen by teams using scala or clojure on the JVM.

Also, OOP has nothing to do with procedural or functional languages, it's completely orthogonal.

Re:Why isn't Java used for modern web application development? by fizx on Sunday June 10, 2012 @05:56AM (#4090662)
Because otherwise you get a bunch of

    new Callable<Integer>() {
      @Override public call() {
        return 1;
      }
    }
Re:Why isn't Java used for modern web application development? by masklinn on Sunday June 10, 2012 @06:08AM (#4090683)
Or even better,

    for(final Iterator it = container.iterator(); it.hasNext();) {
        final Object o = it.next();
        println((Integer) o);
    }
compared to:

    container do: [:o |
        Transcript print: o; cr.
    ].
Re:Why isn't Java used for modern web application development? by joshAg on Sunday June 10, 2012 @06:16AM (#4090702)
this explanation made the most sense to me. thanks.
Re:Why isn't Java used for modern web application development? by koide on Sunday June 10, 2012 @05:56AM (#4090663)
Because it's more expressive and leads to less and more maintainable code?

Who cares about paradigm purity? Especially given on a language that's not totally pure already.

Re:Why isn't Java used for modern web application development? by joshAg on Sunday June 10, 2012 @06:04AM (#4090677)
I don't care about paradigm purity, but given the amounts of java and lisp i've written, I didn't see why java would benefit from a lambda.
Re:Why isn't Java used for modern web application development? by rbanffy on Sunday June 10, 2012 @09:17AM (#4090965)
Actually, it needs pure functions. Lambdas are one way to add them with the benefit of being buzzword-compliant.
Re:Why isn't Java used for modern web application development? by IsTom on Sunday June 10, 2012 @10:14AM (#4091094)
Purity is orthogonal to lambda abstractions. It's matter of what function can do (pure or not) and function creation (a lambda or something more verbose).
Re:Why isn't Java used for modern web application development? by rbanffy on Sunday June 10, 2012 @05:18PM (#4092246)
Sorry. I meant simple, C-style functions. I should never comment on HN before breakfast.