5 ms·
>> This interface Supplier is one of the new functional interfaces in Java 8 and it is really appropriate for our definition here because it only contains a nul
by jebblue 14y ago
>> This interface Supplier is one of the new functional interfaces in Java 8 and it is really appropriate for our definition here because it only contains a nullary method named get() that can return any parameterized value that we want. So we can use a lambda expression to implement this interface on the fly, this would be a closure to generate the next stream node. This is where the lazy evaluation magic can happen by means of using this parameterless closure to define the next stream cell.
Since when did Java start sounding like, not Java? Is nullary a word? Lambda? Closure, isn't that a language? It's just stream management, why does it have to sound so complicated? Time to go back to C?
- randomguy7788 14y agonullary i believe is a word(a function that does not take in any arguments) just like how a unary function takes in a single argument, a binary takes in 2 arguments, ternary takes in 3 arguments, variadic etc etc etc... my apologies if you were being sarcastic :P (i am not a native english speaker)
- roryokane 14y agoI think he was being not sarcastic, but satirical – he was writing a parody of Java programmers. So he didn’t really mean that nullary wasn’t a word; he was just saying that existing Java programmers might be confused by all the changes and new ideas they will have to learn. But thanks for explaining ‘nullary’ anyway – I couldn’t remember what it meant. Edit: Looking at jebblue’s comment again, maybe I'm understanding him wrong and he’s serious after all. Poe’s law (http://en.wikipedia.org/wiki/Poe%27s_law http://en.wikipedia.org/wiki/Poe%27s_law) is in effect. In case “Closure, isn't that a language?” is serious, here’s the answer: no, but Clojure (http://clojure.org/ http://clojure.org/) is. The name “Clojure” is a pun on “closure” (source: https://groups.google.com/d/msg/clojure/4uDxeOS8pwY/UHiYp7p1a3YJ https://groups.google.com/d/msg/clojure/4uDxeOS8pwY/UHiYp7p1...).
- randomguy7788 14y agoahh, thanks for clearing that up and explaining the difference between the terminologies!
- jebblue 14y agoTrue, also thanks randomguy for the explanation, If I've come across that word I couldn't recall it. Normally I'd just look it up but then all the other terms hit me and I just had to write something to show the level of frustration I'm already sensing about Java 8.
- kyllo 14y agoIf you can't beat 'em, join 'em, right? If you can't get all the Java programmers to switch to a functional programming language, just add enough functional features to Java that you can do FP in it. It's genius, really. Within another version or two, maybe Scala will be unnecessary.
- norswap 14y agoWhile the addition of functional features to Java is more than welcome and should continue, here's to hoping that Java never gets as needlessly complex as Scala.
- happy_dino 14y agoHaving gained experience with both, I can happily declare Java 8 to be finally more complex than Scala.
- kyllo 14y agoI'm not a Scala guy, but I think Scala allows one to write less complex code than is typically written in Java (1.7 or lower). Let's not confuse the complexity of the language itself, with the typical complexity of idiomatic code written in the language. Ruby is about as complex of a language as there is, the syntax and formal language spec are nothing short of baroque, but its flexibility and expressiveness allows you to write succinct, drop-dead simple code in it, that could only be expressed with pages of boilerplate in Java. Adding functional features to Java will make its spec and implementation more complex, but it can make actual Java code less complex.