Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rust doesn't have an option to generate C++ code; Nim does.

> Rust is being developed for LLVM, a compiler that's also shared with C++.

Not at all relevant (and LLVM is a backend target, not a compiler).



> (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.


Rust cbindgen has an option to generate C code, which is generally also valid C++.


Also not relevant since it lacks Nim's mechanisms for integrating the generated code with user-provided C++. You said that you questioned Nim's "fantastic interop" but you have no valid logical reason to ... certainly Rust not having it isn't any sort of argument.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: