News for hackers. Stuff that matters.
Re:Java JIT vs. Java AOT vs. Go for Small, Short-Lived Proce... by ptx on Tuesday December 24, 2019 @07:30PM (#21875895)
Java is slower than Python for simple short-running programs. When Python is finished Java is still struggling through start-up and class-loading.
Re:Java JIT vs. Java AOT vs. Go for Small, Short-Lived Proce... by twic on Wednesday December 25, 2019 @12:30PM (#21879470)
Is this actually true? Have you measured this, or seen measurements?
Re:Java JIT vs. Java AOT vs. Go for Small, Short-Lived Proce... by ptx on Thursday December 26, 2019 @05:10PM (#21887272)
Here are measurements for an extreme case of a short-running simple program:

  $ cat Hello.java 
  class Hello { public static void main(String[] args) { System.out.println("Hello from Java!"); } }

  $ cat hello.py 
  print("Hello from Python!")

  $ time /usr/lib/jvm/java-13-openjdk/bin/java -Xshare:on -XX:+TieredCompilation -XX:TieredStopAtLevel=1 Hello
  Hello from Java!

  real 0m0.102s
  user 0m0.095s
  sys 0m0.025s

  $ time python3 -S hello.py 
  Hello from Python!

  real 0m0.034s
  user 0m0.020s
  sys 0m0.013s
It's a bit faster if you create a custom modular JRE with jlink:

  $ /usr/lib/jvm/java-13-openjdk/bin/jlink --add-modules java.base --output /tmp/jlinked-java13-jre
  $ /tmp/jlinked-java13-jre/bin/java -Xshare:dump
  $ time /tmp/jlinked-java13-jre/bin/java -Xshare:on -XX:+TieredCompilation -XX:TieredStopAtLevel=1 Hello
  Hello from Java!

  real 0m0.087s
  user 0m0.050s
  sys 0m0.035s
Re:Java JIT vs. Java AOT vs. Go for Small, Short-Lived Proce... by ptx on Thursday December 26, 2019 @09:15AM (#21883901)
Yes, I often write small command-line tools and that's what I found. Profiling seemed to indicate that doing anything at all in Java, such as reading a config file, is fast the second time but super slow the first time.

You can test my assertion simply by writing a "hello world" in Python and Java.