Book Review: The Swift Developer’s Cookbook by Erica Sadun

41y+DqweMeL._SX388_BO1,204,203,200_

If you have been around the Apple development community for any amount of time you have almost certainly heard of Erica Sadun. She has already published dozens of books, taken a highly active role in the discussions and proposals on the evolution of Swift since it became open sourced, and has a Ph.D in computer science for good measure. Right away you know that this book is coming from a real authority on the subject of Swift.

As I do, lets start with who The Swift Developer’s Cookbook, is for so you can decide if you want to keep reading, or move along to finding what you are looking for. The book retails at USD 39.99 (for the print edition), but the price does tend to be a bit less than that. So for a book that clocks in at just over 200 pages this is a fairly reasonable price. The preface of the book says that it has been written “for programmers both experienced and new who are looking to push existing aptitudes into a new arena”. Now, if by “new” the author means an intermediate understanding of Swift then that is a totally accurate statement. The book will push you, no question about that, but this is not what you pick up in your first few months of learning Swift and you need a solid grasp of the fundamentals at the very least.

Another important point is that this book is all about Swift. There is no coverage of Xcode, or API usage, or Autolayout, or anything like that. This is purely about the language and that is important to keep in mind if you are perhaps looking for something more broad based in terms of Swift and Apple development. But if you want to dive deep into Swift and are serious about growing you skills in this realm, then this is going to be for you.

About the book

There are 8 chapters to the book: Introduction, Printing and Mirroring, Optionals, Closures and Functions, Generics and Protocols, Errors, Types, and Miscellany. Each of these chapters has been written to be fully independent of each other so if you only need the Generics and Protocols chapter you can head straight to it without needing to have read the others.

As the title implies this book has been structured in a way that each topic is about giving you templates, or guidelines, for dealing with specific problems or aspects of the Swift language. But you are not just being taught a series of steps that can be simply translated directly as is to your own code. It is much more about the fundamental concept of what each topic is. You can get an answer to “How do I make an optional?” but the book is also trying to teach you to simultaneously think “Does this variable really make more sense and create better code an optional?” which is a much more abstract, but equally important question to ask. In this sense the approach of the book is a mix of DIY manual and computer science text book.

The writing is very well done. Concepts and ideas are expressed clearly and the language used is appropriate, but also kept simple so that each sentence does not require a glossary to understand what is being said. Yes, there are going to be many times where you have to stop, and go back a few pages, or even to the start of the chapter, to reread sections because you are not quite getting your head around it. But this is usually due to the nature of the subject and the complexity of what is being taught. Some sections, in particular Errors, are really hard to get through. But I have yet to see any writing, anywhere, on error handling that I would describe as “electric” or “exciting”, or anything remotely close to that, so that is par for the course.

This book is published by Addison Wesley and when it comes to design and layout their expertise shows. The book I read was a print edition and the text was clear, easy to read, and was formatted with just the right spacing between letters and lines. The print edition had no colour, so code blocks were simply black text. Developers work in colour and when I am reading code that is what I like to see too. But most of the code samples were small enough that it wasn’t a big deal, and considering the cost of colour printing for print books, it is easy to see why the decision was made to go black and white and keep the cost of the book down.

There is also a e-book version that you can purchase separately, or is included with the price of the print edition. When the book was first released it was published using Swift 2.0 and the print edition has not been updated since then. The publisher does list this book as being part of the Content Update Program, however, Pearson Education, the distributor of the book, recently layed off several thousand employees, so this has had an impact on updates. Erica did however mention to me on Twitter that the updates are written, so whether the delay is much longer remains to be seen. But the will and interest of Erica to keep this book updated is definitely there. Because it is a very theoretical book it could still be relevant for another year in its current form, but with Swift evolving as it is, a lack of updates could be a deal breaker to many who need the most up to date syntax to really feel comfortable with the book.

How effective is the book?

The first time I read through the book I really struggled. A lot of it didn’t sink in and I felt a bit dumb for not being able to grasp more of the concepts. That doesn’t sound like a ringing endorsement but, actually it is, and there are good reasons for that experience the first time I read through it. To start with I was still not quite at a level in my own Swift knowledge that I was able to really understand a lot of what was being taught. And this is probably going to be a book that many people will end up reading twice, maybe even three times before everything really sinks in.

And for what the book is trying to teach that is perfectly okay. If you think to courses you may have taken in university, or college, or elsewhere, there were probably many textbooks or lectures that you needed to go through a couple times to really be able to absorb the information. A lot of that probably had to do with the nature of them being theoretical, or abstract, and trying to teach you how think and problem solve, as opposed to facts or prescriptive answers. The Swift Developer’s Cookbook is a book that requires an investment of your time and patience. If you are willing to do that then you are going to end up with a far better grasp of not only how to program in Swift, but also understanding what fundamentally makes Swift the language unique and delightful.

TL;DR

The Swift Developer’s Cookbook is really targeting those people who want to get serious about becoming great Swift programmers. It is not going to teach you everything, but it covers some of the most important concepts to the Swift language, such as Optionals, and Generics and Protocols. It is probably going to take time, and a few read throughs, before you become really comfortable with everything the book is teaching.

The only caveat I have is the uncertainty about whether this book will be updated to Swift 3.0. You could still read it and the concepts being taught will still be relevant even if it is Swift 2.0 syntax. But for some this could be a deal breaker, which is reasonable to understand. But if you are serious about advancing your Swift skills, and you are okay with it currently being in Swift 2.0 syntax, then it is definitely worth the investment.

If you don’t already, you can follow Erica Sadun on Twitter @ericasadun to find out all the latest Swift 3.0 news, and what she is up to, along with the occasional mom joke and cute animal picture tossed in for good measure. As always you can find me on Twitter @third_beach, or if you just want to follow updates to this site you can follow @manitobaninja.