2

It can look quite a generic question, but what is the very technical reason for javac not to compile concurrently ? I read that the eclipse compiler is parallel, so why not javac ?

volley
  • 6,651
  • 1
  • 27
  • 28
Snicolas
  • 37,840
  • 15
  • 114
  • 173
  • 1
    The "very technical" reason is that Sun / Oracle did not not designed / implemented the `javac` compiler that way. I imagine they have more important things to do ... in terms of delivering product that will earn money for Oracle. – Stephen C Sep 28 '17 at 05:49
  • What about open jdk then ? – Snicolas Sep 28 '17 at 05:50
  • What about it? The same reasoning applies there. In reality, OpenJDK is 99.x% the same codebase as the Oracle badged JDK release ... and developed by the same team of people. – Stephen C Sep 28 '17 at 05:52
  • I mean there is now more room to get motivated to do just a better compiler. – Snicolas Sep 28 '17 at 05:55
  • 1
    It is the same people (Oracle employees), with the same (Oracle) managers setting their priorities. And it is your just your opinon that it would make the compiler better. On the other hand, if you have (I am guessing) 12 man months to spend overhauling the java compiler **for free** (and you have compiler-writing skills), I suggest that you volunteer :-) – Stephen C Sep 28 '17 at 05:57
  • If others are interested, actually I am ;) I believe the gain in productivity would be huge. Or will another language do it before (Kotlin ?) – Snicolas Sep 28 '17 at 06:17
  • If you are interested in doing the work, put your hand up. If you are interested in someone else volunteering .... good luck with that :-) – Stephen C Sep 28 '17 at 06:56
  • You will never be able to compile faster than you can read source code or write class files. So before you start trying to optimize the processing that happens in-between, you should check the size of its fraction on the entire process. It might be discouraging… – Holger Jan 22 '18 at 14:25
  • What about this answer, where it is demonstrated that javac does run on multiple cores even for single files? https://stackoverflow.com/a/31553913/1262865 – john16384 Oct 24 '20 at 03:17

2 Answers2

2

It is highly unusual for compilers to actually work in parallel and I can't find any sources that say that Eclipse's Java compiler is an exception.

What eclipse does have the ability to do, is to compile multiple files in parallel at the same time. This is unrelated to the fact that Eclipse comes with its own Java-compiler. If it did use javac it could just run multiple instances of javac in parallel - there's no problem with that. And in fact that's exactly what build tools such as maven do when you run a build with multiple threads.

sepp2k
  • 363,768
  • 54
  • 674
  • 675
  • Do you mean compiling in parallel in different modules ? Gradle does that too, but here I am really talking about compiling 1 module in parallel. – Snicolas Jan 25 '18 at 15:37
  • @Snicolas I meant compiling different files in parallel. It's perfectly possible to compile different files from the same module in parallel (or to do this in Java versions that don't have modules). What isn't possible is to compile a single file in parallel. – sepp2k Jan 25 '18 at 17:05
-2

I think it makes javac program simple, if it's internal parallel, then many race condition has to be handled, which complicate the thing. To utilize multi-core, you can create multiple javac process to reach the same goal, seems that makefile and gcc works like this way.

"Keep it simple and stupid"

lee qiaoping
  • 155
  • 4