4 ms·
Your questions don't make sense. LLVM is a framework for building compilers and tools. C is a language specification.
by KerrAvon 3y ago
Your questions don't make sense. LLVM is a framework for building compilers and tools. C is a language specification.
- latenightcoding 3y agoIt does make sense, your language can target C or LLVM. each option comes with pros and cons e.g: C is more familiar, LLVM has better support for JIT compilation.
- halayli 3y agoNo it doesn't. Ignoring the fact that you incorrectly refer to LLVM IR as LLVM, C is a language spec and LLVM IR is a dialect. LLVM IR dialect doesn't mean much outside LLVM framework and are constantly expanded upon and improved via no attributes and ops and abstractions to help trickle down context coming from levels above to be used for optimizations and making valid assumptions down the line. Comparing the 2 is nonsensical to say the least.
- twic 3y agoI know what you mean. But the fact is that there are compiler front-ends which produce LLVM IR, and there are compiler front-ends which produce C, so they alternatives to each other in that context.
- halayli 3y agoAnd what do you do with that produced C program?
- pizlonator 3y agoBoth C and llvm have been used as backends for other language implementations so it makes sense to compare them for that use case.
- latenightcoding 3y ago>> Ignoring the fact that you incorrectly refer to LLVM IR as LLVM I also "incorrectly" wrote "target C" instead of "target C code". It's obvious what I meant. >> Comparing the 2 is nonsensical to say the least. You could have easily googled "C vs LLVM as a backend" to find a lot of interesting discussions comparing both before being so confidently incorrect
- silisili 3y agoThank you. I'm thoroughly confused not only by the question, but by the amount of replies treating this as a valid question. Maybe I'm misinterpreting something here...
- MarkSweep 3y agoI agree the question is not well formed, but it’s easier to understand if you read this story (OP mentioned but did not link): https://news.ycombinator.com/item?id=36529456 https://news.ycombinator.com/item?id=36529456 Basically the Zig language is moving away from using LLVM in its backend. One backend they are adding is one that generates C. I guess if I had to restate the OP’s question, I would say: What are the trade offs in making a compiler target LLVM versus C in its backend.