Java 8 Lambdas
31–40 of 144 posts
Re: Java 8 Lambdas
#32Congratulations 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.
Re: Java 8 Lambdas
#33Earlier 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…
Re: Java 8 Lambdas
#34Would have been a big deal - if they introduced 10 years ago
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
#35Earlier 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…
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
#36Earlier 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.
Re: Java 8 Lambdas
#37I 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…
Re: Java 8 Lambdas
#38Earlier 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.
Re: Java 8 Lambdas
#39Would 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.
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
#40Congratulations to the Java-programmers for getting a feature that virtually every other OOP language has had for about 10 years.
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).