123 points · by andrekandre · 5y ago · 49 comments
Bit of a tangent, I suppose, but I was disappointed to see that the actor implementation continues enlarging the C++ core of the language. I also think that combines with the fact that the project is, in reality, controlled by Apple and not truly open, to create an extraordinarily high bar for contribution.
I think the very narrow needle it's trying to thread between its base case as a GUI applications environment and other types of programs may end up dooming it. You can't please all the people all the time...
It looks like Swift is taking pointers from Rust. Specifically Rust's send/sync traits. There's even other keywords like unsafe in Swifts new `UnsafeSendable` for Sendable types that bypass compile time checks.
[0] https://old.reddit.com/r/rust/comments/7qels2/i_wonder_why_g...
Surely you meant borrowing.
Rust might have brought many interesting concepts into mainstream, however unsafe wasn't one of them.
Sendable is just yet another monadic type, or a ML functor.
Swift has used the “Unsafe” prefix for a very long time to indicate things that break its safety model, see for example the UnsafePointer APIs.
By this token, actors seem to be the language-level implementation of a class where all methods are asynchronous, and also being protected by the same lock.
The novel feature seems to be cooperative scheduling amongst actors.
My enduring impression after learning Swift Actors is that a LOT of additional complexity is introduced because of reference types. The data inside an Elixir process is just that: data, but the possibility of the data in a Swift Actor being a reference to a class suddenly makes everything complicated.
Regardless of the technical achievement from a compiler perspective I found that Swift’s Actors didn’t map well to my understanding of them from Elixir/Erlang and that they weren’t a net positive for solving the kinds of problems actors are suited for. I’ll concede this is all very personal and subjective though.
I plan to use actors enums for states in my next major app version release.
Or at least I was, until Apple decided to backdoor the iPhone in the absurd notion that it protects kids. Now I’m trying to figure out how to migrate off their platform entirely.
They also seem to have an m-to-n scheduler (not sure if in user space or kernel), so you can have more actors than “threads”.
Actors in systems like erlang seem to make concurrency simple, and the model seems to be easy to grasp.
On the contrary, a few code samples i've seen on swift forums made my mind twist trying to understand how the code was going to be executed..
This is why `await` is such an important keywords to litter around your code - anything can happen in between when you await and when you come back, including actor message processing. You could have another invocation against your actor instance happen in tandem.
This definitely increases the learning curve, but likely still saves time later when you are fighting various deadlock conditions.
pre {
background-color: rgb(40, 40, 35);
color: rgb(248, 248, 242);
}If you remove syntax colouring from a text, you do expect to still be able to read the text.
Why the difference? Because the wheel is an essential component of a car, while syntax colouring is more akin to the paint job of the car: you change change it, remove it, it won't affect the function of the car.
BTW, if we remove the CSS, the text becomes apparent again. So if we keep going with the same analogy, it becomes even more unsuitable: removing half of the wheels prevents the car from working, but removing all of them now restores a smooth ride. We quickly see how it turns absurd and contradicts.
Brand new? I thought Carl Hewitt invented Actors https://en.wikipedia.org/wiki/Actor_model
> Although what Swift brings is new to the language, it's not new to tech itself.
I think it's pretty clear that the author meant "brand new to Swift"?