Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interesting. Anyone have an opinion on how this compares to using Kotlin for similar tasks?


Seems very similar https://kotlinlang.org/docs/kotlin-tour-hello-world.html although I haven't ever used Kotlin like a "script replacement" (e.g. https://kotlinlang.org/docs/run-code-snippets.html#command-l... ) to compare and contrast

Overall, I think Kotlin is a vastly superior language to Java and spanks Scala in discoverability and legibility (less magick moar bettar, IMHO)


I've abandoned the jvm, but I found Scala much better designed than Kotlin. Things in Kotlin felt consistently ad hoc and I would frequently run into weird special casing whereas Scala actually had general principles that could be applied to more use cases.

Kotlin on the other hand had better IDE support in intellij for obvious reasons. That was not nearly compelling enough for me.


What’d you switch to from JVM?


Also, see my comment about kotlin scripting (kts) elsewhere in this thread.

But, in short, you can write kts shell scripts; import any library you want, use anything in the JVM or the Kotlin or Java library ecosystem that you need, etc.

Works on the command line (you need a jvm and kotlin installed from your favorite package manager). The Kotlin Jupyter kernel also uses kts and this is a nice way to use Java stuff in jupyter.


I'd consider it equal or better in all regards.

- Top-level functions/main is supported - data classes are approximately as good as records - A scripting mode comes built in, and can use annotations to import and use dependencies within the same file - There's a repl - The keyword 'var' exists, and the keyword 'val' is more ergonomic than 'final var'

The only thing I remember missing from the article is the implicit imports which I don't remember Kotlin having. Regardless, I'd reach for Kotlin every time. I think funnily enough Java never fully clicked for me until I started using Kotlin, which in many ways is "Java, except many best practices are on by default".


Kotlin is much better in that regard.

I use Kotlin scripts (.main.kts) as a replacement for Bash scripts for years.

You can inline dependencies without additional tooling, and Kotlin is still much more expressive than Java.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: