8

I have lately seen a lot of people mentioning that functional programming is better than object oriented programming.

So far I have only experience in oop and I would really like to know some reasons why it is better.

Comments
  • 1
    I cannot think of any reason why functional programming would be better. Maybe for simple stuff. Most real-world applications demand OOP. It would be extremely difficult to implement without good OO modelling.
  • 2
    Functional programming makes threading extremely easy, and therefore scales horizontally very very well.

    Most oop apps only scale well vertically, which gets expensive quickly!
  • 1
    it often is more solution oriented.
    Where in OO you do a lot of designing a hierarchy, you don't do that in FP.
    It is simpler and often more predictable.
  • 2
    Pure functions* are very easy to test and debug. They are predicable and can be composed with one another.

    *Pure functions that have no side effects, for every input that is the same, the same output is provided. For example: a function that adds two numbers
  • 0
    Neither is the holy grail. Functional programming is mostly from JS guys.
    And OO is rather new in that regard.

    Some languages are OO only and some functional only and some mix.

    I prefer a mix from both but honestly functional programming gets messy as fuck after some time mostly because stuff gets implemented dozen of times and they all have different behavior if you don't go strictly with your code guidelines. Look at php for example many function somenamed so or some_so. Haystack and needle for string functions aren't consisting either foo($haystack, $needle) and bar ($needle, $haystack). I still like php though because it matured.

    On the otherhand I made a little adventure into Java and could scream when I had to write stuff like

    Url url = new Url("http://foo.com"); and that motherfucker wanted me to catch an MalformedUrlException.

    choose your poison but don't say any is better

    PS: JavaScript is a clusterfuck because most node_modules are missing core functionality
  • 1
    http://weblog.raganwald.com/2007/...

    For examples see CommonLisp, Haskell, Elixir...

    Oh and http://smashcompany.com/technology/... .
  • 0
    @Data-Bound you're probably right. I have a distaste against OOP because industry treats it as the defacto methodology. Fortunately they are slowly coming around and frameworks like React are becoming more mainstream thanks to Facebook. Even if they have a stupid license agreement.
  • -1
    @Data-Bound doesn't know what fp is lmao
  • 0
    There is a big difference between fp purists and fp pragmatists.
Add Comment