3 ms·
How fast does Golang compile? https://www.octobench.com/ https://www.octobench.com/
by KingOfCoders 2y ago
How fast does Golang compile?
https://www.octobench.com/ https://www.octobench.com/
- bilekas 2y agoHow fast does Rust compi..... I better not actually.
- pkolaczk 2y agoWhy? I'm quite curious. There aren't any good benchmarks on the internet, especially ones comparing it to other languages. I'd love to actually see some real numbers showing how far off it is from Java or Go (I don't doubt it is slower than Java or Go, as it is a much more sophisticated language). My anecdotal evidence suggests it is not as slow as many think. It compiles a 500k LoC (that's count of all code in dependencies) project in ~10s on my M2 Pro.
- OtomotO 2y agoSubjectively, not baked by any science, the Linking step is the worst, even with mold.
- OtomotO 2y agoAbout my only gripe with the language. But it's getting better.
- lihaoyi 2y agoDon'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
- KingOfCoders 2y agoI 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.
- arxanas 2y agoOne thing I discovered while trying to improve my incremental Rust compilation time (https://blog.waleedkhan.name/rust-incremental-test-times/ https://blog.waleedkhan.name/rust-incremental-test-times/) was that there was a lot of time that seems to have been attributable to `cargo` itself (https://lobste.rs/s/ktyp2q/improving_incremental_test_times_rust#c_ukhulp https://lobste.rs/s/ktyp2q/improving_incremental_test_times_...), rather than the compiler. It seems like a similar situation as reported in the article.
- croo 2y agoHuh, 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
- p2detar 2y agoPretty impressive numbers, although it’s fair to say here that while Go comes with its own build toolset, pretty much no one uses plain javac to compile stuff. It’s almost always either Gradle or Maven and as the article hints they slow down builds a lot. > From this study we can see the paradox: the Java compiler is blazing fast, while Java build tools are dreadfully slow. Something that should compile in a fraction of a second using a warm javac takes several seconds (15-16x longer) to compile using Maven or Gradle. edit: typos
- creesch 2y agoI'd be curious to see what the slowdown is, because my gut feeling is that it simply comes down to QoL stuff tools like maven do. If we keep it to compiling only, stuff like resolving dependencies from the pom.xml and such.
- imachine1980_ 2y agoYes but reality is even worst maven projects take f*"* eternity like the post says, you have tens of atomyse package that make simple task that should take seconds take minutes, while the fast in go is not only the compilation time, but that 28000 is in real word case,at least it'd feels like this for experience.
- KingOfCoders 2y agoWhat I love most is how people project. I was just saying "How fast does Golang compile" because I'm interested in compilation speeds and CPU usage cross compilers (Rust, despite it's "slowness" seems to have the best CPU utilization of the compilers I've checked over the years). I've been using Java from 1996 on for two decades. A sidenote: The article is hard to read, it's not clear how much IO there is. It seems to use LOC as "all lines" including empty lines and comments, not "of code" (most tools today mean NCLOC when they say LOC). Also not sure why they chose Netty for the test with 500k lines and then only used a sub project with 50k lines. "Compiling 116,000 lines of Java per second is very fast. That means we should expect a million-line Java codebase to compile in about 9 seconds, on a single thread." The get the score from compiling 50k of lines without IO it seems and then extrapolate to 1m of lines - does that also fit into memory? No GC? And no IO? At least one would need to check if a file has been changed on disk? Or would the OS do that with a cache check? "compile your code, build tools add a frankly absurd amount of overhead ranging from ~4x for Mill to 15-16x for Maven and Gradle!" IO? Check for changed files?