-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functional Programming vs. OOP #43
Comments
Did your eyes entirely miss what I wrote:
Additionally, local assumptions can be immutable, which does not require the global, total purity and religiosity of Haskell. Partial orders instead of total orders, because the latter don’t exist in our universe.
We already addressed that.
Not true. The HOF (higher-order functions) essentially require GC.
If you can grok it, then why are you thinking non-pure FP has no purpose. Typeclasses are a disciplined, well-typed form that leads to good abstraction. Good abstraction is essential to expert programming. You do not place a high priority on abstraction. We do.
I’ll let @keean address this. I am growing weary. |
I think I figured out why you’re downplaying the typeclasses point and not grokking how FP + goroutines work together. I will just add that it seems you do not see how Go’s goroutines can be combined with FP, because you presume that concurrency/parallelism in FP is only obtained as a total order of purity and immutability. But there is no such thing as 100% parallelism. In a pure FP language we would use monads to structure state so that we can prove which parts of our program are mutual independent so we can parallelize them. We this is analogous to employing local immutability and purity annotations and running the independent parts in goroutines. You think too simplistically and do not see that they are dualistic analogs of each other. There is no such thing as an entirely immutable program which is also Turing complete. Rather you’re thinking of a declarative language with no state transformations such as HTML without scripting. You’ve been hoodwinked by Haskell into thinking it’s doing some kind of exclusive magic that doesn’t have any mutable state. Or that the global purity and laziness as the default in Haskell does not have a categorical dual (i.e. impurity and eagerness as defaults) which is equivalent in power and also employs FP. Both of the categorical duals can both implement the capabilities of each other. They just have different default models due to the defaults chosen. |
@shelby3 wrote:
But how do you solve this:
such that can write record.a, record.b instead a(record), b(record) . And what about copying a value from records to other records, just like we importing values from modules to other modules? |
I don't understand, you can simply write:
I don't see the issue that is concerning you. |
So you request for an uniform function call syntax. I think this is quite ok. What about default values in typeclasses and importing values from other records, do you want to realize that by manual copying? |
Personally I want instances to be non-overlapping, as overlapping can cause problems with the meaning of programs changing when new instances are introduced, which I see as a mis-feature. This means default values are only allowed if the typeclass has no instances. This is not a very common case, and is probably not at all useful, so I don't think default values should be supported. I favour using disequalities to make make the same choices without overlapping, so:
|
@keean wrote:
An alternative is all instances would be manually listed on import. So then no strange changes based over defaults overlapping when imported modules change. Another alternative is only instances not defined in the module their data types have to manually listed on import. Another alternative to add to the second one above is for the compiler to create a metadata file with a list of the last imported instances that weren’t from same module as their data types. The programmer would need to manually augment this metadata or delete it so the compiler could refresh. |
Yes, the original idea of Kay was to model entities as "objects" communicating over channels "messages". BTW, this might interests you, too. |
Note, if I import a struct in Rust which has implementations, I also get the implementations into the current scope. I can implement new methods in the current module for the same struct which can then be exported to the module importing the said struct from the current module. Otherwise, inheritance of signatures in OOP is not that good, as it leads to collision just like importing module members at once "open". In the end, I would not say that inheritance in OOP is the biggest problem, there are more annoying ones:
|
Ty. I actually linked that before in these 1000s of Github posts, but lost it. |
I believe I refuted every point in favor of Scala’s OOP in In Defense of OOFP. |
Functional Programming vs. OOP
@NodixBlockchain wrote:
Incorrect. Imperative state effects are managed in the monad paradigm of pure FP.
There’s the Optionally declare functions
pure
? issue thread #4 for discussing monads and a general Language Discussion thread #1. There’s also a discussion of pure effects systems in the latter portion of the Concurrency issues thread #17.I already told you that the #35 issues thread (where this discussion originated) is not about creating a pure FP language.
I already gave you the superset definition of FP:
I really grow weary when having discussions with you because it’s as if the relevance of what I write doesn’t sink in for you the first, second, or even sometimes the 3rd or 4th time it is explained. How many more times do I have to explain that pure FP is not all of FP.
FP is not about avoiding state. That seems to be the stumbling block of your persistent misconceptualization.
FP is about the definition I quoted above.
OOP binds data to methods in objects at instantiation and includes the anti-pattern of virtual inheritance. FP employs dependency injection of functions along with data that function call, which is late binding of interface to data (aka “interface inheritance”). Typeclasses automate (and make implicit) this FP capability.
So the reason you do not comprehend the significance of what we are doing is because you haven’t yet grokked the distinction between FP and OOP. And how typeclasses are simply an automation of FP late binding dependency injection.
The strictly pure (and lazy evaluation) variant of FP is more focused on the mathematical definition of a function and equational reasoning. Monads are employed in order to model stateful effects in the pure FP paradigm.
P.S. I know you are a highly productive programmer once you understand. So I hope we could attain mutual understanding.
The text was updated successfully, but these errors were encountered: