@mattiem@mastodon.social
@mattiem@mastodon.social avatar

mattiem

@mattiem@mastodon.social

macOS/iOS ⌨️, outdoors 🏔, justice ⚖️, games 👾

Pretty into open source. Previously: Crashlytics, Apple

This profile is from a federated server and may be incomplete. Browse more on the original instance.

mattiem, to random
@mattiem@mastodon.social avatar

Got a great question about keeping some code compatible with complete checking both off and on. It is hitting a very tricky case involving a compiler bug with default values. Here's a little explaination along with a possible solution.

A nonisolated init is one of those things that just keeps coming up as a useful trick.

phill, to random
@phill@mastodon.notsobig.co avatar

it's not right but it's okay

mattiem,
@mattiem@mastodon.social avatar

@phill No but it totally is right! Actors are not threads.

mattiem,
@mattiem@mastodon.social avatar

@krzyzanowskim @phill It uses the main thread to achieve its isolation. And the distinction might seem pedantic. But you don’t have to be afraid of using the MainActor, or think of it has a bottleneck.

mattiem,
@mattiem@mastodon.social avatar

@krzyzanowskim One way to protect mutable state is to guarantee that it is only ever accessed on one thread. That’s what the MainActor does. But it is not, itself, a thread.

mattiem,
@mattiem@mastodon.social avatar

@krzyzanowskim That is all true. Are you trying to say that you believe the MainActor is a thread?

mattiem,
@mattiem@mastodon.social avatar

@helge @krzyzanowskim I often make a very clear distinction between “thing that runs code” and “thing that does synchronization”. It’s possible to manage all state with the MainActor, all while executing very little on the main thread. But I don’t know if that distinction is actually helpful, especially in this case where the line is so blurry.

Sorry for being confusing!

ctietze, to swift
@ctietze@mastodon.social avatar

Are there any API design best practices about error handling?

So far, I sketched everything with Result<Value,Error> so I get typed errors.

But both stack unwinding and the lack of ceremony of throws is appealing, too. API consumers probably don't need fine grained detail which of the 20 error cases occurred.

mattiem,
@mattiem@mastodon.social avatar

@ctietze I think in practice, there are very few reasons why callers should care about error types. The binary worked/failed is so applicable to so many situations, and I think you have to have a very compelling reason to not use it.

mattiem, to random
@mattiem@mastodon.social avatar

Wrapped up my first official day at Apple again*, working on the forthcoming Swift concurrency migration guide. Gotta admit, so many parts of this I did not see this coming.

  • as a contractor this time, relax
tonyarnold, to random
@tonyarnold@mastodon.social avatar

Is there a way to declare via a Swift Protocol that a property must be isolated to AnyActor in Swift 5.10?

mattiem,
@mattiem@mastodon.social avatar

@tonyarnold Are you trying to express that it must be isolated to some actor, but you do not care which?

mattiem,
@mattiem@mastodon.social avatar

@teomatteo89 @tonyarnold I think this gets to the root of my question. Are you trying to force conformances to be actor types? And if so, why? Could you make the property async instead?

mattiem,
@mattiem@mastodon.social avatar

@tonyarnold @teomatteo89 I bet it does, but if you can make it async, you get all of the same protection with a lot more flexibility. Give it a shot!

mattiem, to random
@mattiem@mastodon.social avatar

Making progress in Transistor.

Kid keeps asking me to finish Jump Jump Jump in Mario Wonder and I want to throw the controller at the TV every time. But I’ve only tried maybe 10000 times so far.

Playing anything?

mattiem,
@mattiem@mastodon.social avatar

@HanBrolo I really want to play Witcher 3! But I cannot take on another 40+ hour game until I clear out my backlog a little more…

mattiem,
@mattiem@mastodon.social avatar

@MuseumShuffle @HanBrolo “40 hours” is what they call it, which takes me about 6 months too

mattiem,
@mattiem@mastodon.social avatar

@MuseumShuffle @HanBrolo yeah for sure! I don't mean how long you could play for, these numbers usually refer to how long you need to play for to complete. Witcher's estimation is here:

https://howlongtobeat.com/game/10270

ctietze, to random
@ctietze@mastodon.social avatar

Designing Actor-Based Software (with Hugh McKee) https://youtube.com/watch?v=CBUWcUuG6Ss

The examples sound great and also intuitively make sense to me as an actor noob: use data structures that support "fanning out" for concurrency.

But Swift's actor model seems to behave a bit differently, doesn't it?

At least the stuff everyone complains about feels different.

/cc @mattiem

mattiem,
@mattiem@mastodon.social avatar

@ctietze I didn’t watch the whole thing. But no, “actors” in this context are not the same thing as Swift concurrency actors and this has tripped up a lot of people.

airspeedswift, to random
@airspeedswift@mastodon.social avatar

// Only access this property via the queue

Narrator: but it was not only accessed via the queue

mattiem,
@mattiem@mastodon.social avatar

@airspeedswift Someone should really make some kind of language feature to help with problems like this.

ctietze, to random
@ctietze@mastodon.social avatar

ChimeHQ has 69 repositories.

Nice. @mattiem

mattiem,
@mattiem@mastodon.social avatar

@ctietze Just 31 more to go!

mattiem,
@mattiem@mastodon.social avatar
mattiem,
@mattiem@mastodon.social avatar

@icanzilb @ctietze Sure why not!

mattiem, to random
@mattiem@mastodon.social avatar

It's very common to have trouble with SwiftUI's EnvironmentKey/PreferenceKey protocols and strict concurrency.

I've updated the protocol section here to include a few techniques that work well for any static let in a non-isolated protocol.

https://github.com/mattmassicotte/ConcurrencyRecipes/blob/main/Recipes/Protocols.md#static-variables

mattiem, to random
@mattiem@mastodon.social avatar

Brain stopped making smart. Added caffeine but no more smart come out. Added even more. Still no smart! How make more smart?

charliemchapman, to random
@charliemchapman@mastodon.social avatar

For anybody who's curious: here's a comparison of the 2024 11in iPad Pro vs the 2018 with the Magic Keyboard and the Keyboard Folio (RIP 😢)

image/jpeg

mattiem,
@mattiem@mastodon.social avatar

@charliemchapman iPad sandwiches

ctietze, to random
@ctietze@mastodon.social avatar

@mattiem I thought about multiple cursors some more.

Given N cursor locations, an Insert("Foo") command would need to apply the change to the text storage from back to front in all N locations.

Isn't that it?

I'm almost done with the single cursor approach.

I can apply Insert and Delete commands as depicted, and change the selection declaratively.

Tomorrow I'll implement the execution of the whole command value. Pretty excited!

Would this be useful for you with 2+ cursors?

mattiem,
@mattiem@mastodon.social avatar

@ctietze I think you are getting it.

My text mutation system is really complex, involves scheduling and deferred non-visible work. But my own personal use-case may not matter! I still think this is a neat concept.

mattiem,
@mattiem@mastodon.social avatar

@ctietze No not yet unfortunately. This was an area I’m working on changing. I think it may be my next focus. Plus it’s all under my control so I can change it!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • kavyap
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • tacticalgear
  • khanakhh
  • Youngstown
  • mdbf
  • slotface
  • rosin
  • everett
  • ngwrru68w68
  • Durango
  • provamag3
  • InstantRegret
  • cubers
  • GTA5RPClips
  • cisconetworking
  • ethstaker
  • osvaldo12
  • modclub
  • normalnudes
  • anitta
  • tester
  • megavids
  • Leos
  • lostlight
  • All magazines