loading...

re: Function vs Object VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Then is it me, or is this similar to procedural programming with ADT (abstract data types)? In the real world, a lot of time people would mix par...

Regarding "scale of systems" I was mostly thinking about number of names (be it functions, classes, etc.) that might collide with one another. Namespaces of course solve part of the problem, in the meaning that functions have some "prefixes" before their names (like name of namespace or module for example).

What [is] the difference between namespacing with objects and namespacing with modules?

I didn't give an example here, sorry. I had in mind Java 9 modules, and upcoming C++20 modules. They solve different problems than just namespaces in these languages.

Regarding testability. I was thinking rather about a set of functions (methods) enclosed in a class. It's rare to do everything in just one function, typically one function uses other functions to express the result. I was never trying to imply that functional programs are difficult to be unit-tested ;)

You always get the same output for the same input, which is not always true for objects. [emphasis added]

Now I don't know how to respond to this... Seems like a serious bug to me. There's not a problem to create objects with immutable state, where the results of method calls are always the same. Plus such immutable objects can easily be shared between threads. It depends on the style and/or necessity.

There are patterns in FP as well, which you can learn and then reuse across languages. For example, map, reduce, functions as values, monads (option-monad, either-monad, futures - similar to promises, but not the same, etc.)

Very true. Just a different set of concepts. By the way, combination of map and reduce is one of my favourites (!) I learned long ago.

Thank you very much for your time and interesting discussion. I will keep coming to your blog and occasionally ask some more questions :)

Code of Conduct Report abuse