Skip to content. | Skip to navigation

Personal tools

Sections

More Swift protocol thoughts

The other day, I had linked to some thoughts regarding object oriented programming, Objective-C and Swift's new protocol extensions. Here is some more background in support of the metablog viewpoint that we already have protocols and it is called object oriented programming, OOP.

From Design Principles Behind Smalltalk, 1981

"In Smalltalk especially, the interaction between the most primitive objects is viewed in the same way as the highest-level interaction between the computer and its user. Every object in Smalltalk, even a lowly integer, has a set of messages, a protocol, that defines the explicit communication to which that object can respond."

If you read the wonderful article on how Smalltalk got to where it was 30 years ago, you will see we have not really gone far and even seem to be going in circles.

I find it fascinating that a system "entirely comprehensible to a single individual" and to be used by children is consider to be too strange and difficult to use by adult programmers.

The following excerpt is particularly relevant to the last posting regarding the desire for better protocols in Objective-C years ago.

"Also, message protocols have not been formalized. The organization provides for protocols, but it is currently only a matter of style for protocols to be consistent from one class to another. This can be remedied easily by providing proper protocol objects that can be consistently shared. This will then allow formal typing of variables by protocol without losing the advantages of polymorphism."

Remember, the above quote is from 30 years ago and pre-Swift protocol extensions announced last week. That sentence is pretty much exactly how Objective-C should already be used. If a method argument can be of more than one class type, then those class interfaces should conform to a protocol and the protocol defines the method argument rather than a single class or id.

Add comment

You can add a comment by filling out the form below. Plain text formatting. Comments are moderated.