3 ms·
> Most other languages are implemented in C I'm not entirely sure what you mean here, but this is true for neither of the interpretations I have. Most compiler
by jcranmer 6y ago
> Most other languages are implemented in C
I'm not entirely sure what you mean here, but this is true for neither of the interpretations I have. Most compilers are not written in the C language (indeed, even the major C compilers are all written in C++ now!). Alternatively, most languages compile down into a bytecode language, or into native assembly, without converting into anything that is or looks like C in the process. Indeed, for languages targeting native assembly, C is an unwelcome intermediate step precisely because its semantics can be too constraining.
- tyingq 6y ago"I'm not entirely sure what you mean here" I mean that most of the popular languages I'm familiar with are written in C.
- Thiez 6y agoGCC is written in C++ these days, and LLVM has always been C++. Perhaps some languages are written in C, but C itself hasn't been for some time, if you look at the most popular compilers.
- jcranmer 6y agoThat doesn't clear up any of my confusion, although that may well be because your experience is mostly with managed languages where the distinction between compiler and runtime is less obvious. Even looking at major languages [1], what do we have: * Self-hosting languages: C#, Go, Haskell, Java, most LISP implementations, OCaml, Pascal, Rust, Swift * C++ implementation: C/C++/Objective-C compilers, Fortran compilers (using the same toolchains as the former), JavaScript, probably Visual BASIC (although that may be C# instead) * C implementation: Perl, PHP, Prolog, Python, R, Ruby, Shell (although note that many of these languages have their libraries largely written in their own language). * Not sure: ALGOL, APL, Cobol, Erlang, Forth, Kotlin, SQL, Simula, Smalltalk. Although I suspect that many of these are self-hosted. 7 of 32 is a far cry from "most languages". [1] Using the list of programming languages in Wikipedia's category box at the bottom here.
- deleted 6y ago[deleted]
- dnautics 6y agoerlang is written in c. somewhat controversially, the new JIT has C++ in it.
- int_19h 6y ago"Self-hosting" can be a bit tricky to define for Forth. A typical implementation would start with a few words defined manually in assembly, and build the rest up from there. That aside, you need to account for multiple implementations. E.g. for Python, CPython is written in C, but PyPy is self-hosted (kinda; it's complicated: https://doc.pypy.org/en/latest/architecture.html#layers https://doc.pypy.org/en/latest/architecture.html#layers).