- No, I would be surprised if you find a heavily used compiler with a single C ++ pass.
- No, it performs several passes and even various optimizations based on the flags that you pass.
Advantages (single pass): fast! Since all source code needs to be studied only after the compilation phase (and, therefore, the start of execution) can happen very quickly. This is also an attractive model because it makes the compiler understandable and often “easier” to implement. (I worked once on the Pascal compiler once, but I don't often see them, while single-pass interpreters are common)
Disadvantages (sinlge-pass): Optimization, semantic / parsing. Sometimes a single code scan allows you to do everything that is easy to catch with simple mechanisms in a few passes. (why do we have things like JSLint)
Advantages (multi-pass): optimization, semantic / parsing. Even pseudo-interpreted languages, such as "JRuby", go through the process of compiling the pipeline to go to the java / jvm bytecode before execution, you could consider this multi-pass, and multiple viewing of various representations (and, therefore, the resulting optimizations) of the code can do it very fast.
Disadvantages (multi-pass): complexity, sometimes time (depending on whether AOT / JIT is used as a compilation method)
In addition, single pass is widely used in academia to help explore aspects of compiler design.
Brandon
source share