Live data from Hacker News

Java 8 Lambdas

datumedge.blogspot.co.uk

111–120 of 144 posts

Re: Java 8 Lambdas

#111
post #61

Earlier quoted context omitted.

Are you kidding? Reflection is one of the most powerful parts of the .NET framework. Hell, the page you link to contains many examples of the different possibilities, but they're just a start. The only knock I know of against reflection is that it's a performance hit. If that's really the issue, write the code using reflection (it's going to be better code, most likely), and then see if performance is an issue. If it…

Sometimes I find it a littl bit interesting that .NET community typically lag behind Java community in general (be careful interpreting general vs all). In Java, the best known book that can be considered comparable with Jon Skeet book is written by Josh Bloch of SUN, Google, and API design fame. He literally suggested to avoid Reflection and use other features unless you are in the business of writing IDE, compiler,…

Brrr. I wish I could edit all the typos I've made using iPad :(

Re: Java 8 Lambdas

#112
post #98
post #96

I was recently at a Java conference where Juergen Hoeller (of Spring fame) was a keynote speaker. In one of his talks he said something like "Once again, Java is solving yesterday's problems". The moment he said that, I thought to myself "Yes! So true!". The day before, Angelika Langer gave a talk on Lambdas in Java 8. I watched as the other developers listened with half-opened mouths (and some of them, with confused…

Because in environments where Java is used "switch language your're using" just isn't such a viable option. Especially in the light of an option of just upgrading the language. There's nothing seriously wrong with Java that couldn't be fixed by incremental language updates - like the ones C# has received in last couple of versions.

> Because in environments where Java is used "switch language your're using" just isn't such a viable option.

I hope this excludes the education sector. Nobody should ever learn lambdas as being "implementations of a compiler-guessed interface with one non-defaulted method".

Re: Java 8 Lambdas

#113
post #99
post #96

I was recently at a Java conference where Juergen Hoeller (of Spring fame) was a keynote speaker. In one of his talks he said something like "Once again, Java is solving yesterday's problems". The moment he said that, I thought to myself "Yes! So true!". The day before, Angelika Langer gave a talk on Lambdas in Java 8. I watched as the other developers listened with half-opened mouths (and some of them, with confused…

I don't understand or agree with your logic at all. Oracle shouldn't waste time on Java because it is already so far behind as to be hopeless? That notion seems silly at best, especially as 99% of code written on the JVM is still done in Java. Also, generics fiasco? Generics may not be perfect, but I haven't met a single person who isn't glad that they are in the language. Who has done generics better? C#? Because C#…

It depends on what you want to do. It would make sense that Scala, a language that can naturally encode a type class like structure and jruby, a dynamic language wouldn't mind erasure. For jruby it is self evident why and for scala's case, reified generics make it really hard to do higher kinded stuff.

Haskell is type erased too but it's not commonly noticed due to the nature of the structures commonly used and the strength of the type system. But in an OOP language where inheritance is used significantly, you really do need Reified generics as they make things much easier. I believe Java also made additional compromises to maintain backwards compatibility.

Re: Java 8 Lambdas

#115
post #41

Earlier quoted context omitted.

I smell trolling, however considering this anecdote is genuine: (1) interns should never be allowed to commit code in the master branch without a code review from a senior developer (2) there are many competent developers in India, or around the world, so if your company needs to outsource, it can do so by being a little careful about who they employ (3) if the above 2 are not possible, simply look for another job, b…

I can give many examples where I've handed code over and later there was problems due to less-skilled developers. One good example I have is being called by a client who had a bug they couldn't fix in some code I had written years before. After looking into it, I found something like this: // ABC 1/1/2001 removed this call as we don't understand why it was being called // x = performImportantCalculationABC(); There a…

Your code looks bad to me. Either x isn't used at all later, or you set x then for some reason set it again which is bad.

Re: Java 8 Lambdas

#116
post #61

Earlier quoted context omitted.

Are you kidding? Reflection is one of the most powerful parts of the .NET framework. Hell, the page you link to contains many examples of the different possibilities, but they're just a start. The only knock I know of against reflection is that it's a performance hit. If that's really the issue, write the code using reflection (it's going to be better code, most likely), and then see if performance is an issue. If it…

Yeah, I don't know about that. When I first discovered reflection, I was using it for everything. Initially it was awesome but then I've quickly realised that it's exactly the kind of thing that makes code a lot more complicated than it should be, especially with the deadly reflection + expression trees (runtime code generation) combo. It's really a dark path that you should stay away from. Basically, unless your pro…

>When I first discovered reflection, I was using it for everything.

Well there's your problem. You have to use the right tool for the job. Reflection shouldn't be used for everything, and I wasn't suggesting that was the case. My point was that it shouldn't be avoided. It's damn helpful in a lot of different places, and to say outright that you're just not going to use it would be depriving yourself of a powerful toolset.

Re: Java 8 Lambdas

#117
post #9

'sorted()' doesn't really act like that, does it - taking in a comparator function? It's much better to have comparator functions for the most common types baked in, and use projection to select a list of fields to use to compare with. Comparator functions are very easy to get wrong. The example given here - ".sorted((a, b) -> a.getValue() - b.getValue())" - won't work properly when the calculation wraps around.

> It's much better to have comparator functions for the most common types baked in, and use projection to select a list of fields to use to compare with. Except that requires a sorting key for the result. Trivial for dynamically typed languages, but how do you handle the type of that key in a statically typed language? Mandate that the key be a string? Build a limited set of overloads against a dedicated type? And ev…

I have to agree here, this feels too much like:

"Doctor, it hurts when I move my arm like this!"

"So don't move your arm like that."

We've spent the last...god knows how many decades dealing with wrap-around on (unsigned generally) integers. :|

Re: Java 8 Lambdas

#119
post #99

Earlier quoted context omitted.

I don't understand or agree with your logic at all. Oracle shouldn't waste time on Java because it is already so far behind as to be hopeless? That notion seems silly at best, especially as 99% of code written on the JVM is still done in Java. Also, generics fiasco? Generics may not be perfect, but I haven't met a single person who isn't glad that they are in the language. Who has done generics better? C#? Because C#…

As a "language snob", I feel that Java is hopelessly behind among JVM languages. But I also think that C# is well-designed enough that it doesn't matter whether it's the only CLR language I'll ever use. I don't know if the grandparent poster feels the same, but your post actually confirms my opinion. Of course I have no realistic idea how Oracle would ever migrate millions of Java coders to a cleaner language. :(

>>As a "language snob", I feel that Java is hopelessly behind among JVM languages.

Java is designed by its existence to be a better C++, nothing much. Nothing changes that base design goal.

But this is a design goal for the late 80's and early 90's.

The fate of most Java-only programmers, which are uncountable today is pitiable to say at the least. Its like Dijkstra said, one must avoid prolonged exposure to bad tools. Because they permanently damage your brain. Oracle will never do away with Java, its their bait to sell their products. Most Java programmers will go the COBOL programmers way- "Employable only at MegaCorps"

Re: Java 8 Lambdas

#120

Earlier quoted context omitted.

Funny, I've had it the other way: I was working on a project as a senior dev and had interns writing Godless functional code using Guava and Functional Java, and having a grand old time seeing how much concurrent code they could fit into a single statement. The fact is that Java is not a functional language and to bolt on functional pieces and then ignore the imperative, OO nature of Java is stupid. Don't get me wron…

There are significant lessons to be learned from functional programming, the least of which is the value of immutability in making complex systems comprehensible. Immutability is almost completely necessary for easy-to-understand concurrency, and extremely helpful in designing easy-to-understand APIs and operations on in-memory-models. It is a poor programmer indeed that discards the lessons of FP and instead writes…

>>It is a poor programmer indeed that discards the lessons of FP and instead writes purely imperative OO. Your interns may have been writing bad code, but it wasn't the "functional" part that was the problem.

Functional code is not Idiomatic Java code, 99.99% of Java code, practices and projects do not have it. Now when you go and bolt functional code on top of it, you are putting a tough puzzle on top of the code.

Don't be surprised if people cannot understand such code. In fact its bad programming to write non idiomatic code in a language. It confuses people, puts wrong patterns and paradigms and places where they don't belong. The language syntax struggles to support such semantics and often the code looks like a difficult puzzle in itself. Such code is very difficult to maintain and saps your energy is focusing on the wrong issues.

Post reply on HN