Skip to content

Comment on A review of Nim 2: The good and bad with example codeparent

Comments

(and LLVM is a backend target, not a compiler).

LLVM is a backend compiler which compiles to backend targets like x86, which have their own compilers. It's hard to say exactly what a compiler is and isn't, because it's compilers all the way down; compilers are made of compilers.

My working definition is a compiler is a program that turns code from one form into another, whether that's machine code, byte code, IR, or some other high level source. It's a broad definition but it covers all the things we call "compilers".

So you have an idiosyncratic definition of compiler that no one else uses.

https://en.wikipedia.org/wiki/Compiler

"In computing, a compiler is software that translates computer code written in one programming language (the source language) into another language (the target language)."

https://en.wikipedia.org/wiki/LLVM

"LLVM, also called LLVM Core, is a target-independent optimizer and code generator.[5] It can be used to develop a frontend for any programming language and a backend for any instruction set architecture. LLVM is designed around a language-independent intermediate representation (IR) that serves as a portable, high-level assembly language that can be optimized with a variety of transformations over multiple passes.[6]""

As I correctly said, LLVM is not a compiler, it is a backend target of Rust, C++, etc. compilers. They read source language and generate backend output ... anything from assembly language to C++. Even when Nim uses the C++ backend, C++ is the backend target, even though the generated C++ is fed to a C++ compiler.

End of story and of my participation.

So you have an idiosyncratic definition of compiler that no one else uses.

My definition is supported by your links, so I don't think it's idiosyncratic at all.

"In computing, a compiler is software that translates computer code written in one programming language (the source language) into another language (the target language)."

That's exactly what I said:

"My working definition is a compiler is a program that turns code from one form into another"

LLVM... is a target-independent optimizer and code generator.

Code generators are a kind of compiler. The input language is IR, and the output language is machine code. Thus it fits the definition of a compiler you proffered.

As I correctly said, LLVM is not a compiler, it is a backend target of Rust, C++, etc. compilers.

These things are not mutually exclusive. It can be a target of Rust, C++, etc., but that doesn't make it not a compiler. LLVM being a compiler is supported by both of your wiki links. Your first link lists LLVM under "Notable Compilers and Toolchains". In the second link in the LLVM infobox it reads "Type: Compiler". Nuff said.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.