> What do other think is the reason for the slow backend adoption of Swift?
It's not different enough. All the demos I've seen of it, felt like it was mostly an "also ran" language that modernised it to be a significant improvement over Obj-C.
But I've never seen any argument for it being a huge enough improvement over C#, Kotlin or others to be worth it to switch ecosystems.
I feel differently. I read the docs when it was first released and felt it was potentially hitting the sweet spot for "static yet expressive" and "familiar yet modern". I was mainly Python at the time and the readability and clarity impressed me and those are areas where I have very high standards.
More radical languages all tend to look a bit "read only" to me but I am aware that might just be unfamiliarity on my part.
C# and Kotlin both have nice features but they are more conservative Java-likes than Swift. Swift had enough modern features and syntax to feel like it would be reward the effort learning.
But I don't own an iOS device so I'm still waiting for a use case!
.NET and JVM also have Clojure, Scala, F#, C++ to choose from, metaprogramming runtimes, and AOT compilation support (although many seem to forget about this one).
So while Swift is a welcomed improvement over Objective-C, hardly brings anything worthwile to dump either the Java or .NET ecosystems.
> C# and Kotlin both have nice features but they are more conservative Java-likes than Swift. Swift had enough modern features and syntax to feel like it would be reward the effort learning.
What does it have that Kotlin doesn't?
(As a Scala programmer, Swift and Kotlin look pretty much the same to me; as far as I can see they're both polished but conservative languages that don't fundamentally offer anything that wasn't in OCaml)
They're pretty similar on the surface but Kotlin is a bit hindered by it's Java legacy, generics are better in Swift (and for example C#) because of that. Swift has associated values with enums, Kotlin can assign a value to a variable with a when (switch) statement. Swift uses more pass by value, Kotlin does a lot more pass by reference. Kotlin has Java's form of garbage collection, Swift uses ARC. ARC is simpler to predict but can induce a performance penalty.
I don't think Kotlin has any form of the "ugly C" API Swift has.
Swift is a bit more secure in terms of "it compiles, it works" than Kotlin, but Kotlin is definitely a huge improvement over Java.
As someone who writes Kotlin and Swift on a regular basis, the Java bits that leak through to Kotlin are quite frustrating at times. If you picked up the language without a feel for Java’s quirks (as I did), Kotlin feels somewhat finicky and temperamental compared to Swift.
In contrast, Swift has done an excellent job of making a real clean break from its Obj-C predecessor, despite sporting full Obj-C interop. It has for most practical purposes none of Obj-C’s quirks for pure Swift code, which is great.
I frequently find myself wishing that Kotlin shared Swift’s level of independence from its predecessor, or that I could just use Swift instead. While Kotlin isn’t a bad language, its ties to Java leave me less than enamored.
> generics are better in Swift (and for example C#) because of that
Disagree. Reified generics let you write functions that do different things based on the runtime type of an object, but such functions are confusing to a reader and best avoided.
> Swift has associated values with enums
Java/Kotlin style enums are my favourite from any language, since they're first-class objects; you can give them a value in a field if that's what you want, but you can also have them implement an interface etc.
> ARC is simpler to predict but can induce a performance penalty.
In the general case ARC has the same pause problems as traditional GC, since you can't tell when one reference is the last living reference to an arbitrarily large object graph.
> Swift is a bit more secure in terms of "it compiles, it works" than Kotlin
How so? If anything I'd have expected the opposite.
Fair enough. Looking into it, swift's "associated values" sound super weird; it seems like it means you can have multiple distinct instances for the same enum case, which breaks what I'd expect an enum to be. In fact an enum with associated values sounds more like a sealed class - both those concepts exist in Kotlin, but they're different and the difference is useful.
Like I said, you can write the same kind of thing very easily in Kotlin by using a sealed class - your example would translate line-for-line. It's a useful feature. But it's very confusing to call it a kind of enum rather than as a kind of class; as your other post acknowledges, it means Swift essentially has two different things that are differently implemented but both called "enum".
>C# and Kotlin both have nice features but they are more conservative Java-likes than Swift. Swift had enough modern features and syntax to feel like it would be reward the effort learning.
What necessary modern features do you feel Swift has and C# doesn't?
It's not different enough. All the demos I've seen of it, felt like it was mostly an "also ran" language that modernised it to be a significant improvement over Obj-C.
But I've never seen any argument for it being a huge enough improvement over C#, Kotlin or others to be worth it to switch ecosystems.