Why are compiled Java class files smaller than C compiled files?

后端 未结 9 1498
被撕碎了的回忆
被撕碎了的回忆 2020-12-16 17:16

I would like to know why the .o file that we get from compiling a .c file that prints \"Hello, World!\" is larger than a Java .class file that also prints \"Hello, World!\"?

9条回答
  •  旧巷少年郎
    2020-12-16 18:05

    In short: Java programs are compiled to Java byte code, which requires a separate interpreter (Java Virtual Machine) to be executed.

    There is not a 100% guarantee that the .o file produced by the c-compiler is smaller, than the .class file produced by the Java compiler. It all depends of the implementation of the compiler.

提交回复
热议问题