A brief complaint

I have been programming for 30 years…this is my first attempt at programming on a Mac.

I have to say using a PHYSICS problem as an example is way over my head. Not really understanding this chapter that well and I think it is because I know nothing about Physics. I’ll have to look at some other books to get an understanding of what this chapter is really teaching me. A simpler example would have made this a lot easier.

I’m sorry to hear that, but thank you for letting us know. If you have any questions about it, please ask. We would be happy to help.

In general it may be helpful to go through the chapter without trying to understand everything. You are learning a lot of new things at once: a new language, new development environment, and new subject matter (physics!). We find it is helpful to muddle through it and get the code working, and then go back and try to work out exactly what the program is doing and why it works.


Thanks for response…like I said a BRIEF complaint…I am looking forward to the SWIFT book that will be out this summer. I am actually glad you put this book out first because I do like learning the GUI side as I go vs. going thru a whole book of terminal code that I will probably never use on a project. That is great for examples but kinda boring to learn.

We are looking forward to it, too. There is a lot to Swift that we weren’t able to cover in this book!

If it helps any (and it may not), here are a couple of things that were not really explained in the example.

dt is a convention standing for “delta time” (Δt), where “delta” itself is a convention for “the change in”. So dt is just shorthand for “the change in time”.

A vector is just something with magnitude (how much/heavy/fast/etc.) and direction, represented in 2D space as an ordered pair “(x, y)”. With an implied origin of (0, 0), the longer the line, the higher/stronger the magnitude. Add an arrow tip to the end, pointing away from (0, 0), to reinforce the direction.

Acceleration due to Earth’s gravity is about 9.8 m/s (meters per second), for every second of downward velocity. And by convention, “up” is represented as a positive number, while “down” is represented as a negative number. That’s why gravity is set to Vector( x: 0, y: -9.8 ). Gravity doesn’t cause anything to move left or right (the x direction), but it pulls downward at about 9.8m/s per second (y=-9.8).

As to the question of what the chapter is trying to teach, my take on it is:

[li]structs vs. classes (especially being able to include methods in structs)[/li]
[li]self-referencing via self (as opposed to this)[/li]
[li]how to declare a return type from a method[/li]
[li]the need to use named parameters when invoking methods (though unlike some languages, the order matters)[/li]
[li]how to keep a descriptive parameter name for callers but use a more convenient shorthand internally[/li]
[li]how to use operator overloading (but outside the struct, outside, outside…); bummer that we can’t use += for Vectors though[/li]
[li]designated initializers vs convenience initializers[/li]
[li]practice with declaring and using/iterating arrays[/li]
[li]whetting our appetite for closures[/li]
[li]how to indicate inheritance, and the need to declare explicitly when a method is being overridden[/li]
[li]how to view the iterative history of a variable in the Playground[/li]
[li]note the existence of computed properties (and the convention for declaring getters/setters)[/li]
[li]how to declare a human-readable dump of a class or struct (though I had trouble extending this)[/li][/ul]
If you were able to grasp must of the above without focusing too much on the physics aspect of the sample problem, then you should be pretty well set.

But I hear what you’re saying. Had it been an example from accounting talking about net present value, my eyes likely would have glazed over very quickly.

NO! NO! NO! Velocity, i.e. the distance you travel in a given amount of time, is measured in m/s. “I was doing 60 miles/hour” is a velocity. Acceleration is the change in velocity per a given amount of time, and as a result the units for acceleration are??? Well, a change in velocity would be something like:

and that change in velocity occurs over some time interval, say 2s. So the acceleration would be:

[code] 4 m/s

  2 s

Which is: 2 m/s/s or 2 m/s^2. Okay?!

I saw that Physics example while glancing over the book at the book store, and I thought, “Oh, brother!”. You don’t complicate GUI programming, which is complex enough on its own, by introducing Physics into the mix. There are also lots of jarring grammatical errors in the text. Y’all might want to learn the difference between the words “since” and “because”–they are not interchangeable. For example:

Compare that to:

I don’t fault the Big Nerd Ranch guys for being good programmers but lacking in writing skills. However, if they are going to sell books then they need to hire an editor who can compensate for their deficiencies. From what I saw in the first three chapters, the editor for this book was not up to the task. But…I do plan on buying the book, so my criticisms are not fatal.

On the programming side, I especially liked how right from the start they dispensed with Xcode’s default project setup, and in its place created the following setup:

…as described here:

mikeash.com/pyblog/friday-q … llers.html

Strictly speaking that’s not a velocity since directional information is absent. However, 60 miles/hour due east is a velocity - speed plus direction.

NO! NO! NO! Velocity, i.e. the distance you travel in a given amount of time, is measured in m/s. “I was doing 60 miles/hour” is a velocity. Acceleration is the change in velocity per a given amount of time
Correct…which is why the original quote didn’t stop at m/s:

Meters per second per second (which, at least to me, has more meaning than saying “meters per second-squared”).

But I guess this all just backs up the original poster’s complaint about using physics as a general topic.

I’ll second the original complaint, and as the safe landing challenge was way over my head, it would be nice to see how it’s supposed to work in the solutions…


This is the way I thought about the problem: gravity is accelerating the rocket downward, which means that the rocket’s downward velocity is continuously increasing(but all falling objects in Earth’s atmosphere have a terminal(or maximum) velocity–which I ignored). If the rocket opens a parachute, then it makes sense that the rocket will stop accelerating downwards–otherwise its velocity would keep increasing–rendering the parachute not effective enough. So, let’s just say that the parachute creates an upward acceleration that counteracts the acceleration of gravity, namely an acceleration of +9.8 m/s^2. Using those figures, you can create a simple solution in your code. Note that whatever velocity the rocket has when a +9.8m/s^2 acceleration is applied by the parachute, counteracting the -9.8 m/s^2 acceleration of gravity, will be the velocity that the rocket has when it hits the ground. If the net acceleration of the rocket is zero, then its velocity remains constant because acceleration is a measure of how much the velocity changes per second.

However, I read up on parachutes, and it turns out that a parachute will initially provide a bigger acceleration upwards than gravity’s acceleration downward–which will cause the rocket’s velocity to slow. For example, if the velocity of the rocket just before the parachute opens is -100 m/s, we know gravity is accelerating the rocket at -9.8 m/s^2 (i.e. for every second the rocket falls, its velocity is increasing by -9.8 m/s), so if the parachute initially provides an acceleration of +20 m/s^2, then the net acceleration will be:

Notice that the net acceleration is in the upward direction. Therefore, 1 s after the parachute is deployed, the change in velocity will by +10.2 m/s:

So, the new velocity of the rocket one second after the parachute is opened will be

But notice, if that state of things continued, then after 9 more seconds, the rocket would start moving upwards, i.e. its velocity would be positive. Of course, that doesn’t happen: after a skydiver pulls their rip cord they do not float upwards back to the plane they jumped out of. The reason that doesn’t happen is because as the velocity of the rocket+parachute decreases, the upward acceleration provided by the parachute decreases(there’s less air resistance at slower velocities). At some point, the velocity slows enough so that the parachute only provides an upward acceleration that is roughly equal to gravity’s downward acceleration, and thereafter the rocket falls at a constant velocity to the ground.

But of course, we bought the book to learn about Cocoa programming, not graduate level physics.