News for hackers. Stuff that matters.
Re:Writing a C Compiler (2017) by userbinator on Friday June 09, 2023 @03:33PM (#36262952)
It's backwards. Writing a C compiler in C or Asm makes sense, a Python compiler in C also does, but a C compiler in Python is an odd inversion of abstraction.
Re:Writing a C Compiler (2017) by Jtsummers on Friday June 09, 2023 @03:46PM (#36263161)
Why? The objective is to translate code in one language (C) to another (machine code or assembly or perhaps an intermediate representation). Why does it make sense to use C for that task and not Python or some other language? It's not like C provides facilities that specifically enable compiler writing or text parsing for itself that other languages are lacking.
Re:Writing a C Compiler (2017) by avgcorrection on Friday June 09, 2023 @04:19PM (#36263606)
I guess this harkens back to the days when you had to write a compiler in a low-level language because that’s all that the platform that you are targeting supports. Then it sounds weird to talk about writing a compiler in a high-level language in order to target a low-level one, because surely these high-level languages are more platform-dependent than the blessed (guaranteed on the platform) low-level one.

But these days we can access dozens of languages on many platforms. And we can use high-level languages that are good for writing compilers—languages with good string types and algebraic data types—instead of being limited to awfully imperative/procedural ones.

In other words: your perspective sounds way more anachronistic.