|
|
|
|
|
by fauigerzigerk
3736 days ago
|
|
Is your 'close to the metal' claim based on any concrete experience with Swift? I like Swift as a language but I found its String/unicode support way too slow for the text processing stuff I do on the server side. I also tried using arrays instead, but in my text parsing micro benchmarks Swift is always four times slower than Go, Java, C++ and even two times slower than JavaScript/V8. I don't really see a reason why this should be the case, so I hope it will improve over time. But using mandatory reference counting does limit the sort of tasks for which Swift will ultimately be suitable. I wouldn't put it in the same category as C++ and Rust for that reason. |
|
- Swift performance issues involving working with strings, some of which have been ameliorated by later releases;
- 'Hidden' bridging between NSString and String, which can be expensive and might have something to do with some of String's APIs actually being Foundation APIs in disguise.
There is much to be done with regards to Swift performance, though. If you have any sample benchmarks I would be interested in writing/running them myself, just for personal edification.
In terms of 'close to the metal', I freely admit this is a ill-defined term I am using for my own benefit. Swift code doesn't execute on something akin to the JVM or CLR; it still requires a heavier runtime than (e.g.) Rust. It is AOT-compiled to machine code. (But then again, this is possible to some degree for Java as far as I can tell, although it is certainly not the most popular way to run Java code.)
I agree that mandatory RC for classes and boxed types makes Swift impractical for a certain definition of 'systems software' typically written in C++ and occasionally Rust. For a different definition, one that encompasses the garbage-collected Go, Swift is theoretically suitable. The language designer has mentioned that he would personally like to see Swift gain some form of borrowing/lifetimes, although even if that did happen Swift would not get it for years to come.