DEV Community

Randy Arba
Randy Arba

Posted on • Edited on

Kotlin or Swift

When everyone talking about native development or hybrid development, i just wanna talk about the programming language. Yes, for native development there was two platform, android and iOS, each of that develop with different language android for kotlin/Java, iOS with Swift/Objective-C. Okay, now i will compare kotlin and swift because there react similiar. But actually kotlin and swift have different behaviour only have similiar syntax. every of them have different pros and const and absolutely own way of thinking.

Kotlin is another child of Java language with improvement in some component in rich collection function such as map, filter, reduce, etc. But the most improvement is, when Coroutine come that make more powerfull than Java or Swift. Swift didnt have component that similiar to Kotlin Coroutine. The other hand kotlin have LLVM component that can mimic native component so kotlin can port into native OS example in macos or iOS, but kotlin native still under development because lack of performance than kotlin it self.

Swift language is completely different than kotlin, java, objective-C or maybe popular golang language. Swift has no Virtual Machine (VM). swift have similiar behaviour like C++ and Rust language. Java kotlin have reflection, have VM, Generic specialization, and arent allow to handle memory. So when there an streaming app or image processing better with C/C++ language. So compare swift with kotlin is not fair enough except compare the syntax. maybe its fair if compare swift with C++.

What do you think about that?

Top comments (5)

Collapse
 
funkymuse profile image
FunkyMuse

Swift has no data classes, does not have delegation or delegated properties, also doesn't allow annotations.

Kotlin's classes are final by default, has no struct or passing by value, doesn't have tuples, no type alias, and no guard statement/s.

Swift relies on ARC garbage collection and no it's not similar to C++ or Rust, Swift runs on top of Objective C code using llvm bit-code, so it does compile to native but has few extra steps, making it slower than C++, I don't think you can compare Swift with C++, it's definitely faster than Kotlin but that doesn't make it comparable with C++.

C++ directly compiles to machine code, but if not optimized, it can act like Java/Kotlin.

Collapse
 
leviaran profile image
Randy Arba

Very nice it's so detail, thanks for adding more pros and cons. I just write the general thing, but you awesome to add more. Yes actually other language can improve and extends to LLVM if that language can support JIT or AOT, and especially kotlin, kotlin can be native development with their LLVM, but it like you said before it same as swift kotlin native, it does compile to native with has few extra steps and making slower, but i am not sure compare the both language kotlin and swift about the performance if they do in LLVM mode. Thanks you for your comment. nice discussion.

Collapse
 
galoiswannabe profile image
galoisWannaBe

If you have a target platform in mind, go Kotlin, if that platform is Android or JVM, and Swift if your target is going to be iOS or MacOS. If your target is multiplatform, I recommend Kotlin, as Kotlin has built-in multiplatform support.

Collapse
 
leviaran profile image
Randy Arba

Yes you right, kotlin multiplatform can do that, in business logic side, in view side or UI side i think not, because IOS still use swift to write the UI.

Collapse
 
galoiswannabe profile image
galoisWannaBe

You'll definitely still be writing the UI in Swift! But you can write the UI in Swift, as well as the functions that Kotlin doesn't do! Moving in the other direction, programming for JVM, Android, etc, it quite the endeavor, though, and doesn't seem to be supported.