Archive for October 2, 2023

Monday, October 2, 2023

The Bleeding Edge of Swift Concurrency

Matthew Massicotte (Mastodon, via Juri Pakaste):

Swift Concurrency is all about succinct, safe code. Yet, it comes with a surprising amount of subtly and new pitfalls. It’s actually quite easy to accidentally introduce races and hangs. Learn about bringing async/await and actors into your code without the pain.

There’s a lot packed into this short and sweet talk. I think it’s a must-watch.

See also: Semaphore, MainOffender, Queue.

Previously:

@Model for CoreData

Helge Heß:

ManagedModels is a package that provides a Swift 5.9 macro similar to the SwiftData @Model. It can generate CoreData ManagedObjectModel’s declaratively from Swift classes, w/o having to use the Xcode “CoreData Modeler”.

Unlike SwiftData it doesn’t require iOS 17+ and works directly w/ CoreData. It is not a direct API replacement, but a look-a-like.

[…]

A CoreData object has to be initialized through some very specific initializer, while a SwiftData model class must have an explicit init, but is otherwise pretty regular.

The ManagedModels @Model macro generates a set of helper inits to deal with that. But the general recommendation is to use a convenience init like so[…]

I like this general approach, but my experience is that it’s not good to cache the NSEntityDescription. If you return it from a class method, there can be problems if you use the same managed object class with multiple managed object models or multiple instances of the same model when testing. (I avoid the similar convenience methods that are built into Core Data, too.) Maybe this has since been fixed, but I found that it worked better to specify the entity by name in the fetch request so that it gets looked up in the proper managed object model.

Previously:

Update (2023-10-09): Helge Heß:

Frohlocket, a new release of my #SwiftLang Model macro for #CoreData is out. As suggested by @mjtsai entities are not cached in the type anymore and multiple MOMs can be built from them (MOMs themselves are still cached for other methods that take PersistentModel types, like .modelContainer(for: Todo.self)). And a few more bugfixes related to optionals.

Google at 25

Google (via Hacker News):

Twenty-five years ago we launched Google Search to help you find answers to questions big and small. As we celebrate our birthday, here’s a look back at how our products have evolved over the past 25 years, from autocomplete to generative AI — and how our search for answers will drive even more progress over the next quarter century.

Forty Years of GNU and the Free Software Movement

Free Software Foundation (via Hacker News):

On September 27, 1983, a computer scientist named Richard Stallman announced the plan to develop a free software Unix-like operating system called GNU, for “GNU’s not Unix.” GNU is the only operating system developed specifically for the sake of users’ freedom, and has remained true to its founding ideals for forty years. Since 1983, the GNU Project has provided a full, ethical replacement for proprietary operating systems. This is thanks to the forty years of tireless work from volunteer GNU developers around the world.

[…]

Usually combined with the kernel Linux, GNU forms the backbone of the Internet and powers millions of servers, desktops, and embedded computing devices. Aside from its technical advancements, GNU pioneered the concept of “copyleft,” the approach to software licensing that requires the same rights to be preserved in derivative works, and is best exemplified by the GNU General Public License (GPL).

As they note, “While software has become deeply ingrained into everyday life, the vast majority of users do not have full control over it.” Open-source software is more widely used than ever, yet as a user it seems like things are more locked down than ever.

Alas, Stallman recently announced that he has cancer.

Previously:

Update (2023-10-09): Christine Hall (via Hacker News):

Officially billed as a “hacker meeting,” Biel’s GNU community pretty much pulled out all of the stops for a relatively small one-day event. The speakers’ roster included the likes of Nextcloud co-founder Björn Schießle who talked about “The Next 40 years of Free Software”; Matthias Kirschner, president of FSFE who opened the day with “The FSFE’s Work: An Overview for Free Software Hackers”; and Swiss Parliament member Jörg Mäder, who was on hand to talk about GNU Taler, GNU’s privacy-aware online payment system.

In all, the day was filled with 14 presentations if you include Stallman’s middle of the day keynote.

[…]

Stallman talked about Red Hat’s support contracts, which forbid customers from distributing Red Hat’s open-source software. He said the practice might not violate the GPL (“I don’t have a conclusive answer to that”), but that its approach is “antisocial.”

[…]

“Children sometimes can get interested in free software,” he said as an answer to his own question. “I’m afraid that there is a problem that happens once the calamity of peer pressure sets in. I was safe from peer pressure. I was completely out of popularity. I gave up on trying to be popular. I just said it’s a waste of time for me to do anything trying to be popular so I won’t bother, and so I was safe. And there are some others who are safe. Maybe we can find them and interest them in free software[…]”