←back to thread

302 points Bogdanp | 9 comments | | HN request time: 0s | source | bottom
Show context
AndyKelley ◴[] No.44390865[source]
My homepage takes 73ms to rebuild: 17ms to recompile the static site generator, then 56ms to run it.

    andy@bark ~/d/andrewkelley.me (master)> zig build --watch -fincremental
    Build Summary: 3/3 steps succeeded
    install success
    └─ run exe compile success 57ms MaxRSS:3M
       └─ compile exe compile Debug native success 331ms
    Build Summary: 3/3 steps succeeded
    install success
    └─ run exe compile success 56ms MaxRSS:3M
       └─ compile exe compile Debug native success 17ms
    watching 75 directories, 1 processes
replies(8): >>44390894 #>>44390942 #>>44390948 #>>44391020 #>>44391060 #>>44391265 #>>44391881 #>>44393741 #
taylorallred ◴[] No.44390942[source]
@AndyKelley I'm super curious what you think the main factors are that make languages like Zig super fast at compiling where languages like Rust and Swift are quite slow. What's the key difference?
replies(4): >>44390972 #>>44391002 #>>44391022 #>>44396531 #
1. AndyKelley ◴[] No.44390972[source]
Basically, not depending on LLVM or LLD. The above is only possible because we invested years into making our own x86_64 backend and our own linker. You can see all the people ridiculing this decision 2 years ago https://news.ycombinator.com/item?id=36529456
replies(3): >>44391069 #>>44391737 #>>44395388 #
2. unclad5968 ◴[] No.44391069[source]
LLVM isnt a good scapegoat. A C application equivalent in size to a rust or c++ application will compile an order of magnitude quicker and they all use LLVM. I'm not a compiler expert, but it doesn't seem right to me that the only possible path to quick compilation for Zig was a custom backend.
replies(3): >>44391237 #>>44392250 #>>44403098 #
3. MobiusHorizons ◴[] No.44391237[source]
Be that as it may, many C compilers are still an order of magnitude faster than LLVM. Probably the best example is tcc, although it is not the only one. C is a much simpler language than rust, so it is expected that compilation should take less time for C. That doesn’t mean llvm isn’t a significant contributor to compilation speed. I believe cranelift compilation of rust is also much faster than the llvm path
replies(1): >>44391789 #
4. zozbot234 ◴[] No.44391737[source]
The Rust folks have cranelift and wild BTW. There are alternatives to LLVM and LLD, even though they might not be as obvious to most users.
5. unclad5968 ◴[] No.44391789{3}[source]
> That doesn’t mean llvm isn’t a significant contributor to compilation speed.

That's not what I said. I said it's unlikely that fast compilation cannot be achieved while using LLVM which, I would argue, is proven by the existence of a fast compiler that uses LLVM.

6. int_19h ◴[] No.44392250[source]
It will compile an order of magnitude quicker because it often doesn't do the same thing - e.g. functions that are aggressively inlined in C++ or Rust or Zig would be compiled separately and linked normally, and generally there's less equivalent of compile-time generics in C code (because you have to either spell out all the instantiations by hand or use preprocessor or a code generator to do something that is two lines of code in C++).
7. VeejayRampay ◴[] No.44395388[source]
what is even the point of quoting reactions from two years ago?

this is a terrible look for your whole community

replies(1): >>44397706 #
8. elktown ◴[] No.44397706[source]
Honestly I think it's good to highlight it. As a industry we're too hampered by "Don't even try that, use the existing thing" and it's causing these end results.
9. pjmlp ◴[] No.44403098[source]
Not all do use LLVM.