Site icon ashishb.net

Swift, Kotlin, and Go

It is impressive to see the amount of similarity which exists in Swift, Kotlin and Go, the three new languages for iOS, Android, and server-development respectively.

Consider a simple, Hello World program.

Swift

func printHello() {
  // Type automatically inferred to string
  let name = "Ashish" // let declares a read-only variable
  print("Hello world from \(name)!")
}

Kotlin

fun printHello() {
  // Type automatically inferred to string
  val name = "Ashish"  // val declares a read-only value, var declares a read-write variable
  println("Hello world from ${name}")
}

Go

import fmt

func printHello() {
  // Type automatically inferred to string
  const name = "ashish"  // const declares a constant value
  fmt.Printf("Hello world from %s", name);
}

 

Exit mobile version