The OO Hello World in Kotlin, the "the new language from JetBrains for the JVM", is here!
Project Kotlin is a codename for a statically typed programming language compiled to JVM byte code and JavaScript.
You can see the OO Hello World series post here: http://carlosqt.blogspot.com/2010/06/oo-hello-world.html where I give some details on why these "oo hello world series" samples.
Version 1 (Minimal):
The minimum you need to type to get your program compiled and running.
class Greet(name : String) { val name : String = name[0].toString().toUpperCase() + name.substring(1, name.length); fun salute() { println("Hello, ${name}!"); } } // Greet the world! fun main(args : Array<string>) { val g = Greet("carlos"); g.salute(); }
Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
package greetprogram; public class Greet(name : String) { private val name : String = name[0].toString().toUpperCase() + name.substring(1, name.length); public fun salute() { println("Hello, ${this.name}!"); } } public fun main(args : Array<string>) { val g = Greet("carlos"); g.salute(); }
The Program Output:
Kotlin Info:
""Project Kotlin" is the codename of a statically-typed JVM-targeted programming language developed by JetBrains intended for industrial use. This is an object-oriented language” Taken from: (
http://confluence.jetbrains.net/display/Kotlin/Welcome )
Appeared:
|
2011
|
Current Version:
| |
Developed by:
|
JetBrains
|
Creator:
|
Andrey Breslav
|
Influenced by:
|
Groovy (Guillaume Laforge), C# (Anders Hejlsberg)
Java (James Gosling), Scala (Martin Odersky) |
Predecessor Language
|
N/A
|
Predecessor Appeared
|
N/A
|
Predecessor Creator
|
N/A
|
Runtime Target:
|
JVM
|
Latest Framework Target:
|
JDK 6
|
Mono Target:
|
No
|
Allows Unmanaged Code:
|
No
|
Source Code Extension:
|
“.kt”
|
Keywords:
|
31
|
Case Sensitive:
|
Yes
|
Free Version Available:
|
Yes
|
Open Source:
|
Yes
|
Standard:
|
N/A
|
Latest IDE Support:
|
Intellij IDEA
|
Language Reference:
| |
Extra Info:
|
Hi!
ReplyDeleteThanks for the post.
Some slight corrections:
* Besides Java and Scala, Kotlin was heavily influenced by Groovy and C#.
* Kotlin has 31 keyword, not 38.
Hi ABreslav,
DeleteThanks for your comments. Post is now updated! I think I was including annotations in the keywords number.
Carlos