Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So if I use/chain Object.methods in JS I'm basically writing functional programming?

Is that really what FP is? I had the impression that FP was something different.



Yeah just functional programming isn't that mind-bending IMO. F# and OCaml are pretty easy to pick up.

I think the confusing bit is that one of the most popular functional programming languages is Haskell... which is really hard. So certainly in my mind I had "functional programming = like Haskell = stupidly difficult" for ages. But Haskell is difficult for other reasons: really abstract type system, functions are pure, etc.

Oh also another thing is they all tend to really encourage you to use immutable singly linked lists and write recursive functions that match on (head :: tail)... but I don't think you have to do that, and IMO it's the wrong thing to do a lot of the time (it semantically nice but computationally terrible).


Yep! If the methods create new objects, and leave the method arguments unchanged, you'll likely be writing code that's vaguely functional.


At its core, FP is programming using only functions. The rest follows.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: