Live data from Hacker News

Java 8 Lambdas

datumedge.blogspot.co.uk

31–40 of 144 posts

Re: Java 8 Lambdas

#32
post #24
post #2

Congratulations to the Java-programmers for getting a feature that virtually every other OOP language has had for about 10 years.

The feature has been in Java for a long time. This is just nice syntax for anonymous inner classes.

Though the current implementation does use anonymous inner classes under the covers the intent was to specify them such that other implementations that are more efficient could be used. The likely final implementation will be simple methods invoked with invokedynamic that don't need a separate class and instance per call site.

Re: Java 8 Lambdas

#33

Earlier quoted context omitted.

Java is still widely used. I'm looking forward to this -- there are some projects we can't take to Scala due to client concerns around a less mainstream language.

> Java is still widely used. I'm looking forward to this -- there are some projects we can't take to Scala due to client concerns around a less mainstream language. I hope I am wrong but I smell a trap here. Some time ago I implemented a solution (for .Net, that is) that employed some more modern techniques ( reflection, recursive lambdas, etc). Unfortunately many of the programmers in charge of maintaining my code w…

You lost me at reflection. That said, I think that some of the more advanced usages of lambda could be more difficult to understand.

Re: Java 8 Lambdas

#34

Would have been a big deal - if they introduced 10 years ago

I think you are mistaken. For 99%+ of business level code which wires up pre-built J2EE components and builds domain models, then you simply don't need them.

Even in C# for example, I've seen huge systems written in .Net 4.0 without a single lambda being required.

Re: Java 8 Lambdas

#35
post #30

Earlier quoted context omitted.

You can't have statements in pythons gimped versions of anon functions :/

I call BS. def return_closure (value): def closure (): return value return closure foo = return_closure(5) print foo() # prints 5 If you look closely, foo is an anonymous function, and it could have anything you bloody well please inside of it. What you can't do is put statements in an anonymous function that you are declaring inline. But the full syntax I just demonstrated is only marginally longer. UPDATE Modify th…

If you look closely, foo is an anonymous function

No, "foo" is a variable holding a reference to a named function--the function named "closure". You seem to be confused as to what an anonymous function is. (It doesn't per se have anything to do with closures.)

GP is right, Python's lambdas are crippled, unfortunately. And I'm saying that as someone who loves Python.

Re: Java 8 Lambdas

#36
post #26
post #21

Earlier quoted context omitted.

I don't know what you mean by "sorting key" in this context. The idiom I have in mind is how .Net implements "SortBy", "ThenBy" and friends. Overloads can be used for a comparator function based approach, but it should not be the first choice. And I'll stand by comparators being easy to get wrong, particularly when values may be null, polymorphic, etc.

> I don't know what you mean by "sorting key" in this context. He means the item by which you sort. The "by" in your "SortBy" example.

Yes, but that reading doesn't make sense given what he also wrote - that apparently this would make things more awkward in a static language.

Re: Java 8 Lambdas

#37
post #5

I don't know how I feel about interface defaults. Why is that more important than say declared properties or unsigned types?

They are hugely important for introducing new behavior on existing interfaces without breaking compability. They are at the core of what is going to allow you to use all the new functional-style collection methods on your old collections without changing your implementation code at all. Declared properties and unsigned types are relatively small changes. BTW, in JDK8 they have provided limited support for unsigned ty…

Agreed and it's an order of magnitude better than extension methods which .Net uses for the same functionality!

Re: Java 8 Lambdas

#38
post #4

Earlier quoted context omitted.

Care to elaborate? Ruby had them from day 1, PHP has only had them since 5.3, not sure what the deal is with python.

C# has had them for a little while now.

OT, but all this language comparison got me wondering: has anyone implemented C# on the JVM? :-)

Re: Java 8 Lambdas

#39

Would have been a big deal - if they introduced 10 years ago

I think you are mistaken. For 99%+ of business level code which wires up pre-built J2EE components and builds domain models, then you simply don't need them. Even in C# for example, I've seen huge systems written in .Net 4.0 without a single lambda being required.

In your sense, you don't need them for 100% of the code.

Lambdas are NEVER required, as tons of other syntactic features are never required.

They are nice to have though, because they make the code more concise and reduce bugs but reducing boilerplate and repetition. Working without them when you have them at your disposal is idiotic.

That huge .Net 4.0 systems have been written without a single lambda probably speaks more about the programmers (not experienced enough?) than about lambdas.

Re: Java 8 Lambdas

#40
post #2

Congratulations to the Java-programmers for getting a feature that virtually every other OOP language has had for about 10 years.

And what difference has the lack of lambda's really made?

I cant stand these "my language is better than your language" debates. Use whatever one makes sense for the job (or, in the case of the enterprise, you can hire enough of).

Post reply on HN