Wednesday, November 4, 2015

Swift Protocol-Oriented programming

Apple makes a big deal about Protocols in swift and how they are better than anything else ever.  I found it quite irritating that nowhere in their explanation of what makes them so great did they mention that a protocol is eerily similar to an interface in Java.  Moving from a C++ background to Java, I was completely baffled why you would use an interface rather than an abstract class.  That question was answered back in 1997 when I started designing applications and APIs using interfaces first.  Nowadays, moving into swift, protocols certainly have features that interfaces do not - such as extensions and conditional conformance - but really - this is not something they just pulled out of nowhere.  I wish they didn't have to act like every thing they do is new and unprecedented.

It would be so much more honest for them to come out and say, "In designing a new language, we looked at what works in Java, Lisp, Python, (gasp) Perl, Haskell, Go, JavaScript - the needs of iOS and the environment apps find themselves in - and created a best-of-breed language."

No comments:

Post a Comment