News for hackers. Stuff that matters.
Re:SwiftData by jahewson on Tuesday June 06, 2023 @01:00PM (#36215820)
Looks pretty different. Much closer to more modern state management approaches such as Recoil and Jotai.
Re:SwiftData by esprehn on Tuesday June 06, 2023 @01:19PM (#36216081)
What part makes you think of Recoil? CoreData (and now SwiftData over it) are more like ActiveRecord in my experience.
Re:SwiftData by jahewson on Tuesday June 06, 2023 @04:54PM (#36218988)
Yes, that's CoreData but we're talking about this new intermediate SwiftData layer. If you think of the ORM part as just "storage" the bindings are quite Recoil-like. Take a look at `recoil-sync`, which handles querying and syncing with persistent storage.
Re:SwiftData by _trackno5 on Tuesday June 06, 2023 @01:06PM (#36215910)
I don't get what you're saying here.

Swift Data is just a framework to annotate data structures to be stored by Core Data.

It looks a lot like an ORM.

Re:SwiftData by jahewson on Tuesday June 06, 2023 @04:49PM (#36218925)
If we think of CoreData's role here as simply providing persistent storage then the annotation layer is the interesting bit - binding a persisted model to a view via a query is conceptually similar to Recoil's atoms' support for complex fetching, persistence, and offline support.
Re:SwiftData by bigtechennui on Tuesday June 06, 2023 @05:58PM (#36219618)
Thinking of CoreData as simply providing the persistence layer is incorrect. It also provides the schema. CoreData’s object graph management and persistence are separate - you can use CoreData without persistence, but you can’t use it without a schema.

The annotations are for defining the CoreData schema – i.e. the necessary piece – rather than relying on a schema definition file as one would prior to SwiftData.

There are additional syntactic niceties for SwiftUI binding, but the annotations are very much an ORM.