CHAPTER1

Exercises Section 1.1.1

Exercise 1.1.1: What's the difference between a compiler and an interpreter?

  • A compiler is a program that can read a program in one language -- the source language -- and translate it into an equivalent program in another language -- the target language. An important role of the compiler is to report any errors in the source program that it detects during the translation process.

  • An interpreter is another common kind of language processor. Instead of producing a target program as a translation, an interpreter appears to directly execute the operations specified in the source program on inputs supplied by the user.

Exercise 1.1.2: What are the advantages of
(a) a compiler over an interpreter
(b) an interpreter over a compiler?

  • a. The machine-language target program produced by a compiler is usually much faster than an interpreter at mapping inputs to outputs.

  • b. An interpreter can usually give better error diagnostics than a compiler, because it executes the source program statement by statement.

Exercise 1.1.3: What advantages are there to a language-processing system in which the compiler produces assembly language rather than machine language?

  • The compiler may produce an assembly-language program as its output, because assembly language is easier to produce as output and is easier to debug.

Exercise 1.1.4: A compiler that translates a high-level language into another high-level language is called a source-to-source translator . What advantages are there to using C a target language for a compiler?

  • For the C language there are many compilers available that compile to almost every hardware.

Exercise 1.1.5: Describe some of the tasks that an assembler needs to perform.

  • It translates from the assembly language to machine code. This machine code is relocatable.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容