3 ms·
A Vision for Embedded Swift (https://github.com/apple/swift-evolution/blob/main/visions/embedded-swift.md https://github.com/apple/swift-evolution/blob/main/vis
by glhaynes 3y ago
A Vision for Embedded Swift (https://github.com/apple/swift-evolution/blob/main/visions/embedded-swift.md https://github.com/apple/swift-evolution/blob/main/visions/e...) has the details on this new build mode and is quite interesting.
Effectively, there will be two bottom layers of Swift, and the lower one, “non-allocating” Embedded Swift, will necessarily be a more restricted compilation mode (e.g. classes will be disallowed as they fundamentally require heap allocations) and likely to be used only in very specialized use cases. “Allocating” Embedded Swift should allow classes and other language facilities that rely on the heap (e.g. indirect enums).
Also, this seems to maybe hint at (most of?) the Swift runtime eventually being reimplemented in non-allocating Embedded Swift rather than the C++ (?) that it uses now:
The Swift runtime APIs will be provided as an implementation that’s optimized for small codesize and will be available as a static library in the toolchain for common CPU architectures. Interestingly, it’s possible to write that implementation in “non-allocating” Baremetal Swift.
- pjmlp 3y agoYes, the long term roadmap for Swift is to bootstrap it, minus the LLVM backend, which is always a matter of not re-inventing the optimization algorithms that half of the world is putting into LLVM, whose contributions are at similar level as the Linux kernel.