Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In general, a compiler translates one language into another. Most compilers target machine code; here are the most common ways of doing this, in order from lowest-level to highest-level:</p> <ol> <li>Produce machine code directly, by including back-ends for each instruction set.</li> <li>Produce assembly language, which is passed to an external assembler. This is what gcc does. After all, why not use existing assemblers? Generating opcodes directly is a pain.</li> <li>Generate a low-level intermediate form of the code, such as <a href="http://llvm.org/" rel="nofollow noreferrer">LLVM bytecode</a>, which gets transformed into machine code. LLVM is a godsend for compiler-writers, because it handles a vast number of optimizations and supports a lot of back-ends, while letting you write at a higher level than assembly.</li> <li>Transform the code into a language like C, and then pass it to another compiler. <a href="http://developers.facebook.com/blog/post/358" rel="nofollow noreferrer">Facebook does this to PHP</a>: they compile it to C++, and then use gcc to compile that to assembly, which is assembled to native code by GNU as.</li> </ol> <p>If you'd like to try writing a compiler, I'd recommend starting off with something like C as the back-end. If you'd like to get more elaborate later, try LLVM. If you try to produce assembly language or machine code directly, it'll probably be less efficient than what a C compiler or LLVM would produce. I speak from embarrassing personal experience on this one.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload