I am really new to Kotlin, coming from PHP. All th...
# getting-started
p
I am really new to Kotlin, coming from PHP. All the tutorials that I've seen so far tell me to use Gradle or Maven, but I don't really understand why I need them. The docs are pretty bad, they don't really explain what it does or why I need it, they just explain how to set it up. This is probably because I come from PHP, I don't think there is an equivalent thing there. Can someone shed some light for me on why I need Gradle/Maven and what they actually do?
s
Do you know what a build system is?
t
Gradle and Maven are build tools that help you package your application and also manage the libraries that you're going to be using in that application. When your code is done and you want to make it into an executable .jar you can configure it in one place and have it do the dirty work for you. When you want to use a library you add a dependency and gradle/maven will handle the transient dependencies that that library brings with it, they're pretty handy.
d
PHP is interpreted. You just throw your php files at it and it runs them. Kotlin needs to be compiled by the Kotlin compiler for the JVM to be able to execute it. A build system manages this for you. It also manages your dependencies (like composer in the PHP world).
👆 1
p
Thanks, that makes a lot of sense. Does it matter whether I learn Maven or Gradle? Which one is used more in the Kotlin ecosystem?
s
I think Gradle is the only supported option going forward. All of the jetbrains projects have been converted from maven to gradle.
d
I doubt Maven support will be ditched completely, but certain features (like multiplatform projects) are probably not happening outside of Gradle.
For a start though you do not really need to learn it and can just go with the autogenerated project from IntelliJ.
a
gradle is roughly composer
🎼 2