4 ms·
> Zig is much more suitable, because it actually addresses the readability aspect How? It doesn't look very different from Rust. In terms of readability Swift
by oguz-ismail2 9mo ago
> Zig is much more suitable, because it actually addresses the readability aspect
How? It doesn't look very different from Rust. In terms of readability Swift does stand out among LLVM frontends, don't know if it is or can be used for systems programming though.
- Someone 9mo agoApple claims Swift can be used for systems programming, and is (partly) eating its own dogfood by using it in FoundationDB (https://news.ycombinator.com/item?id=38444876 https://news.ycombinator.com/item?id=38444876) and by providing examples of embedded projects (https://www.swift.org/get-started/embedded/ https://www.swift.org/get-started/embedded/) I think they are right in that claim, but in making it so, at least some of the code loses some of the readability of Swift. For truly low-level code, you’ll want to give up on classes, may not want to have copy-on-write collections, and may need to add quite a few some annotations.
- galangalalgol 9mo agoSwift is very slow relative to rust or c though. You can also cause seg faults in swift with a few lines. I Don't find any of these languages particularly difficult to read, so I'm not sure why this is listed as a discriminator between them.
- saagarjha 9mo agoBut those segfaults will either be memory memory safe or your lines will contain “unsafe” or “unchecked” somewhere.
- galangalalgol 9mo agoYou can make a fully safe segfault the same way you can in go. Swapping a base reference between two child types. The data pointer and vft pointer aren't updated atomically, so a thread safety issue becomes a memory safety one.
- saagarjha 9mo agoThis is no longer allowed with strict concurrency
- galangalalgol 9mo agoWhen did that happen? Or is it something I have to turn on? I had Claude write a swift version of the go version a few months ago and it segfaulted. Edit: Ah, the global variable I used had a warning that it isn't concurrency safe I didn't notice. So you can compile it, but if you treat warnings as errors you'd be fine.