News for hackers. Stuff that matters.
Re:Ask HN: Concepts that clicked only years after you first ... by taffer on Sunday January 01, 2023 @02:08PM (#34209585)
OOP does not have a monopoly on abstraction and encapsulation. What OOP does, namely object-level encapsulation, is just a very extreme way of structuring code around mutable state. IMO the better alternative is to avoid mutable state as much as possible and keep data and code separate. Code structured as pure functions is easy to test and encapsulation can be done at the module level.
Re:Ask HN: Concepts that clicked only years after you first ... by optymizer on Sunday January 01, 2023 @02:17PM (#34209702)
My point is that improving the state of unit testing has little to do with OOP, and everything to do with the environment that the code runs in.
Re:Ask HN: Concepts that clicked only years after you first ... by kagakuninja on Sunday January 01, 2023 @05:17PM (#34211625)
OOP does not require mutable state. OOP has its origins in imperative languages, and so in the past OOP often involved poor management of mutable state.

I am a Scala programmer, and our code mixes OO and FP. Almost all of our classes are completely immutable.

In the end, you will always need to encapsulate data and functions in some manner. The FP approach involves module systems, but as I understand it, objects in Scala actually provide a better module system than found in pure FP languages.