Fun with Kotlin, Func with Swift!
By Mike Irving - Published: 4/11/2019

After nearly two decades as a professional software developer, I have had the opportunity to code in a variety of languages.

Constants throughout most of this time, have been both C# and JavaScript, perhaps testament to my work in Web Development.

In the past decade, I have also spent much of my time as a Mobile Software Developer, and have worked in many flavours from Native, to Xamarin / C#, and Cordova / HTML 5 Apps.

Whilst I'd often utilise, and champion, such approaches as Xamarin.Forms for Cross-Platform mobile dev, I also understand the performance benefits, and eco-system benefits, or writing pure native code, in the languages offered by the platform providers, namely Apple and Google.

Whilst I have spent many years coding in Objective-C for iOS, and Java for Android, I have had the pleasure this year of working on a new mobile app project for a local business, and we decided to go fully-native, with both Swift on iOS (in Xcode) and Kotlin for Android (in Android Studio).

Whilst I have had to build two complimentary App UIs, and I have much preferred coding the user interface on iOS, I'd have to say that from a code perspective, both Kotlin and Swift have been a pleasure to use. I look forward to using both of them more as time goes on.

Both are part of a new wave of modern syntax languages, and are very similar in structure and power.

As an example, I've included some brief code samples below, encompassing variables, and a function. Hopefully you can see, at a glance, how similar and interchangeable they are. A huge advantage when working multi-platform!


KotlinExample.kt

val myLanguage = "Kotlin"
fun IsMyLanguageFun(language : String) : Boolean {
    return (language == "Kotlin" || language == "Swift")
}
var result = IsMyLanguageFun(myLanguage)
println(result) // true - Kotlin is fun


SwiftExample.swift

let myLanguage = "Swift"
func IsMyLanguageFun(language : String) -> Bool {
    return (language == "Kotlin" || language == "Swift")
}
var result = IsMyLanguageFun(language : myLanguage)
print(result) // true - Swift is fun



View Blog Entries...
Page: 1, 2, 3, 4, 5, 6, 7, 8