Live data from Hacker News

What’s new in Swift 6.2

hackingwithswift.com

21–30 of 258 posts

Re: What’s new in Swift 6.2

#21
post #5

> 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…

The feature is fine but there are better reasons to introduce it.

For macro generated code it is convenient to use identifiers that people won't accidently use in their own code. The ability to use arbitrary identifiers solve that.

Re: What’s new in Swift 6.2

#22
post #5

> 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…

I don't know about other languages but Ruby is similar in that you can name a function with any string (though you might not be able to call it in the standard way) and the Rails default test framework takes advantage of that.

https://tio.run/##S87JLC74/18jJTWtNE@hJiM1JydfoTy/KCelRkFDk0...

Common Lisp allows it as well, though I don't think I've ever seen it done outside a demonstration that it can be done.

Re: What’s new in Swift 6.2

#23
post #3

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?

I use it as a C++ alternative on Linux. We ported a substantial code base from C++ to Swift last year and it works great. Performance is better in some places, comparable to C++ in others. Productivity is definitely improved over the C++ codebase. We didn’t use rust for this project after evaluating how that migration would impact how it was designed internally, and we decided it wasn’t the right way to go. I think the “swift is only relevant in apple ecosystem” view is inaccurate these days. Swift certainly isn’t the answer to every project, just like rust or any other language isn’t the universal answer to every project. It’s worth considering though if it is appropriate.

Re: What’s new in Swift 6.2

#24
post #5

> 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…

The feature is fine but there are better reasons to introduce it. For macro generated code it is convenient to use identifiers that people won't accidently use in their own code. The ability to use arbitrary identifiers solve that.

Except people can also use arbitrary identifiers in their own code now?

Re: What’s new in Swift 6.2

#25
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.

Re: What’s new in Swift 6.2

#27
post #25

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.

So it's becoming C++?

Re: What’s new in Swift 6.2

#28
post #27
post #25

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.

So it's becoming C++?

Considering Swift was primarily written in C++, perhaps Swift was always destined to follow the same path?

Re: What’s new in Swift 6.2

#29
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.

Re: What’s new in Swift 6.2

#30
post #25

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.

I too wish deprecation with migration path was a more common pattern in today's language development. The language has very much needed work and the numerous bugs within Apple's own libraries certainly hasn't helped.

That said, some of the, erm, "new ways" to solve problems have been significant advancements. EG: Async/Await was a huge improvement over Combine for a wide variety of scenarios.

Post reply on HN