What’s new in Swift 6.2

hackingwithswift.com

185 points by ingve 7 days ago


travisgriggs - 7 days ago

Honest question. Not trying to troll. One of the pitches in the earlier days was “C/Objective-C OK, but you can’t write safe/next level code with it—-Swift will close that gap.”

N years later, it doesn’t feel like there has been a step change in Apple software quality; if anything Apple software feels less solid, and looks cool “look what I did” extension points. I mean, some of the tings you could do with runtime categories, and runtime prototypes were really cool. Now when I work on my 2 apps that originally happily port to Swift/UIKit, I’m just left confused with how to make things work. I’m happy when it finally works, and don’t ever try to improve the thing, it’s too much work.

There’s lots of different variables at play here; I’m not trying to stretch inference too much. Heck, it could have been that with adding Swift to the mix, the forces that have contributed to reduced quality in Apples stuff would be even worse.

I’m just frustrated. When I work in Elixir, I’m like this is cool. When I work in Kotlin, I don’t feel like “Apples got a language like this too, but it’s got that extra special zing that used to make stuff Apple touched cool.”

w10-1 - 7 days ago

The article doesn’t give enough attention to the glacial but steady changes in the ownership model that will have great benefit in avoiding copies in value types, Swift’s strength and Achilles heel.

I have to say Paul Hudson has almost single-handedly taken over communicating the essentials of Swift to the world; he’s fantastically reliable, brief but enthusiastic, guiding people around the many pitfalls.

sedatk - 7 days ago

Free-form identifiers are neat for test-case naming, but not for `HTTPStatus.`404``. I think having `HTTPStatus.Error404` was a bad idea to begin with. Just use semantic names like `HTTPStatus.NotFound` and you wouldn't have a problem in the first place. Now, a single character typo can easily make a 404, 403 and create a bug. It's less of a problem with semantic names.

If you want constrained numeric types in Swift, that's another problem to tackle. But `HTTPStatus.`404`` seems to be the least ideal way to go about it. It lets you do stuff like to declare `HttpStatus.`404`` with a value of 403 too.

finalfantasia - 7 days ago

“Swift has turned into a gigantic, super complicated bag of special cases, special syntax, special stuff…”

— Chris Lattner, 2024

https://blog.jacobstechtavern.com/p/apple-is-killing-swift

trevor-e - 7 days ago

Lot of nice improvements here. I'm actually quite liking the async API after using it in a couple small apps and learning the fundamentals.

I really wish the entire Swift team would spend a quarter fixing bugs and improving the compiler speed, though. So many trivial SwiftUI cases trigger the "this is too complex for the compiler" errors which are so frustrating to fix.

catapps - 7 days ago

I've been starting to use Swift again lately after like four years, and while the language is beautiful & the package management story is now a LOT better with SwiftPM, I found that none of it plays nicely with XCode, Simulator, or anything to do with iOS/macOS development -- its primary use-case!

I found myself awestruck that I *HAD* to use XCode or xcodebuild, and could not just run `swift build` and generate an iOS app.

In the end, I had to:

- compile the .app structure myself

- run codesign manually

- manage the simulator manually

- bundle xcAssets manually

- provide swift linker flags manually targeting the toolchain/sdk I needed

- manually copy an embedded.mobileprovision

It was a good learning experience, but what's the story here? Did Apple just give away Swift to the OSS community and then make no ongoing effort to integrate their platforms nicely into the non-xcode build tooling? Looking into https://github.com/stackotter/swift-bundler

jmull - 6 days ago

It sure feels like Swift governance is broken.

They're just shoveling stuff in to the language.

Individually, most items aren't so bad, but collectively they've got a mess and it's getting bigger fast.

None of the decision-makers seem to have the sense or incentive to say "no" to anything.

It's sad, because the language had such promise and there are some really nice things in there.

Well, at least it's relatively easy to avoid or ignore.

monkeyelite - 7 days ago

> InlineArray does not conform to either Sequence or Collection

Why not? Does this mean I need to make a struct which wraps InlineArray and implements Collection? Why didn't they do that?

EDIT: found the answer (I still have concerns):

> While we could conform to these protocols when the element is copyable, InlineArray is unlike Array in that there are no copy-on-write semantics; it is eagerly copied. Conforming to these protocols would potentially open doors to lots of implicit copies of the underlying InlineArray instance which could be problematic given the prevalence of generic collection algorithms and slicing behavior. To avoid this potential performance pitfall, we're explicitly not opting into conforming this type to Sequence or Collection.

nhojb - 7 days ago

Swift is collapsing under the weight of its increasing complexity. So many, many special cases & they keep adding more!

As a developer it becomes so very hard to reason about code behaviour. This is especially true with concurrency, which was meant to simplify concurrent operations, but in actual fact is a nasty can of worms. In an effort to "hide the complexity" it just introduces a huge amount of unexpected & hard to grok behaviour. The new "immediate" Task behaviour & non-isolated async behaviours are good examples of this.

viktorcode - 6 days ago

Spans and inline arrays are the two missing pieces of performance puzzle Swift needed. I'm super hyped for the release!

amichail - 7 days ago

Do you try to put everything on the main actor to dramatically reduce your debugging time?

bsaul - 7 days ago

Coding in both swift and rust is really a funny experience. It's like two roads being built going toward the same city, but starting from widely different places.

Hashex129542 - 7 days ago

Mostly nonsense updates.

Swift was my favorite programming language after C++/Java since 2014. I've been faced major updates few times happily. It was one of the most easiest language. But now,

I tried to update a project from Swift 5.x to 6.x which has 150+ source files itself and no external libraries which is written by my own use and it has almost all swift 5.x features. They made up Swift as super hard. I decided not to use Swift 6 anymore and yes I don't need to reduce debugging time, Even though I don't have powerful computer and debugging time isn't matter to me & development time is actual matter to me.

The language itself becomes Rust (the programming language using by aliens). I Hope Swift language is upgrading itself for Aliens or the Swift team is filled with Aliens. Now, I feel ObjC is super easiest language than Swift.

PS: I understand Swift is Corporate Product & upgrading towards SwiftUI than general purpose programming language. I never gonna use Swift 6 even I do use ObjC for my projects.

synergy20 - 7 days ago

read news about rust and swift these days, it seems modern c++ might keep its dominance for the future

ardit33 - 7 days ago

Swift is amateur hour in action by academics that don't value practicality. The new Concurrency was ill thought, and done by people that just perhaps either don't have enough practical experience, or are so enamored with the actor paradigm (erlang) that they had to shove it down the throat in a ecosystem where it is not used that much. No one is really using Swift for distributed programing.

Glad they are backtracking on this, and I hope they start remove features and simplifying things. Swift's enemy is its own self and the people steering int into just an academic exercise, rather than a practical and performant language that can be used in many domains. Server side Swift right now is dead due to all these insane changes.

Hopefully things get better on the server/other non ios domains, but the language needs to get simplified and become practical and fun to use.

- 7 days ago
[deleted]
xmorse - 6 days ago

does it really matter if it takes 1 hour to compile?

DidYaWipe - 7 days ago

"a new Observations struct that is created with a closure, and provides an AsyncSequence that emits new values whenever any any @Observable data changes"

Is this another asinine onChange()-style mechanism that actually means WILL change? In other words, it tells you BEFORE the value is set on the object, so you can't do jack squat with it much of the time.

That's the M.O. of onChange now, which is utterly brain-dead. Gee, I've been told that a value changed in this object, so let's recalculate some stuff. WHOOPS, nope, none of the other objects (or hell, even the affected object) can take action yet because they can't interrogate the object for its new contents.

Truly incredible that they not only defaulted, but LIMITED change-detection to WILL-change, the least useful of the two choices.

90s_dev - 7 days ago

> So, rather than writing > > @Test("Strip HTML tags from string") func stripHTMLTagsFromString() {...} > > we can instead write > > @Test func `Strip HTML tags from string`() {...}

Maybe I'm just really new at programming, but this seems like an absolutely bad feature, and the example actually perfectly proves it:

You really want to name a function "Hello World!" instead of helloWorld, just so your stack traces can pass a 5th grade English class exam?

codr7 - 7 days ago

There's a lot I love about Swift, but I fear it's quickly becoming too complicated for its own good.

There are just so many ways to solve a problem now that it's more or less impossible for someone to be familiar with all of them.

90s_dev - 7 days ago

I have not looked at Swift since I last wrote some around maybe v3. I hear that it's generally not a competitor to Rust, and is only really useful within the Apple ecosystem. Why is it not more useful as a C++ alternative, since I think that's kind of what the initial goal was? Is it just that non-Apple support is new-ish and not yet matured? Or a more fundamental issue?

meisel - 7 days ago

[flagged]