by isodev · 1y ago · 0 comments
Rust, Go and others have been building WASM 0.2 support for many years, they currently have a “just works” support for WASI. It would be a long time until Swift is even remotely ready for something like this and I don’t feel there is a burning need to have “yet another wasm platform”.
I agree, but I'm telling myself this is only a temporary pain caused by the changes for supporting Swift 6 language mode. Are you talking about something else?
My comment was not about that though, I was more thinking about the super slow build times, unreliable SPM with strange limitations, Xcode still shows errors while reporting a successful build, Previews not previewing, etc.
The lack of Sendable support for Combine and half-assed support on Async Algorithms only makes it more painful to transition at this point in time.
I think the pursuit of some kind of semantic purity in the Swift language overshadows more practical needs and concerns. Making Swift too different from its neighbours like Kotlin and Rust also makes it harder to context switch. It now takes a lot more time and effort to get into the flow of developing native things for iOS...
And of course the brain-dead design of withObservationTracking, which only fires on the FIRST change of a value. I mean... by what definition is that "tracking?" It's goddamned useless, unless of course you implement the clumsy workaround of re-establishing observation tracking every (first) time it fires.
Then there's the bizarre hypocrisy of evangelizing the "single source of truth" while telling everyone to prefer structs over classes in Swift. But structs are COPIED everywhere, which of course breaks the "single source of truth" on the first function call.
I wasted so much time trying to conform to these "best practices" until I finally realized that the people promoting them don't know WTF they're doing. Then I went back to classes, injected the "single source" everywhere it was needed, and got to work adding functionality.
And let's not even get into the half-assery that is SwiftUI... still, all these years later.
In retrospect, I was starstruck by the people I learned programming from, and Apple Neue funds software engineering, especially developer tooling, to the point it is not actively harmful, as opposed to not painful, and very opposed to not-harmful-and-not-painful-on-not-our-platforms.
* Of course, not for Swift 6 Language Mode™, the thing is, there's always been a Huge Project that's launching, but not landing...
I'm not comfy calling out specific names, but the sort of luminary who would have been featured on Daring Fireball over the years proposed this and took umbrage to this being pointed out at the time.
I can think of 2 off the top of my head who specifically did this, one who went on about it until they saw SwiftUI x macOS 1.0 and that became their new drum to beat on. (i.e. the quality was low)
Can confirm. I was pretty stubborn and wanted to use Go to build a UI in a webview/webview using local app, but oh my, js.Value in Go is so much pain to deal with. A lot of things in the JS world don't integrate nicely with Go as a language (e.g. the difference of Go channels and JS Promises, or magical enum values _and_ URL patterns on the same properties like in the Fetch API)
Long story short, I am now around 3 months into building a WebASM bindings and components framework, and it's still a lot of work until I am on the functionality level of TSX files. [1] All those Web/DOM/Browser APIs are kinda hard to integrate into the Go world, especially if you're as stubborn as me and want to have a real typed bindings API that uses Go's native data types.
I mean, well, it actually already exists? It's been around for a long time and works pretty great, with multithreading, access to JS objects, etc. The author of the linked thread topic is the original author of it.
Writing WASM in Swift so it can only be run by a Swift runtime also misses out on a huge aspect of that “bring your language” approach to wasm. It should support enough of the spec so a current wasm binary compiled from say Go can be executed in a WASI runtime powered by Swift and vis-versa. It’s a long way to get there.
Why are they framing it as a proposal if it's done? (if this comes across as Socratic, it is unintentional, I genuinely don't understand why the author would be posting a proposal when it is done)
EDIT: My naive reading of https://github.com/swiftwasm/swift/issues is there's a lot, lot, to go. TL;DR: open from 2021, stdio FILE not available in WASILibc. Long version, filed in 2020 and open: "Pointers needed on WASILibc", "Make the toolchain work without Xcode installed", "Enable libdispatch or provide stubs for it", 2022 "canImport(Dispatch) is wrongly truthy on WASI target", "wasm lacks signal support" (broke/regression in Sept. 2024, still open)
On macOS. Works fine on Linux.
This is such an easy ask. The only thing holding it back, imo, is Apple. Can’t let the plebs bypass Xcode to develop on their Macs!
My workaround is running a container with Linux Swift installed. Of course, I’m not targeting an Apple OS so I have the flexibility.
AFAIK, they support that. https://www.swift.org/swiftly/documentation/swiftly/getting-...:
“Overview
To get started with swiftly you can download it from swift.org, and extract the package.
On macOS you can either run the pkg installer from the command-line like this or just run the package by double-clicking on it (not recommended):
installer -pkg swift-x.y.z.pkg -target CurrentUserHomeDirectory
Now run swiftly init to finish the installation: ~/usr/local/bin/swiftly init
Swiftly will install itself and download the latest available Swift toolchain.”https://bootsharp.com/guide/llvm / https://github.com/elringus/bootsharp
But then again, we've already concluded it was a short-sighted decision.