3 ms·
Ignorant question: What other language is Swift like most? And what improvements does Swift make over that language?
by amelius 9y ago
Ignorant question: What other language is Swift like most? And what improvements does Swift make over that language?
- catawbasam 9y agoKotlin is close
- jernfrost 9y agoKotlin, Rust, Scala and vaguely Go. Swift benefit over Kotlin is that it easily interfaces with existing objective-c and C code. It also has deterministic garbage collection through automatic reference counting which is better for interactive systems and maintaining low memory footprint. Since it is native code and doesn't have a complicated garbage collector it can be used like C to create libraries for other programming languages. This is impossible to do with Go and Kotlin. Compared to Rust it is considerably easier to learn. Go is probably easier to learn than Swift but Swift is a lot more expressive. You could do scientific computations in Swift but that would be cumbersome in Go since you can't easily define matrix, vector and point types yourself.
- favorited 9y agoPeople are posting comparisons to Kotlin, but for the record here's Chris Lattner's take on the Swift/Kotlin comparison: --- Swift and Kotlin evolved at about the same point in time with the same contemporary languages around them. And so the surface-level syntax does look very similar. … But if you go one level down below the syntax, the semantics are quite different. Kotlin is very reference semantics, it’s a thin layer on top of Java, and so it perpetuates through a lot of the Javaisms in its model. If we had done an analog to that for Objective-C it would be like, everything is an NSObject and it’s objc_msgSend everywhere, just with parentheses instead of square brackets. And a lot of people would have been happy with that for sure, but that wouldn’t have gotten us the functional features, that wouldn’t have gotten us value semantics, that wouldn’t have gotten us a lot of the safety things that are happening [in Swift]. I think that Kotlin is a great language. I really mean that. Kotlin is a great language, and they’re doing great things. They’re just under a different set of constraints. ---