News for hackers. Stuff that matters.
Re:Why your F# evangelism isn't working by heywhatupboys on Wednesday May 31, 2023 @01:22AM (#36134742)
well you see! What we can do is to namespace our functions, e.g. by naming them component_create, component_add_button, etc. We then create a plain dictionary with key value pairs that gets passed onto these functions! The functions then possibly return a new map, which is a modified map! This allows us to write code like

  dog = dog_create({name: "foo", age: 12})
  dog = dod_add_friend(dog2)
  print(dog["friends"])
and we can avoid OO completely.

oh... wait a minute

Re:Why your F# evangelism isn't working by epgui on Wednesday May 31, 2023 @01:28AM (#36134786)
This comment shows a total misunderstanding of what functional programming is…
Re:Why your F# evangelism isn't working by heywhatupboys on Wednesday May 31, 2023 @01:42AM (#36134891)
While tongue in cheek, this is one if the OP in non-OP patterns that is used heavily for large projects in FP alike.
Re:Why your F# evangelism isn't working by epgui on Wednesday May 31, 2023 @03:00AM (#36135346)
I'm not seeing that in the example, and I'm not even seeing anything very relevant to FP in the example either. I guess there isn't much mutation happening, and functions are called? But that's not what FP is.
Re:Why your F# evangelism isn't working by tigershark on Wednesday May 31, 2023 @03:39AM (#36135587)
This tells me that you never really looked at functional languages, not even used them. The power of ADT, especially when using a comprehensive pattern matching expression, is pretty difficult to emulate in the OOP world without a ton of code. But in this extremely simple case you just need a record.

    let dogBar = {Name = “bar”; Age = 11; Friends = []}
    let dogFoo = {Name = “foo”; Age = 12; Friends = [dogBar]}
    printfn “%A” dogFoo.Friends 
The advantage is that it’s immutable and it’s guaranteed to don’t have null in any fields. C# only introduced records recently, while F# was born with them. And C# still hasn’t got ADT because it’s missing the Union types as far as I remember.