Kotlin

Compile Kotlin and run jar from command line

Compile Kotlin and run jar

Kotlin:

Kotlin is a statically typed programming language that runs on the Java virtual machine and also can be compiled to JavaScript source code or use the LLVM compiler infrastructure. It is sponsored and developed by JetBrains. While the syntax is not compatible with Java, the JVM implementation of the Kotlin standard library is designed to interoperate with Java code and relies on Java code from the existing Java Class Library, such as the collections framework.[2] Kotlin uses aggressive type inference to determine the types of values and expressions for which type has been left unstated. This reduces language verbosity relative to Java, which demands often entirely redundant type specifications prior to version 10. Kotlin code can run on JVM up to latest Java 11.

https://kotlinlang.org/docs/reference/comparison-to-java.html

Comparison to Java Programming Language
Some Java issues addressed in Kotlin

Kotlin fixes a series of issues that Java suffers from:

Null references are controlled by the type system.
No raw types
Arrays in Kotlin are invariant
Kotlin has proper function types, as opposed to Java’s SAM-conversions
Use-site variance without wildcards
Kotlin does not have checked exceptions

What Java has that Kotlin does not

  • Checked exceptions
  • Primitive types that are not classes
  • Static members
  • Non-private fields
  • Wildcard-types
  • Ternary-operator a ? b : c

What Kotlin has that Java does not

  • Lambda expressions + Inline functions = performant custom control structures
  • Extension functions
  • Null-safety
  • Smart casts
  • String templates
  • Properties
  • Primary constructors
  • First-class delegation
  • Type inference for variable and property types
  • Singletons
  • Declaration-site variance & Type projections
  • Range expressions
  • Operator overloading
  • Companion objects
  • Data classes
  • Separate interfaces for read-only and mutable collections
    Coroutines

So how to run it….

https://kotlinlang.org/docs/tutorials/command-line.html

Download Java JRE

Dowload a Kotlin compiler, store the compiler in c:\Program Files, add the path to system env vars.

https://github.com/JetBrains/kotlin/releases/tag/v1.3.11

Check Java and Kotlin

Make a Class.kt

Compile it and run the jar

Make a change to the class and compile again

Comments Off on Compile Kotlin and run jar from command line