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
1
2
3
4
5
| func printHello() {
// Type automatically inferred to string
let name = "Ashish" // let declares a read-only variable
print("Hello world from \(name)!")
}
|
Kotlin
1
2
3
4
5
| 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
1
2
3
4
5
6
7
| import fmt
func printHello() {
// Type automatically inferred to string
const name = "ashish" // const declares a constant value
fmt.Printf("Hello world from %s", name);
}
|