←back to thread

612 points dayanruben | 1 comments | | HN request time: 0.202s | source
Show context
sgt ◴[] No.42899856[source]
Is Swift actually serious about embedded?
replies(6): >>42899910 #>>42899953 #>>42900093 #>>42900473 #>>42901728 #>>42905236 #
timsneath ◴[] No.42899910[source]
Of course! Tons of examples here: https://github.com/apple/swift-embedded-examples

At WWDC24, we shared a session on embedded Swift, which is available on YouTube: https://www.youtube.com/watch?v=LqxbsADqDI4

More documentation on embedded Swift tooling here: https://github.com/swiftlang/swift/blob/main/docs/EmbeddedSw...

(Disclosure: I work at Apple.)

replies(5): >>42900254 #>>42900260 #>>42900653 #>>42901449 #>>42901605 #
sgt ◴[] No.42900260[source]
Swift is unbelievably cool but I wonder about using Swift for an embedded project as opposed to just C or with FreeRTOS for a more capable system. Is interoperability possible - as in FreeRTOS+swift?
replies(3): >>42900529 #>>42900551 #>>42900720 #
1. aseipp ◴[] No.42900551[source]
For the most part, yes, it should be very achievable. Embedded Swift basically just produces an object file that looks like any object file from a C compiler. The objects mostly rely on very basic primitives like malloc/memcpy so it's pretty freestanding (you can turn off allocations, too). It also has very good support for importing C headers into Swift code so you can interop easily.

Probably the biggest roadbump for something like FreeRTOS is the asynchronous support though. Embedded Swift's async support is still extremely rudimentary and I didn't find much about how to extend it/attach it to other control loops. I think it only supports single-threaded execution right now as well.