-2

Despite Kotlin being more concise and readable than Java for beginners, I don't understand why the latest version of Kotlin still requires a main function and moreover a println method. I watched this video and realized that Java 21 doesn't require a main function or a println method, instead a print method.

Based on the fact that Kotlin isn't taking advantage of those new JVM techniques just yet, I don't understand how Kotlin still beats Java nowadays. Does anyone know?

redbraces
  • 1
  • 1
  • 7
    `print` and `println` in java do different things. And kotlin has `print` as well. – Federico klez Culloca Aug 25 '23 at 21:17
  • 1
    Java does require a main method (as does Kotlin). Just because the compiler hides it from you doesn't change that ... Try writing more Kotlin than a print statement and you'll see the differences quickly. – OneCricketeer Aug 25 '23 at 21:22
  • Perhaps you are asking about a REPL? Similar to JShell? https://kotlinlang.org/docs/run-code-snippets.html#install-and-run-ki-shell – OneCricketeer Aug 25 '23 at 21:25
  • 3
    Java 21 still requires main methods—you just don’t have to put them in a named class. This is a feature Kotlin has had from the beginning. – Tenfour04 Aug 25 '23 at 21:26
  • [Kotlin scripts](https://kotlinlang.org/docs/command-line.html#run-scripts) don't require an enclosing class _or_ a main() method. – gidds Aug 26 '23 at 16:41

0 Answers0