Hacker News new | ask | show | jobs
by Dude2023 3015 days ago
It compiles now? I thought it was a C++ transpiler.
3 comments

Honest question: (besides compile times) what are the advantages of directly generating machine code, instead of generating C++ code?

Doesn't it actually reduce the set of target platforms, while making the compiler harder to debug (by making its output mostly non-human readable)?

One of the major reasons that would influence a language like Jai is that once you do that, even if your generated C/++ is fairly optimal, you still have to go through another slower compiler. Jai's compiler is fairly optimised for speed and I think that would be an unacceptable trade off.

On the target platform side, a video game tends to have a fairly well known set of platforms it will run on (new PC's, PS4, Xbox), so I think this is an acceptable trade off.

And just a final note, the generated C/++ would be very unreadable anyway, unless it was a direct transpiler, at which point you lose a lot of the benefits of having a new language.

by generating C++ code you automatically gain C++ baggage. By generating machine code you are tied directly to how the machine works. If you don't want to deal with something like RAII you'd have to find ways to generate code that doesn't do that, where as machine code you just tell it how to exactly move memory around etc.
It's been using LLVM or directly writing x86-64 directly (based on config) for over a year now. Maybe over 2, but for a long time they've been away from transpiling.
I believe it also has an LLVM backend these days