6
Trithon
4y

man... fuck java's approach to lambda expressions and like passing functions as arguments and the lot.
it's honestly just so terribly bad. it's sucks so much.

Comments
  • 3
    Which approach do u favor?
  • 0
    @IntrusionCM a reasonable one?
    something like kotlin or go, where functions have easy to write typed and can be passed around like any other variables. python and js are also fine if you don't mind not having type safety
  • 2
    I like the approach
  • 1
    Is it? I still have to try them, unfortunately I never had to use that feature. I'm really looking forward to it, when the right time arrives. It's something emotional for me, Java and lambdas.
  • 3
    @Trithon functional interfaces in java and lambdas implementing them are also typed and can be assigned to variables. And operated on as ones. They can also be serialized, meaning dumped to a file, stored in redis or db, transferred over the network.

    What's the problem here?
  • 0
    @netikras Woah. 🤩
  • 2
    @Trithon so basically what you’re saying to @IntrusionCM Is that you don’t like statically typed languages? 😄

    I really like the java approach. The py one is really nice as well though..

    If you wanna treat everything like any variable, try > java 9.
    Haven’t used it myself yet but I don’t like what I’ve read so far.
  • 1
    @c3r38r170 most for loops can be used as streams -> lambda.
  • 1
    I think that code examples would be nice...

    It's not that I favor any language, but I think that every feature can be used in good or bad ways.

    Using lambdas as variables sounds nice first, but long term... Uh....

    Don't think so... It hides complexity
  • 0
  • 0
    Thank the type system. :)
  • 0
    Really don't get the issue. There's things I wish it supported (currying, operator overloading etc.) but the general approach I find pretty solid tbh. I'd take it over the JS approach any day.
  • 3
    "using lambdas as variables"

    Hey uh so me and my functional gang are gonna find you and beat you up if you dont mind.

    I mean @intrusioncm
  • 0
    @yellow-dog you didn't read the comments I guess :)
  • 1
    @IntrusionCM You're kind of right, having functions as first class citizens can make things complex — especially if you don't choose good variable names consistently.

    But the power it unlocks, and with that, the bugs it can prevent, make it more than worth it.

    I would really recommend trying out this course/book in a lost weekend:
    http://learnyouahaskell.com/chapter...

    Not because everyone should program in Haskell, but because it opens your eyes to functional patterns, and why OOP languages are rapidly adopting Haskell-like features.
  • 0
    @bittersweet again... You didn't read the comments, too...

    I said that storing an lambda inside a variable is a bad idea longterm wise....

    What the fuck?
  • 0
    @IntrusionCM I read that part, I just don't agree that it's a bad idea.
  • 0
    @IntrusionCM i have read it. Ive seen that you think "storing a lambda in a variable" is uh... a thing. Its a first class function. What do you think is the difference between
    def fun(){ // }
    and
    let fun = () => //
    is?

    Absolutely nothing*
  • 0
  • 1
    @larrywho11 you have a type that accepts arguments and produces a value. Thats called a function. But i guess i should totally listen to devrant user larrywho11 instead of oracel.
  • 1
    @larrywho11 you are either a troll or another college dude whos only experience is writing that hangman assignment in java6, and im leaning towards the second.

    Btw the method-container-object you are talking about is called a monad.
  • 0
    @yellow-dog don't know much about functional programming. But as far as I remember there is no function in java either
  • 1
    Java was designed for OOP so its natural that functional paradigm is kinda hacky. Lambda is not the most intuitive way but its the Java way. I do not like Java or any OOP focused language by that matter, but @yellow-dog has a point i do agree.
  • 1
    @just8littleBit ah yes, the not statically typed languages like kotlin and go!
    -.\
    What i hate is how java ""solves"" the issue. It's so perfectly not clear.

    Reasonable language:
    sort( array: type[], isBigger: (type, type): bool ) {•••}

    Java:
    sort( type[] array: Predicate<type, type> bool ) {•••}

    To someone a bit unfamiliar with functional style, the java way is much too complicated!
    What the fuck is a predicate? It's a grammatical component you fucks! Not a function that takes some generic ass arguments and returns a bool!
    What the hell is a DoubleConsumer<T, S>??
    Oh you want a DoubleIntFunction<T, S> as well? Too bad, stdlib only has 3-param long types prepared for ya!
    And i don't even know any other types that might exist like that! Why not make it easy and make the type the signature w/o the name!!!
    Java could style it like:
    type name( argtype name, rettype(argtype, ...) name2 ) {•••}
    Would be much easier to learn and understand!
  • 0
    @IntrusionCM see my last comment
  • 0
    @Trithon did you know, that in scala, you can literally pass "predicate", and it will resolve to a (a: Any, b: Any): Boolean ?
Add Comment