Archive for October 11, 2016

Tuesday, October 11, 2016

Optional Non-Escaping Swift Closures

Ole Begemann:

However, it’s impossible to create a reference cycle with a non-escaping closure — the compiler can guarantee that the closure will have released all objects it captured by the time the function returns. For this reason, the compiler only requires explicit references to self for escaping closures. This makes non-escaping closures significantly more pleasant to use.

[…]

Beginning in Swift 3, non-escaping closures are now the default. If you want to allow a closure parameter to escape, you need to add the @escaping annotation to the type.

[…]

There’s a catch to the non-escaping-by-default rule: it only applies to closures in immediate function parameter position, i.e. any function argument that has a function type. All other closures are escaping.

[…]

There’s currently no way to force an optional closure to be non-escaping, but in many situations, you can probably avoid making the argument optional by providing a default value for the closure.

Or you can use overloading.

Update (2018-06-11): See also: Jesse Squires.

We Need to Save the Internet From the Internet of Things

Bruce Schneier:

What was new about the Krebs attack was both the massive scale and the particular devices the attackers recruited. Instead of using traditional computers for their botnet, they used CCTV cameras, digital video recorders, home routers, and other embedded computers attached to the internet as part of the Internet of Things.

Much has been written about how the IoT is wildly insecure. In fact, the software used to attack Krebs was simple and amateurish. What this attack demonstrates is that the economics of the IoT mean that it will remain insecure unless government steps in to fix the problem. This is a market failure that can’t get fixed on its own.

Update (2016-11-07): Jean-Louis Gassée:

A side effect of the smartphone revolution is the emergence of a rich — but cheap — ecosystem of building block modules. Unfortunately, these modules are very insecure and, when assembled into a quick and inexpensive device, they can cause serious trouble. They already have.

A Mac OS 9 Odyssey

Richard Moss (via Rosyna Keller):

But as hard as it may be to believe in light of yet another OS X macOS update, there are some who still use Apple’s long-abandoned system. OS 9 diehards may hold on due to one important task they just can’t replicate on a newer computer, or perhaps they simply prefer it as a daily driver. It only takes a quick trip to the world of subreddits and Facebook groups to verify these users exist.

Certain that they can’t all be maniacs, I went searching for these people. I trawled forums and asked around, and I even spent more time with my own classic Macs. And to my surprise, I found that most of the people who cling staunchly to Mac OS 9 (or earlier) as a key component of their daily—or at least regular—workflow actually have good reason for doing so.

Rachel Simone Weil (tweet):

This hardcover book, published in 1997, tells the history of Apple Computer through one-off and low-run t-shirts made for internal programs, conferences, product teams, or just for fun. These shirts reflect the attitudes and culture within Apple in the 1980s and 1990s, and show off unique unreleased products and demos like SegaMac (!!!).