Live data from Hacker News

How fast does Java compile?

mill-build.org

31–40 of 76 posts

Re: How fast does Java compile?

#31

Use Maven profiles: * compile only * compile/test only * compile/install jar only, skip source/javadoc packages * checkstyle only * static analysis only * code coverage only * Skip PGP (you DO check your artifact signatures, right?) 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. Finally, if you have a large multi-mod…

Alas, I'm stuck with Gradle. And not a simple example of the species, either.

I think thats the major issue I have with Gradle in large orgs: it doesn't lend itself to reuse, but I don't blame it either: it's not really meant to do that.

I'm dating myself, but 20 years ago, we had Ant. It was very much a blunt hammer like CMake. Maven came along and was like "how about we choose a definitive way to organize projects, make that repeatable". You lose flexibility but gain speed/reuse.

I see Gradle more of a replacement for Ant than Maven in this regard. Infinite flexibility, at the cost of speed/reuse.

Re: How fast does Java compile?

#32
post #23
post #4

Earlier quoted context omitted.

How fast does Rust compi..... I better not actually.

Don't worry, I wrote this article about Java but my day-to-day work is Scala. We're lucky if we can crack 4,000 lines-per-second-per-core on my pretty vanilla Scala projects x_x

I feel the pain, I've started a startup on Scala (and some years later successfully sold it), but compilation speed and 20 lines type constraint errors where my biggest problems (but I never forget that it enabled us to scale the company and sell it :-) - but if a programming language spawns consulting companies that only help with speeding up compile times, that is a bad sign.

Though when working on a 2M+ LOC Java project 15 years ago, we also spent a lot of money on very fast RAID hard drives in developer machines to speed up compilation. JRebel was a huge relief back then.

Re: How fast does Java compile?

#34
Interesting read. Just one remark to the "Keeping the JVM Hot" 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.

Re: How fast does Java compile?

#35

I thought java was tokenized, not compiled. That's why you need their runtime environment isn't it?

It is compiled to Java byte code. The JVM runs the byte code. Tokenization [1] is the process of splitting text into components called tokens. It's usually the first stage of parsing. [1]: https://en.wikipedia.org/wiki/Lexical_analysis#Tokenization

Compiled means it's a direct executable in machine code. Java ain't that. Heck, if it needs a runtime with a garbage collector built into the runtime it's especially junk.

Re: How fast does Java compile?

#36

Earlier quoted context omitted.

It is compiled to Java byte code. The JVM runs the byte code. Tokenization [1] is the process of splitting text into components called tokens. It's usually the first stage of parsing. [1]: https://en.wikipedia.org/wiki/Lexical_analysis#Tokenization

Compiled means it's a direct executable in machine code. Java ain't that. Heck, if it needs a runtime with a garbage collector built into the runtime it's especially junk.

No, that is not what compiled means. A compiler is simply a program that translates from one language to another. Hence a compiled language is one that is translated into a different language prior to execution. Java is compiled twice; once to byte code and again to machine code by the JIT compiler. That is unless you compile it directly to machine code using, say, Graal Native Image.

You are welcome to your opinion on the utility of garbage collection but the widespread usage of GC suggests the industry as a whole does not share your view nor is such an unnaunced view supported by research (e.g. https://dl.acm.org/doi/abs/10.1145/1094811.1094836)

Re: How fast does Java compile?

#37

Earlier quoted context omitted.

Compiled means it's a direct executable in machine code. Java ain't that. Heck, if it needs a runtime with a garbage collector built into the runtime it's especially junk.

No, that is not what compiled means. A compiler is simply a program that translates from one language to another. Hence a compiled language is one that is translated into a different language prior to execution. Java is compiled twice; once to byte code and again to machine code by the JIT compiler. That is unless you compile it directly to machine code using, say, Graal Native Image. You are welcome to your opinion…

As having a masters in computer science I respectfully disagree with you. Would you consider a program that translates C code to FORTRAN a compiler? Nope, it's a translator. A compiler compiles a language into a direct executable. Just like Microsoft Windows has executables, .exe file, there's no runtime required to run those files.

Re: How fast does Java compile?

#38

I thought java was tokenized, not compiled. That's why you need their runtime environment isn't it?

I think it means "compile it into bytecode", which can then be run by the Runtime.

That's pretty much the definition of tokenized. I know Oracle would like us to think different, but facts are facts

Re: How fast does Java compile?

#39

Use Maven profiles: * compile only * compile/test only * compile/install jar only, skip source/javadoc packages * checkstyle only * static analysis only * code coverage only * Skip PGP (you DO check your artifact signatures, right?) 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. Finally, if you have a large multi-mod…

I don't think anyone checks their artifact signatures. I've changed signatures several times over the past few years (every time I get a new laptop I forget to copy over my keys) and haven't heard a peep from anyone using my open source libraries who actually noticed the change

Re: How fast does Java compile?

#40
post #8

Earlier quoted context omitted.

Huh, so for anyone interested but did not have the time to do the comparison of the two links of OP and parent post: * java (on a cold jvm): 18.000-32.000 line per second on a single core * java (on a hot jvm): 102.000-115.000 line per second on a single core * golang: 28.000 line per second on 12 core

Outside a synthetic benchmark: * Gradle compiling 100,000 lines of Java at ~5,600 lines/s * Maven compiling 500,000 lines of Java at ~5,100 lines/s * Mill compiling at ~25,000 lines/s on both the above whole-project benchmarks Again not to put Java down but have a proper discussion about compiler speeds. I'm not interested in "your" tool is faster than "my" tool, I want to understand compilation speeds of different p…

Notably, the benchmarks I provide are all single-core. You can get more if you modularize the project and spread out the load over multiple cores, and some of the other pages linked from the OP go into more detail
Post reply on HN