说源代码总是可用于解释器是什么意思? [英] What does it mean to say that the source code is always available to interpreters?

查看:202
本文介绍了说源代码总是可用于解释器是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

思考C ++ - Vol。 1


翻译者有许多优点。从编写代码到执行代码的
的转换几乎是立即的, 源代码总是
可用
,因此解释器可以更具体一个错误
发生。


粗体是什么意思?

这意味着解释器不能工作,除非整个程序在内存中?这意味着我们不能将程序分成模块,然后在需要时解释模块(就像我们用编译器)?



如果是,那么背后的原因是什么?






UPDATE:



C ++中思考 - Vol。 1


大多数翻译需要将完整的源代码同时加入解释器。 strong>


那么,现在是否表示我上面写的内容?



解决方案


这是否意味着解释器不能工作,除非整个程序都在内存中?


否。整个程序不需要在内存中。在需要时将部件加载到内存中。


意味着我们不能将程序划分为模块,然后将模块解释为
和在需要时(像我们做的编译器)?


您可以非常好地模块化程序。



并且粗体线:源代码始终可用



这意味着它是运行的源代码,即在运行时转换为机器特定的指令。 逐行,而不转换为不同的(中间)格式。 (由编译器完成)



维基百科中:


href =http://en.wikipedia.org/wiki/Interpreter_%28computing%29 =nofollow>解释器可能是一个使用以下策略执行程序的程序:


  1. 直接执行源代码

  2. 将源代码转换为一些有效的中间表示/ li>
  3. 显式执行存储的预编译代码 1


  4. 效率



    解释器的主要缺点是,当解释程序时,它通常比编译时运行得慢。速度的差异可能很小或很大;经常是一个数量级,有时更多。在解释器下运行程序通常比运行编译的代码需要更长的时间,但解释它所需的时间比编译和运行它所需的总时间要少。这在编写和测试代码时尤其重要,因为编辑 - 解释 - 调试周期通常比编辑 - 编译 - 运行 - 调试周期短得多。



From Thinking in C++ - Vol. 1:

Interpreters have many advantages. The transition from writing code to executing code is almost immediate, and the source code is always available so the interpreter can be much more specific when an error occurs.

What does the bold line mean?
Does it mean that the interpreter cannot work unless whole of the program is in memory? Which means we cannot divide the program into modules and then have the modules interpreted as and when needed (like we do with compilers)?

If yes, then what's the reason behind this?


UPDATE:

From Thinking in C++ - Vol. 1:

Most interpreters require that the complete source code be brought into the interpreter all at once.

So, does this now indicate what I wrote above?

解决方案

Does it mean that the interpreter cannot work unless whole of the program is in memory?

No. The whole program need not to be in memory. the parts are loaded into memory as and when required.

Means we cannot divide the program into modules and then have the modules interpreted as and when needed (like we do with compilers)?

You can very well modularize your programs. but the required modules should be availble when required by interpreter.

And the bold line: the source code is always available

It means that it's the source code that runs, i.e. converted to machine specific instruction at run time. line by line without being converted to a different (intermediate) format. (as is done by compiler)

From Wikipedia:

An interpreter may be a program that uses one the following strategies for program execution:

  1. executes the source code directly
  2. translates source code into some efficient intermediate representation (code) and immediately executes this
  3. explicitly executes stored precompiled code1 made by a compiler which is part of the interpreter system

Efficiency

The main disadvantage of interpreters is that when a program is interpreted, it typically runs more slowly than if it had been compiled. The difference in speeds could be tiny or great; often an order of magnitude and sometimes more. It generally takes longer to run a program under an interpreter than to run the compiled code but it can take less time to interpret it than the total time required to compile and run it. This is especially important when prototyping and testing code when an edit-interpret-debug cycle can often be much shorter than an edit-compile-run-debug cycle.

这篇关于说源代码总是可用于解释器是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆