Programming paradigms
It's sometimes hard to imagine that there are ways other than object-oriented programming to write software. It all seems such a no-brainer; variables can be changed, objects are instances of classes and those classes have methods and properties, sub-classing saves a lot of duplicate code, and functions can do whatever they want as long as they return the right type. How could it be otherwise?
It is certainly true that Xcode and Cocoa together encourage an extremely object-oriented view of the world, and for very good reason. But in this section, we will take a look at some alternatives, and the reasons why we may want to employ them, either in whole or in part.
Swift is a multi-paradigm language in that it has strong support for programming in different styles; the content of this chapter is driven by that variety.
So, what is meant by paradigm?
Programming paradigms are ways, or styles, of programming. They are not specific languages; they are not coding templates; they...