[swift-users] Comparing POP to OOP
hoffman.jon at gmail.com
Sat Mar 5 16:12:12 CST 2016
> On Feb 25, 2016, at 7:35 PM, Dave Abrahams via swift-users <swift-users at swift.org> wrote:
> on Sun Feb 14 2016, zhaoxin肇鑫 <swift-users-AT-swift.org> wrote:
>> I have not read your blog. But in my opinion, what Apple called protocol
>> programming is actually so called functional programming. It is not object
>> programming at all. It uses protocols and structs to avoid object
> I don't think most functional programmers would recognize
> protocol-oriented programming as what they do. It is true that one of
> the main benefits we see in protocol-oriented programming is that it
> allows one to use *mutable* value types, instead of classes, in
> polymorphic contexts. Functional programming is largely concerned with
> immutable data, where the distinction between value and reference
> semantics disappears, and it doesn't matter if you're using classes or
> not. But the main thing in FP is the use of higher-order functions,
> which Swift enthusiastically supports, but have nothing whatever to do
> with protocol-oriented programming.
Your e-mail touches on one of the things that excites me the most about Swift. As you say “But the main thing in FP is the use of higher-order functions, which Swift enthusiastically supports, but have nothing whatever to do with protocol-oriented programming”. Swift isn’t just a Protocol-Oriented programming language or an Object-Oriented language or a functional programming language it is actually all of them and more. While other languages attempt to support different paradigms, in my opinion, Swift is one of the few language that actually does a good job at supporting multiple paradigms.
In the conclusion section of my post, I mention that while I pointed out a lot of ways that I believe POP is superior to OOP I would not say that POP is a clear winner over OOP. The winner is actually the programmer because we are not limited to one programming paradigm. We can choose the paradigm that fits our needs. Personally I have use POP in a number of projects and I definitely prefer it to OOP or FP but I would not criticize anyone that uses the other two because they are very valid paradigms that have proven over time.
>> On Mon, Feb 15, 2016 at 7:59 AM, Jon Hoffman via swift-users <
>> swift-users at swift.org> wrote:
>>> Numerous tutorials that I have seen take a very Object-Oriented approach
>>> to the protocol-oriented programming (POP) paradigm. By this statement I
>>> mean that they tell us that with POP we should begin our design with the
>>> protocol rather than with the superclass as we did with OOP however the
>>> protocol design tends to mirror the superclass design of OOP. They also
>>> tell us that we should use extensions to add common functionality to types
>>> that conform to a protocol as we did with superclasses in OOP. While
>>> protocols and protocol extensions are arguably two of the most important
>>> concepts of POP these tutorials seem to be missing some other very
>>> important concepts.
>>> In this post I would like to compare Protocol-Oriented design to
>>> Object-Oriented design to highlight some of the conceptual differences.
>>> You can view the blog post here:
>>> swift-users mailing list
>>> swift-users at swift.org
>> swift-users mailing list
>> swift-users at swift.org
> swift-users mailing list
> swift-users at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-users