Archive for February 26, 2019

Tuesday, February 26, 2019

When to Adopt Swift

Marco Arment:

Add up all of the time you’ve spent learning Swift from scratch, accommodating its strictness, fighting its buggy tools, migrating your code through language changes, and re-learning APIs and conventions as they’ve changed over the last 5 years.

I’ve spent zero time doing that.

I’ll jump in when it’s so old, boring, and slow-moving that nobody bothers to tell people to move to Swift because they’re all busy geeking out and fussing over a newer language.

[…]

I know the basics. I’ve written a few thousand lines of Swift, including an entire simple app. I just choose not to write it the vast majority of the time.

I think migration is no longer much of an issue. The tooling is still buggy but getting much better. However, there is absolutely a time cost, and you have to think about what you’re trying to do. Is it worth switching if you’re going to write Objective-C-style code in Swift? One could argue that’s the worst of both worlds. Learning to really take advantage of Swift is rewarding but takes time. And you’re limited in how Swifty you can be if you have an existing Objective-C codebase. For a new app or a major rewrite, I think most developers should bite the bullet. In other situations, it’s less clear. We don’t know yet whether Apple is going to redesign its APIs for Swift, although Mojave’s Network framework is an interesting example of functionality that’s available in both languages but second-class in Objective-C.

Craig Hockenberry:

Another thing I’ve noticed: type safety slows down the prototyping stage where you just want it to work, not be perfect. Quick and dirty leads to great experiences.

(I’ve switched back to Obj-C, too.)

I think it really depends on the type of code. In some cases, particularly at the model and with algorithms, I feel like I’m going much faster with Swift. There’s less boilerplate, the standard library offers a lot that Foundation doesn’t, and the strong typing helps with both thinking and refactoring. But other times, particularly when interacting a lot with Cocoa, it can feel like it gets in the way. There are impedance mismatches and blind alleys. Some of this can be smoothed over with more code.

Ken Kocienda:

💯. I think the most underrated productivity metric in programming is the time it takes to make one iteration. I work hard to keep this cycle time short and cheap. More iterations produces better results.

Craig Hockenberry:

I had high hopes that playgrounds would speed up iteration. That’s been a bust: either inexplicable errors or slower than just compiling some test code.

Unfortunately, this has been my experience as well.

Ken Kocienda:

Learning Swift didn’t teach me anything new about how to think about my programs. It didn’t expand my mind. What’s more, its type safety hinders some of the ad-hoc flexibility that helps when writing the kinds of UI programs I typically write.

Over other languages, Swift doesn’t help me with what’s actually hard about writing code: thinking through exactly what I want to happen. Once I know that, writing the code is mostly a matter of idioms, conventions, tooling, and richness and availability of good libraries.

I didn’t find Swift mind expanding in a theoretical sense, as it mostly brings together ideas that had already appeared in other languages. But it absolutely is in a practical sense because it makes these tools available for real-world code, written in a platform-blessed language. It also refines them in ways that make them more approachable.

Jeff Johnson:

It feels like a cult. Swifters can’t leave well enough alone. They’re morally repulsed if you’re not using Swift, and they have to knock on your door and convert you to the faith.

Rory Prior:

Marco’s reasons are perfectly valid for him, but they really only apply to indie developers or people who get to make the call about the language used for projects, being a Swift refusenik is career suicide otherwise.

Colin Cornaby:

Still confused by the amount of fuss over Marco’s tweet about Swift. No one is cancelling Swift just because Marco isn’t using it. Him holding off on adopting Swift doesn’t threaten anyone else. He’s just doing what he thinks is most responsible for his product.

[…]

Also:

“Swift is super easy to learn way easier than Obj-C so easy kids are learning it on their iPads”

“But if you don’t learn it now you’re going to be forever behind and never useful as a developer again”

It’s relatively easy to learn the basics, but it takes a long time to master. In a sense, everyone is always behind those who started learning any language before them. But learning is not linear, and also there are any number of other things to learn besides a particular language. No one is ahead at everything. The question is what it’s most important for you to learn now.

Brian Webster:

Swift:

(lldb) expr -l Swift -- import PowerPhotos
(lldb) expr -l Swift -- let $view = unsafeBitCast(0x600003b132c0, PowerPhotos.IPPhotoSelectionView.self)
(lldb) expr -l Swift -- print($view.description)

ObjC:

(Lldb) po [0x600003b132c0 description]

Dave DeLong:

Add this to your ~/.lldbinit:

command regex objc 's/^(.+)$/expr -O -l objc++ -- %1/'

Now you can do:

(lldb) objc [0x600003b132c0 description]

Dave Lee:

Another option is overloading po to provide custom behavior for memory addresses:

command regex po
s/(0x[[:xdigit:]]+)$/expr -lobjc -O -- %1/
s/(.+)/expr -O -- %1/

This makes po’ing 0x76543210 treat it as objc. Any other expression gets default po behavior.

Previously: On My Misalignment With Apple’s Love Affair With Swift.

Update (2019-02-27): Vadim Shpakovski:

Open-source libraries written in Obj-C are slowly dying. They’re not maintained or authors rewrite them in Swift. This trend is probably unstoppable. And if your code uses third-party components, you literally have no choice.

App Store Subscription Notifications and Promotional Offers

Apple (via Ryan Jones):

When written thoughtfully, notifications can help users want to keep their subscriptions. To create a positive experience that subscribers engage with, make sure your notifications serve a clear purpose and deliver meaningful information. For example, when you update your app, consider letting subscribers know about new content that they may be interested in. Or, you might send encouraging notifications that remind subscribers to perform a task in your app that they have committed to doing. Notifications should not be used as a reason to launch the app or for advertising, promotional, or direct marketing purposes.

[…]

Apps with auto-renewable subscriptions will soon be able to offer a discounted price for a specific duration for existing or previously subscribed customers. These offers provide the flexibility to create unique promotions to grow and retain your customer base. They can help win back subscribers who have canceled their subscriptions or promote an upgrade to another subscription at a special price. Once the promotional period ends, the subscription auto-renews at the standard price.

Previously:

Update (2019-02-27): Samuel Axon:

In the past few days, Apple has informed developers that they will now be able to target current and recent subscribers with promotional rates on subscriptions. That means subscribers will be able to offer discounts to try to get you back if you lapse, or they might try to entice you to stay if you're considering leaving.

Developers could previously offer limited-time subscription discounts but only to new users. The new model is available in recent beta releases known as iOS 12.2, macOS Mojave 10.14.4, and tvOS 12.2, and it is likely to emerge as the final public release for each. Apple will facilitate three different types of offer for developers who want to retain or regain subscribers.

Update (2019-03-28): Apple:

Using receipt validation, you’ll be able to identify subscribers who have turned off auto-renewal so that you can act quickly with the right offer and win them back before the end of their current subscription period. You can also start thinking about win-back and upgrade campaigns that make sense for your business, and what each user journey looks like.

Apple Music for Google Home

Joe Maring:

Google Home/Assistant speakers already have access to a solid selection of integrated music streaming services, including the likes of Spotify, Pandora, YouTube Music, Google Play Music, and Deezer.

Now, it looks like Apple Music will soon be joining the ranks.

Initially spotted by MacRumors and later confirmed by myself and Phil Nickinson, there’s now an option for Apple Music in the Music section of the Google Home app.

Previously:

Update (2019-02-27): Stephen Darlington:

People outside the US are still waiting for Apple Music on Amazon Echo…