Halite icon indicating copy to clipboard operation
Halite copied to clipboard

Kotlin starter package

Open vafin-mk opened this issue 8 years ago • 8 comments

Added kotlin language package. Kotlin compiler can be installed from https://github.com/JetBrains/kotlin/releases/latest

vafin-mk avatar Dec 09 '16 16:12 vafin-mk

Would love to hear @nmalaguti thoughts on this implementation

truell20 avatar Dec 11 '16 19:12 truell20

It looks like a lot of this is from the Java -> Kotlin autoconversion. It doesn't use a lot of Kotlin idioms.

Example:

for (b in 0..width - 1) {
    row.add(Integer.parseInt(input[index]))
    index++
}

would be better as

for (b in 0 until width) {
    row.add(Integer.parseInt(input[index]))
    index++
}

// or you could do something like
input.take(width).map { Integer.parseInt(it) }

Also might want to use mutableListOf instead of creating explicit ArrayList instances.

nmalaguti avatar Dec 11 '16 23:12 nmalaguti

Does it look better now?

vafin-mk avatar Dec 12 '16 01:12 vafin-mk

Does it look better now?

Much!

I think the package should include details on how to create a JAR with the Kotlin runtime included and a Main-Class in the manifest (unless kotlinc does that automatically?)

It should also include a LANGUAGE file with Kotlin in it.

nmalaguti avatar Dec 13 '16 23:12 nmalaguti

I think the package should include details on how to create a JAR with the Kotlin runtime included and a Main-Class in the manifest (unless kotlinc does that automatically?)

It should also include a LANGUAGE file with Kotlin in it.

We can include a Kotlin compiler on the server and properly tag Kotlin bots with the name "Kotlin."

It is still nice to have the LANGUAGE file in case anyone wants to switch to building with a JAR.

truell20 avatar Dec 14 '16 00:12 truell20

Not sure what is LANGUAGE(just txt with "Kotlin" inside?) file and where it should be.

executable JAR file can be created with:

kotlinc *.kt -include-runtime -d *name*.jar
jar ufe **name**.jar *MainClassName*Kt

and simple run with: java -jar *name*.jar Should i create sh/bat scripts for that?

vafin-mk avatar Dec 14 '16 13:12 vafin-mk

Not sure what is LANGUAGE(just txt with "Kotlin" inside?) file and where it should be.

Yes. See "Customizing your language name" in this doc.

Should i create sh/bat scripts for that?

That would be great.

truell20 avatar Dec 14 '16 23:12 truell20

The CI tests are failing because starter packs are assumed to be valid submissions with a MyBot.* file. In this case, the tests would be looking for a MyBot.jar file. Since users are expected to create their jar and zip it up, I'm not sure what to do about the assumption that all starter packs are valid submissions.

nmalaguti avatar Dec 18 '16 16:12 nmalaguti