answersLogoWhite

0

Why java compiler slow?

Updated: 8/9/2023
User Avatar

Wiki User

11y ago

Best Answer

Actually, the Java compiler is not considered slow when compared to compiling a similar project in C or C++. The Java compiler itself is actually quite simple. All of the fancy Java optimizations occur during runtime.

As someone who used to work on the Sun JDK at Sun itself, I can tell you that the old javac (pre-2010 or so) was rather simplistic. Remember that javac itself is a Java program, so that to run, it must first invoke a JVM, and incurs typical JVM load and initialization time. It was originally designed to work on the 'fork/exec' model so common to UNIX, where it would fork a new instance of javac (and the associated JVM required to run it) for every file that it compiled. Now, creating a new JVM had significant startup time costs (initialization of methods was nontrivial), but javac would run reasonably fast one that happened. However, having to fork several hundred times during a single project compile got expensive, and slow. This was particularly true on Windows, where a 'fork/exec' call is over 10x as slow as on a UNIX or Linux system.

So, the 'old' javac, while quite quick to actually compile a single file after it got running, was actually quite slow overall when forced to compile a large number of source code files.

A major revamp of the javac compiler was undertaken during 2010 with JDK 7. This revamp significantly reduced the number of times a fork/exec was done, buy reusing existing JVMs to run several (sequential) invocations of the javac language. This significantly improved large project compile times, as it reduced the primary overhead that was slowing things down. There are additional projects being worked on that will turn javac into a single multi-threaded program able to compile multiple files itself in one invocation, thus eliminating the need to spawn multiple JVMs. This will particularly help Windows compiles, as Windows threading is much faster than fork/exec.

So, overall, if you are running a JDK with a javac created BEFORE mid-2010, javac will be relatively slow for compiling lots of source files, and worse on Windows. Pretty much all Sun/Oracle JDK 6 versions (even the newest ones) have this "defective" javac. The newer, faster javac is available in JDK 7 - I believe it may not be in JDK7, but is definitely in JDK 7 Update 1 and later. This javac should feel quite responsive for most projects, and only be a bit slow on large Windows compiles (more than 100 source files or so), and, even there, will be a noticeable improvement over the JDK 6 javac program.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

The Java programming language itself will not slow down your computer, but a program written in Java can.

By default some versions of the JDK/JRE will install an "auto-updating" feature, which may take up a small amount of RAM and will be loaded at startup. Normally this is a small enough value that you won't notice a difference, but users of older computers should keep it in mind.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why java compiler slow?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the best compiler can be used to create Java programs?

A Java compiler.


What does the Java compiler translate Java source code to?

The Java compiler translates Java source code to Java byte code.


What is the difference between java compiler and C compiler?

Greetings Technologist. The Java compiler compiles Java code, whereas the C compiler compiles C Code HTH Richard Wolf Software Architect


Is the Java compiler 16bit or 32bit?

The Java compiler itself (javac) is a 32-bit application.


When java uses compiler?

What i know is java we will use compiler when it want to get class file(file with .class extension) from java file(file with .java extension).


Does Java Script use the same compiler as Java?

No


Is JVM is part of compiler?

no jvm is not a part of java compiler


What is the compiler for java?

javac.


What is the name of java compiler?

It is simply called the Java compiler. The actual program is usually called Javac.


Which os is build in Java compiler?

Java compiler available on multiple platforms, the class files it generates are platform-independent.


Is compiler is platform independent?

No. (Of course you should specify what compiler you are talking about.)


What is Javac?

The Javac is the java compiler javac.exe is a process associated with Java(TM) 2 Platform Standard Edition 5.0 Update 5 from Sun Microsystems, Inc.. Java Capusal this is a java compiler