Hacker News new | ask | show | jobs
by taharvey 2382 days ago
What part of Swift being as fast as C++, as safe as Rust, and with the functional type system of Haskell (but actually useful in the real word) is unappealing?
1 comments

I don’t have the time to dive into specifics like the other comments are asking for, but I can say that all three of these claims are false. Swift has significant performance penalties for a lot of its functionality; Rust is significantly safer and lower overhead (Swift doesn’t do anything about thread safety or mutable aliases, for starters); and Swift’s type system, as far as I know, is not as advanced as Haskell’s (and also significantly less ergonomic when it does match functionality, imo.)

I will say that I think the language made compromises in all three of these directions, though.

I would encourage you to look deeper.

1. We've moved our company code base from tight C/C++ code to Swift. It is just as fast, with higher level syntax. In some cases faster. It has native SIMD types without external libraries too. Moreover, the Swift group has been focusing on correctness over performance to date. The goal has always been, that its deeply typed design can enable optimizations not even possible in c/c++.

2. Several of the founding Rust team moved to the Swift dev team years ago. As of Swift 5, the memory model supports the Rust-like borrowing. One could say Swift at this point is a complete superset of Rust. But, more importantly Swift favors a functional style of value type operations... which are inherently memory safe, and have no concurrency side effects in the first place. Value types together with Swift's very easy to use Dispatch concurrency library work for most use cases... it is viewed that "borrowing" is only a special purpose opt-in feature.

3. Swift is pragmatic. It is functional in its type system, value type operation, and no side-effect philosophy. But it is multi-paradigm, flexible, and designed for the real-world problems that reflect real programming needs... where as Haskell is arguably an academic curiosity and extremely unlikely to become a mainstream general purpose language.