40
Comments
  • 4
    Interestingly there is a trend emerging that agrees with that statement.

    It's been around for a while but it recently starting gaining support again.
  • 7
    My classmate told me functions/methods confuse him. A had a look at his code. Counting the lines of his main would make an 4 byte integer overflow
  • 2
    @nblackburn the thing is that they said this because they didnt understand it. In the last year they were encouring us to do it.
  • 1
    @Codex404 I guess the same applies anywhere else because functional is easier to understand.
  • 4
    @nblackburn is it? I started with OOP game dev and switching to functional was so annoying.
  • 2
    @Codex404 I would say so because there is a lot more concepts to grasp than functional. The reason you found it difficult was likely because it is a change of mindset.
  • 1
    The real problem with OOP is that dev abuse it. And it's not really interesting as core concept for an architecture. Try some DOP to clean the code and remove that inheritance hierarchy.

    And please don't use functional if your language is not build for it (at least keep it to the minimum).
  • 1
    As someone who struggles learning C++

    What's wrong with OOP?
  • 2
    @LeFlawk OOP is okay, but there is so much better to build an architecture.
    An architecture with OOP will have a horrible inheritance hierarchy which is not good for your heart if you plan to maintain and add features to your software. And testing is not really quick. You easily lost performances with an architecture like that btw.

    I'm learning to build an entity components system library with C++. Take a look at what mean ECS or data oriented programming. It's not the only solution I guess, but I like it.
  • 2
    @Celes Im mostly doimg PHP nowadays, Laravel is written in an OOP manner and its really easy to change or extens a piece od the framework.

    When I was doing gamedev in C++ and C# OOP was great. It could be just me but functional programming is a lot harder to keep code clean.
  • 1
    @Codex404 you will probably see more clean code with a functional language like Haskell I think. But when you did OOP all this time, the feeling can be weird indeed x)

    I guess building a library will allow you more easily too see the problems with OOP. Well that's not like if you can't use it, just that more interesting things exist :p
  • 4
    OOP is fine, and functional is also fine. Both can be overused and misused, but when applied correctly and in the right amount, both can be useful
  • 1
    I always think of oop = database or model, functional for interfaces, procedural for transactions. But that's just my humble opinion.
  • 2
    "Don't listen teachers at school"
    - business
  • 2
    Your teacher is wrong!!! Use OOP with static methods only!!!1 😎
  • 1
    @Codex404 Laravel is actually the furthest from OOP you can get in PHP.

    Noticed the shit ton amount of traits used for everything? The composable methods on collections, where they even forced in higher order messaging to avoid the need for closures? Scopes for queries which automatically have a builder -> builder type signature? The lack of constructors, and heavy use of magic methods in many classes? Extending classes using Macro injections?

    Laravel is so "convenient" and terse because it ports as much functional programming concepts to PHP as possible.

    The problem you run in to now and then is that FP really needs a solid type system if you want to prevent complicated bugs, because with dense composable functions it becomes hard to see where what happens if you can't typecheck the in/out of every function.

    PHP7 is going in the right direction regarding parameter & return type definitions, supporting optionals. But just maybe types is not enough, we need either and monads and ADTs.

    And arrow functions... without arrow functions, functional JS was unreadable. Now in ES6 it's almost doable.
  • 2
    @bittersweet wait if that is true than Im confused about what OOP is since Ive always learned it was working with classes and objects of those classes.
  • 1
    @Codex404 True! Laravel is still solidly grounded in OOP (it's harder, but not impossible, to ditch than in JS).

    But it's very noticeable that Otwell hates OOP, hacks it away as much as possible, and replaces it with some FP inspired magic.

    The result is a framework which shows the advantages of functional programming in a language which wasn't designed to do it.
  • 1
    Sure professor! Let me uninstall it 😑
Add Comment