Review: Simulations in Swift 5
I have been curious about Swift for the past few weeks. Mostly because of all the attention Apple is giving to it. This book was among those I picked up to study the language. When I saw that one reviewer on Amazon gave this book a bad rating, for the wrong reasons, I decided to write one and have it here.
If you are curious about Swift, regardless of what level you see yourself at, you should give this book a try. It does not assume any level. It is short and covers interesting computer simulations. Keep in mind that you might need a Apple computer and the Xcode IDE. I haven't tried the recent standalone app for running Swift playgrounds.
At about 150 pages, this is one of the shortest programming books I have read recently. It discusses five simulations. The last simulation spans two entire chapters. One simulation is the famous game of life, which has had entire volumes dedicated to it. The author covers it in about a couple of pages, including the code.
Swift is by no means a simple or easy language. The language has changed, many times, over the years. But the author covers just enough of the language to get your simulations going. As someone who has been in this field for a while, I find that quite refreshing. Recent technical books throw feature after feature at you, to show how super cool their new tool or language is. This book does not do that.
Also, short books tend to be better for us because technology advances at such a ridiculous pace and things get obsolete fast — reference books are the exception. Short books that cover interesting topics instead of the topic du jour are even better. Despite not being comprehensive, they give the reader ideas and avenues to explore next. We need shorter books! Oh, and tech talks as well.
There were a few things I didn't like, but they didn't outweigh the good parts. For example, the book never tells you that UIKit is for iOS (iPhone, iPad, AppleTV) only. It does not tell you to import the foundation library for some functions that, in my opinion, should have been built-ins in the first place. Sometimes, the book explains concepts like closures or recursions at the end of chapters that used them. It slightly annoyed me on behalf of those who are just starting.
Okay, last nitpick because the coder in me is dying to. Seeing Int.random(in: 0..2) a few times bothered me and I made me question my understanding of Swift. I know the language is all about high-level constructs, but wouldn't Bool.random() make more sense? In fact, I went with that in my code, and things worked fine. Is there some optimization that makes random faster for Ints and not Bools?
You can get the book from Amazon here.
February 21st, 2020.