TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How fast does Java compile?

94 pointsby jatcwang6 months ago

13 comments

rho46 months ago
We slow our build down by having a dozen 'tools'-projects with a handful of classes each in a straight dependency-line above our main project that contains 99% of the code. This easily increases our compile time from a few seconds to several minutes. With a bonus chance to cause an infinite IDE workspace build loop.
Someone6 months ago
&gt; Compiling 32,000 lines of code per second is not bad<p><a href="https:&#x2F;&#x2F;prog21.dadgum.com&#x2F;47.html" rel="nofollow">https:&#x2F;&#x2F;prog21.dadgum.com&#x2F;47.html</a>: <i>“By the mid-1990s, Borland was citing build times of hundreds of thousands of lines of source per minute”</i><p>I know it’s a different language, but I don’t think Java is significantly harder to parse than Pascal, bytecode doesn’t have to be heavily optimised (it gets heavily morphed at runtime) and computers are a lot faster than in the 1990s.<p>Also, recently (2020) <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24735366">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24735366</a> said: <i>“Delphi 2 can compile large .pas files at 1.2M lines per second.”</i><p>Or am I mistaken in the idea that Java isn’t hard to parse? If so, why is it hard to parse? Annotations? Larger programs with lots of dependencies?
评论 #42277310 未加载
评论 #42279141 未加载
martylamb6 months ago
That&#x27;s a nice writeup. Given the hot&#x2F;cold difference you observe, I&#x27;d be very curious to see how builds compare when using maven daemon or gradle daemon.<p>I am not very familiar with those myself, simply aware of them.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;apache&#x2F;maven-mvnd">https:&#x2F;&#x2F;github.com&#x2F;apache&#x2F;maven-mvnd</a><p>[2] <a href="https:&#x2F;&#x2F;docs.gradle.org&#x2F;current&#x2F;userguide&#x2F;gradle_daemon.html" rel="nofollow">https:&#x2F;&#x2F;docs.gradle.org&#x2F;current&#x2F;userguide&#x2F;gradle_daemon.html</a>
评论 #42245818 未加载
lihaoyi6 months ago
Author here, hope people find this article interesting!
评论 #42245583 未加载
评论 #42248553 未加载
mothergreen6 months ago
Interesting read. Just one remark to the &quot;Keeping the JVM Hot&quot; Benchmark: Running the same Compilation Task on exactly the same input over and over again gives the Just in Time compiler of your Java runtime engine the chance to optimize for this specific task. This somehow spoils the idea of this benchmark because in a real world situation the source code changes between each compilation process.
评论 #42278081 未加载
exabrial6 months ago
Use Maven profiles:<p>* compile only<p>* compile&#x2F;test only<p>* compile&#x2F;install jar only, skip source&#x2F;javadoc packages<p>* checkstyle only<p>* static analysis only<p>* code coverage only<p>* Skip PGP (you DO check your artifact signatures, right?)<p>The beauty of this is you can create a corporate super pom that defines all of these for you and they can be inherited by every project in your org.<p>Finally, if you have a large multi-module project, run with -T2C to parallel-ize module builds. If your tests are written in a sane&#x2F;safe manner: -DuseUnlimitedThreads=true -Dparallel=classes -DforkCount=2C will also give you a major boost.<p>We have a giant code base (500,000 SLOC) with 28 maven modules, and a full compile and install takes less 40 seconds with compile&#x2F;install only. You often don&#x27;t need to do a full build, but even with tests thats about 3 mins on a M3 Max.
评论 #42251884 未加载
评论 #42247830 未加载
never_inline6 months ago
&gt; Again, Maven doesn’t make it easy to show the classpath used to call javac ourselves.<p>Wait, I was under the impression that maven dependency plugin has a command for exactly that (dependency:build-classpath or something like that)?
nwellinghoff6 months ago
Seems easy enough to do a quick fix for. Just add a option to maven that goes straight into compile and does nothing else. Would be good for local dev. However as we all know maven does much more than this and server side ci&#x2F;cd process is what really slows your other team members down (if its slow)
setheron6 months ago
Long classpaths with unnecessary direct dependencies (i.e. not runtime) cause surprising slowdowns due to lookup performance.
评论 #42277793 未加载
cutler6 months ago
With Clojure it&#x27;s just a simple deps.edn file and the `clj` on the command line. JVM in a jiffy.
anuraganand7896 months ago
very good write up. This was really informative!!!
KingOfCoders6 months ago
How fast does Golang compile? <a href="https:&#x2F;&#x2F;www.octobench.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.octobench.com&#x2F;</a>
评论 #42245529 未加载
评论 #42245495 未加载
bastloing6 months ago
I thought java was tokenized, not compiled. That&#x27;s why you need their runtime environment isn&#x27;t it?
评论 #42245528 未加载
评论 #42245632 未加载
评论 #42245535 未加载
评论 #42245530 未加载
评论 #42245536 未加载