Excluding compilers that convert one high-level language to another, does any compiler that compiles to machine code need to be written in assembly?
Does a compiler that compiles to machine code need to be written in assembly?
622 Views Asked by kjh At
2
There are 2 best solutions below
0
Paul Stansifer
On
A compiler is not a special, magical program. If you squint at it, a compiler is just a program that turns one text file into another text file (well, okay, a binary file).
There is only one constraint about what language a program can be implemented in. If you're writing a program in a language, that language has to already have a compiler or interpreter implemented. Therefore, the first compiler/interpreter for language X cannot be written in X. (If you want to be able to use it, at least.) But this isn't special to compilers/interpreters; you can't usefully write anything in X until someone has implemented X.
Related Questions in COMPILER-CONSTRUCTION
- Reference: Crafting Interpreters. Print statement is not able to evaluate expression. Help me fix this (details below)
- Load function written in amd64 assembly into memory and call it
- I have implemented till Statements and State in Tree Walk Interpreter. I am pissed with an error
- Resolve shift/reduction conflict in grammar for expressions in PLY for calls to embedded functions
- Grammar for access to properties and calls to embedded functions
- LLVM code generation causes problems with pointer arithmetic
- what does react compiler mean actually?
- Errors on Recursive Descent Parsing Java
- Java CUP produces Shift-Reduce conflict when parsing a grammar for a C++ type language
- Three-Address-Code (TAC) and Conjunction/Disjunction
- How do I write an implicit cast for my strongly typed interpreter? (C++)
- Yacc parser not reducing specific production rules as intended
- Why is the function version tag consistently "Base" in HDF5 library?
- Sly parser, how are recursively defined types implemented?
- Does a non terminal token need an explicit definition?
Related Questions in PROGRAMMING-LANGUAGES
- How can passing the `IO ()` to `main` be considered pure?
- Programming language/library that uses dataflow analysis to fetch only required data from the database
- Infinite loop for user-defined list_length
- Prolog evaluation of unknown variables
- How to create a "PyObject"-like structure in C++ for a dynamically typed programming language?
- Effect on time complexity of defining function argument in different ways
- Bison ID reduction conflict
- How to add support for my programming language on GitHub?
- Auto-casting number literals in a type checker
- How does a program store variables?
- Overloaded Subprograms in Ada
- Java bytecode not in .class file
- Estimating the Percentage of Changes in Programming and Natural Languages over a 10-Year Period
- Which programming languages don't treat if as syntax?
- Can I compile the java code in something like a dll to use inside the Python code, and use this before in a pyinstaller compiled program?
Related Questions in LOW-LEVEL
- Where exactly is the first data sector on a FAT file system?
- how to write a large value > 32 bits with a format string exploit %n
- Why is there low-level and high-level assembly
- C# Key and mouse hook not working on excel
- Parsing SQLite file columns without sqlite3.h header file
- How can you get a DEVICE_OBJECT from the name of the device?
- On Windows, intercepts and change a click event system-wide
- Workaround for "use of variable before deduction of auto"
- How is asynchronous programming implemented under the hood without continuous cheching?
- Address translation of a instruction of multiple bytes
- How to set buttons and leds using addresses in mips assembly?
- static link ffmpeg to rust binary
- Bochs Panicing After Not Finding Speaker In WSL
- C# does the compiler leave re-references in the final binary?
- Sanitizing static freestanding nolibc programs?
Related Questions in MACHINE-CODE
- C++ optimization comparing inline classes and functions doesn't seem good enough
- CMP ESI, -20. This part of code makes no sense to me. How does this magic work?
- What version of ARM does the given machine code correspond to?
- Not seeing my input(NOPs) inside the stack
- Not getting the expected output when running a shell code in a buffer overflow
- How to test J and B type RISCV instructions with random operands jumping to random memory locations?
- Not getting the same result from running a python script to generate a certain input string as i get when typing it myself
- Buffer overflow attack not going as intended
- EIP doesn't get overwritten when perfoming a buffer overflow attack
- How to compile hexadecimally encoded instructions into an ELF for RISCV simulation?
- The value in CS is 1FD0h what is the location of next instruction from 00000h if Instruction pointer is 3CD4h
- Is there a way to make GDB disassemble all memory in a specific range, without regard for instruction boundaries?
- Does exe file after linking consist of machine language only?
- How can I call a Windows .DLL (API) function from machine code?
- GNU Assembler: Set fixed displacement size
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The source code for a compiler does not need to be written in assembly. For example, (a good portion) of the CPython compiler (well, technically interpreter) is written in C: http://en.wikipedia.org/wiki/Cpython
In the very beginning, before there were compilers, the very first compiler did have to be written in assembly. But then someone used this compiler to compile their own compiler. Then someone else used this compiler to compile their own compiler. And so on and so forth.
This brings up the concept of "bootstrapping". A bootstrapping compiler is one that is written in the language it intends to compile. The clang compiler can compile C++ code, but the compiler itself is written in C++! How does this work? Well the very first clang compiler was compiled by a different compiler (g++ probably). After the clang compiler was mature enough, it was able to compile its own code. Now, any changes made to the clang compiler can be recompiled by the clang compiler into another clang compiler! Neat, huh?