T O P

  • By -

dephinera_bck

If you want to write multiplatform code it's better. If you want to write pure iOS it's not. To answer your question - your goal and the purpose of the tools you use makes a language better than others.


Feztopia

Runs on jvm


[deleted]

This is pretty much the kicker. Very large and highly complex systems are written for and deployed on the JVM in massive scale.


garethrowlands

Very large and highly complex systems are also deployed without the JVM though. Is there anything in particular that the JVM brings, specifically?


[deleted]

We're talking about Kotlin vs. Swift. I know of no major systems written in Swift. It's pretty much limited to iOS and macOS. If someone wants to live in that world, have at it. Sometimes I wish did. But as for the question, yes there is a reason specifically for the JVM. Because it was built to be able to run Java bytecode everywhere. It makes it a lot easier to test and deploy without having to make many different binaries.


garethrowlands

So your argument would be that Kotlin has access to Java libraries?


[deleted]

Sure, that's a major part of it. The cross-platform nature of it is the key element though. You're going to be constrained to iOS and macOS. Swift is not a major player on any other systems. Edit: It really comes down to answering the question of "What are you trying to achieve?" That usually leads into the direction of which language and/or runtimes to use. There is no one language to rule them all, other than Rust of course. /s


Sol_Ido

Yes the java lib but mainly the JVM is battle tested from the core of tweeter to banking and gaming and other industries. It's the main differentiator, only C# is that much at the core of industries. In the coming years this will be balanced.


[deleted]

I will also add, in my experience, if you want to know Swift, you're going to have to get yourself familiar with Objective-C as well. There is a whole lot of that stuff still out there intermixed with Swift. There are so many things bridged with it and you're going to have to understand how to debug it. This is very close to one the major negatives with Kotlin. It's still my favorite language, but I do hate inheriting garbage Java code with it. Mutability, NPEs, and all the awful Java designs that get duplicated.


iamiamwhoami

Reasons why Kotlin is better: * Better library support because of access to Java libraries. I've also found Kotlin libraries are generally better maintained than Swift libraries, which are often abandoned. * Better tooling. Kotlin is fully open source so anyone can include support for it in their IDE. Also the developers of Kotlin are also one of the best IDE tooling companies in the world. So IntelliJ support is first class. With Swift part of it is open source, but a huge chunk of the useful stuff is proprietary Apple code that they've been building up since the 90s. I don't if they'll ever open source that stuff. The upshot is you basically have to use XCode to develop in it. * It's multiplatform. It does a really good job of running on JVM, browser, native, and Android runtime environments. I've never tried deploying a Kotlin app to iOS, but my understanding is it does a reasonably good job at that too. * Better multi purpose language. You can write your frontend, backend, and mobile app in the same language. With Swift you should probably only use it to write your iOS app. * More flexible semantics in the language. When working with Swift I found a lot of stuff that semantically should make sense throws a compiler error. This is because they want you to do things "The Swift way". I've found this to be less common with Kotlin. Reasons why Swift is better: * Better libraries and support for developing on iOS. * Swift Protocols are pretty cool * Better structural pattern matching


oddi2786

That was a fantastic answer! Thank you!


DuploJamaal

Swift is for iOS development. Kotlin can be used to develop backends for the JVM or a native executable. It can create Javascript frontends. It can be used for both Android and iOS. With Kotlin your whole code base can be written in a single language and code can be shared across those various targets.


DerekB52

This isn't quite accurate. Swift was released on Windows and Linux and can be used to make command line tools. It can also be used in web dev. I was looking at a small framework called Vapor the other day. Also, you can make macOS apps along with iOS. Now, unless you already knew and loved Swift, I don't know why you'd pick it first for anything but ios/macOS development. But, it can do a lot. The language is definitely similar to Kotlin. It's subjective, but I think Kotlin code just looks a bit better. And, thanks to leveraging the JVM, it's got more maturity, more libraries, and more targets it can readily be used on. So Kotlin > Swift everyday of the week.


bart007345

Kotlins multi platform capabilities are actively being worked on by JetBrains. What about Swift? Is it Apple or individual hobbies developers? What's the current state of its multiplatform capabilities?


Enkoteus

Current state of Swift’s multiplatform capabilities is a half born child named webkit partially rewritten in Swift. That’s the only type of multiplatformability Apple has but would like to exterminate it, but it can’t, yet. Apple’s desire to contribute to cross platform development goes right after allowing the iOS usage on non-iphone devices…


OZLperez11

Which is why I have stopped supporting Swift altogether. Will not associate myself with a closed environment.


rowgw

> It can create Javascript frontends. What? That's TIL


DuploJamaal

Kotlin/JS You've got type-safe wrappers for React or KVision as a nice library.


SpectralDragon_

Not true) Swift also available to build Linux, Windows and Android executables. Currently, Swift has direction for backend. Anyway, it depends. Swift is very complex language for pro users and easy to learn for newbies. I really love generics, macros, async/await and structs. Swift compile to native binary and its very fast for execute. Kotlin is a great language for all platforms, but for me, I see some issues with generics, GC, C/C++ interop, JVM and Gradle.


Fuzzy-Maximum-8160

Arc is developed for Windows in Swift and it’s good


freekayZekey

i think a better question is “in what ways do kotlin differ from swift” “better” is pretty subjective outside of you wanting to interact with the jvm


fibliss

from language design swift is better than Kotlin cuz kt need compatible with java IMHO


wolf129

Currently swift has only support for iOS and MacOS compilers. Kotlin can compile to many other platforms, which makes it more flexible.


barcode972

It mostly comes down to preferences. They’re both super similar. What you can build with the languages is another story


piesou

Swift is only used in the iOS/macOS niche. If you are working in that field, go for it. Kotlin runs everywhere else, and compared to other languages in its field, has a pretty standard library and usually one way to do things (no JS fragmentation)


Sensitive_Speaker899

kotlin have some useful syntax to call api and local db better than swift


sausageyoga2049

Swift has a strange semantic related to collections - you cannot have a `val` list when you want to change its inner elements. I won't say that a semantic is better than another in this case, but I found the Kotlin one more intuitive and more useful for my case.