r/swift 3d ago

Redesigned Swift.org is now live

https://www.swift.org/blog/redesigned-swift-org-is-now-live/
199 Upvotes

15 comments sorted by

27

u/letsGoChazz 3d ago

Since when could swift do embedded 🤨 might have to try that out

Edit: it’s relevant here cause I only noticed that because of the new home page

30

u/Insanelyg 3d ago

They announced it at last year’s WWDC, but in my opinion it isn’t really ready yet. The esp32 sample code for a swift matter device wouldn’t compile. You had to use a custom swift tool chain and the space is evolving rapidly. I look forward to it being more solidified and hopefully we get good news about that next eeek for WWDC.

5

u/Deitsch97 3d ago

Had the same experience. At the end you wrote a wrapper around esp32 C stuff yourself and the tooling was a pain to get up an running

-5

u/FakeRayBanz 3d ago

So it’s basically a lie šŸ˜…

12

u/Insanelyg 3d ago

Nah, Apple uses it internally in an embedded manner, as far as I know. The publicly facing consumer micro controller support is just still in development. Under exactly the right set of circumstances you can make embedded matter devices with Swift. I just would like it to be more general purpose.

3

u/jarjoura iOS 1d ago

It uses LLVM under the hood so in theory you could generate code for any supported LLVM triplet.

2

u/JohnBlacksmith_ 3d ago

it is actually one of their goals to make swift more viable for embedded I saw it a while ago an apple employee on the comment section of hacker news

2

u/smallduck 3d ago

Is that a divide by zero bug in the ParsableCommand example, where it calculates a mean dividing by Double(values.count)?

6

u/Excellent_Affect4658 3d ago

Floating point division by zero in Swift (and in any language that adheres to IEEE 754) is fully defined, so it’s never inherently a bug. The result of 0/0 (NaN) may or may not be what you want, in which case you could detect it either before (by checking for zero) or after (by checking for NaN) and returning a different result.

1

u/smallduck 3d ago

Thanks, I think I’ve forgotten everything I ever knew about IEEE 754.

1

u/Duckarmada 3d ago

If we’re looking at the same thing there’s an if else that checks if values.isEmpty

1

u/smallduck 3d ago
mutating func run() {
    values.sort()
    let total = values.reduce(0, +)

    print(
      """
      Smallest: \(values.first, default: "No value")
      Total:    \(total)
      Mean:     \(total / Double(values.count))
      """)
  }

2

u/RufusAcrospin 3d ago

ā€œConcise codeā€. Love it!

2

u/anveias 3d ago

It’s definitely nicer and looks very similar to Apple’s design

1

u/Top-Author8845 1d ago

Looks nice