Archive for August 9, 2017

Wednesday, August 9, 2017

Swift 5: Start Your Engines

Ted Kremenek (via Erica Sadun):

ABI stability is the center focus of Swift 5 — and we will pivot much of our prioritization of efforts for Swift 5 around it. With Swift 4, ABI stability was a strong goal. In Swift 5, it is a requirement of the release. Whatever ABI we have at the end of Swift 5 is the ABI that we will have. ABI stability is an important inflection point for the maturity of the language, and it cannot be delayed any longer.

[…]

It is a non-goal of Swift 5 to roll out a full new concurrency model. That is simply too large an effort to do alongside ABI stability. However, it is important that we start making progress on discussing the directions for concurrency and laying some of the groundwork.

[…]

After reflecting on the evolution process during both the Swift 3 and Swift 4 releases, the Core Team felt that we could strike a balance with not diluting attention from ABI stability while still enabling a broader range of proposals compared to Swift 4 by requiring that all proposals have an implementation before they are officially reviewed by the Core Team. An implementation can come long after an idea has been pitched and after a proposal has been written. However, before a pull request for an evolution proposal will be accepted — and thus an official review scheduled — an implementation must be in hand for a proposal as part of the review.

Update (2017-08-10): See also: Hacker News.

The Internet Archive Adds 25,000 78rpm Records

The Internet Archive (via Jason Scott):

Through the Great 78 Project the Internet Archive has begun to digitize 78rpm discs for preservation, research, and discovery with the help of George Blood, L.P.. 78s were mostly made from shellac, i.e., beetle resin, and were the brittle predecessors to the LP (microgroove) era.

The digitization project currently focuses on discs that are less likely to be commercially available--or available at all in digital form--particularly focusing on underrepresented artists and genres. Digitization will make this less commonly available music accessible to researchers in a format where it can be manipulated and studied without harming the physical artifacts. We have preserved the often very prominent surface noise and imperfections and included files generated by different sizes and shapes of stylus to facilitate different kinds of analysis.

Radix Sort Revisited

Pierre Terdiman:

Although the standard Radix Sort doesn’t work very well with floating point values, this is something actually very easy to fix. In this little article I will review the standard Radix Sort algorithm, and enhance it so that:

  • it sorts negative floats as well
  • it has reduced complexity for bytes and words
  • it uses temporal coherence
  • it supports sorting on multiple keys

[…]

A Radix Sort is an apparently bizarre sort routine which manages to sort values without actually performing any comparisons on input data. That’s why this sort routine breaks the theoretical lower bound of the O(N*logN) complexity, which only applies for comparison-based sorts. Radix is O(k*N), with k = 4 most of the time, and although this is not an in-place sort (i.e. it uses extra storage) it is so much faster than any other sorting methods it has become a very popular way of sorting data.

Protocol Composition in Swift and Objective-C

Jesse Squires:

Any protocol in Swift that contains optional members must be marked as @objc. I have written before about avoiding @objc in your Swift code as much as possible. When @objc infiltrates your object graph, nearly everything must inherit from NSObject which means you cannot use Swift structs, enums, or other nice features. This leaves you not writing Swift, but merely “Objective-C with a new syntax”.

[…]

A better approach is to split up large protocols into smaller ones, and provide a unique property (like a delegate) for each one.

[…]

This design transfers the “optional-ness” from the protocol itself to an additional optional property on the class. If you want headers and footers in your table view, you can opt-in to those by setting titlesDataSource. To opt-out, you can set this property to nil. The same applies to reorderingDataSource, and so on.

[…]

Instead of numerous disjoint protocols, you can design a union of protocols. This provides a single, top-level “entry point” to reference. You can extract the optional members of a protocol into a new protocol, then add an optional property for this new protocol on the original protocol. The result is a comprehensive top-level protocol and a set of “nested” protocols.